• <bdo id='oVj5g'></bdo><ul id='oVj5g'></ul>

      <legend id='oVj5g'><style id='oVj5g'><dir id='oVj5g'><q id='oVj5g'></q></dir></style></legend>

    1. <tfoot id='oVj5g'></tfoot>
    2. <i id='oVj5g'><tr id='oVj5g'><dt id='oVj5g'><q id='oVj5g'><span id='oVj5g'><b id='oVj5g'><form id='oVj5g'><ins id='oVj5g'></ins><ul id='oVj5g'></ul><sub id='oVj5g'></sub></form><legend id='oVj5g'></legend><bdo id='oVj5g'><pre id='oVj5g'><center id='oVj5g'></center></pre></bdo></b><th id='oVj5g'></th></span></q></dt></tr></i><div id='oVj5g'><tfoot id='oVj5g'></tfoot><dl id='oVj5g'><fieldset id='oVj5g'></fieldset></dl></div>

      <small id='oVj5g'></small><noframes id='oVj5g'>

    3. 如何使图像悬停在css中?

      时间:2023-11-29

        <bdo id='dvv8a'></bdo><ul id='dvv8a'></ul>

          <tbody id='dvv8a'></tbody>

        <small id='dvv8a'></small><noframes id='dvv8a'>

        <i id='dvv8a'><tr id='dvv8a'><dt id='dvv8a'><q id='dvv8a'><span id='dvv8a'><b id='dvv8a'><form id='dvv8a'><ins id='dvv8a'></ins><ul id='dvv8a'></ul><sub id='dvv8a'></sub></form><legend id='dvv8a'></legend><bdo id='dvv8a'><pre id='dvv8a'><center id='dvv8a'></center></pre></bdo></b><th id='dvv8a'></th></span></q></dt></tr></i><div id='dvv8a'><tfoot id='dvv8a'></tfoot><dl id='dvv8a'><fieldset id='dvv8a'></fieldset></dl></div>
        • <tfoot id='dvv8a'></tfoot>

            1. <legend id='dvv8a'><style id='dvv8a'><dir id='dvv8a'><q id='dvv8a'></q></dir></style></legend>

                本文介绍了如何使图像悬停在css中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想在悬停时将图像从正常更改为更亮,我的代码:

                 <div class="nkhome"><a href="Home.html"><img src="Images/btnhome.png"/></a></div>.nkhome{左边距:260px;顶部:170px;位置:绝对;宽度:59px;高度:59px;}.nkhome 一个 img:hover {背景:网址(图片/btnhomeh.png);位置:绝对;顶部:0px;}

                为什么悬停不起作用?当我的鼠标在它上面时,它会显示第一张图像,而不是悬停图像.

                解决方案

                你有一个包含 img 标签的 a 标签.那是你的正常状态.然后添加一个 background-image 作为悬停状态,它会出现在 a 标签的背景中 - 在 img 标签后面.

                您可能应该创建一个 CSS 精灵并使用背景位置,但这应该可以帮助您开始:

                <a href="home.html"></a></div>div一个{宽度:59px;高度:59px;显示:块;背景图片: url('images/btnhome.png');}div a:悬停{背景图片: url('images/btnhomeh.png);}

                这篇 A List Apart 2004 年的文章 仍然具有相关性,将为您提供一些关于sprites,以及为什么使用它们而不是两个不同的图像是个好主意.写得比我能向你解释的任何东西都要好.

                I want to change the image from normal to brighter when it's on hover, My code:

                    <div class="nkhome">
                        <a href="Home.html"><img src="Images/btnhome.png" /></a>
                    </div>
                .nkhome{
                    margin-left:260px;
                    top:170px;
                    position:absolute;
                    width:59px;
                    height:59px;
                }
                .nkhome a img:hover {
                    background:url(Images/btnhomeh.png);
                    position:absolute;
                    top:0px;
                }
                

                Why doesn't work the hover? When my mouse is on it, it shows the first image, not the hover image.

                解决方案

                You've got an a tag containing an img tag. That's your normal state. You then add a background-image as your hover state, and it's appearing in the background of your a tag - behind the img tag.

                You should probably create a CSS sprite and use background positions, but this should get you started:

                <div>
                    <a href="home.html"></a>
                </div>
                
                div a {
                    width:  59px;
                    height: 59px;
                    display: block;
                    background-image: url('images/btnhome.png');
                }
                
                div a:hover {
                    background-image: url('images/btnhomeh.png);
                }
                

                This A List Apart Article from 2004 is still relevant, and will give you some background about sprites, and why it's a good idea to use them instead of two different images. It's a lot better written than anything I could explain to you.

                这篇关于如何使图像悬停在css中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:CSS中不规则多边形的悬停效果 下一篇:具有 Rowspan 悬停和斑马效果的表格

                相关文章

                  <bdo id='pzp1D'></bdo><ul id='pzp1D'></ul>

              1. <small id='pzp1D'></small><noframes id='pzp1D'>

                    <legend id='pzp1D'><style id='pzp1D'><dir id='pzp1D'><q id='pzp1D'></q></dir></style></legend>
                    <i id='pzp1D'><tr id='pzp1D'><dt id='pzp1D'><q id='pzp1D'><span id='pzp1D'><b id='pzp1D'><form id='pzp1D'><ins id='pzp1D'></ins><ul id='pzp1D'></ul><sub id='pzp1D'></sub></form><legend id='pzp1D'></legend><bdo id='pzp1D'><pre id='pzp1D'><center id='pzp1D'></center></pre></bdo></b><th id='pzp1D'></th></span></q></dt></tr></i><div id='pzp1D'><tfoot id='pzp1D'></tfoot><dl id='pzp1D'><fieldset id='pzp1D'></fieldset></dl></div>
                  1. <tfoot id='pzp1D'></tfoot>