<tfoot id='8Iht3'></tfoot>

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

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

        <small id='8Iht3'></small><noframes id='8Iht3'>

          <bdo id='8Iht3'></bdo><ul id='8Iht3'></ul>

        使图像出现在链接悬停css上

        时间:2023-11-01

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

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

                1. <tfoot id='I5k7I'></tfoot>
                    <tbody id='I5k7I'></tbody>

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

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

                  问题描述

                  我正在使用这个可能很简单的解决方案,但我在 stackoverflow 或与此特定问题相关的互联网上找不到任何帮助.

                  I am working with this, probably simple solution, but I couldn't find any help on stackoverflow or the internet relating to this specific problem.

                  我有一个菜单,我想让图片显示在链接下方或当您将鼠标悬停在其附近时.我希望这可以在 CSS 中完成.这是我目前的代码.

                  I have a menu, and I want to make an image appear under the link or close by when you hover over it. I hope this can be done in CSS. This is my code so far.

                  HTML

                  <html>
                      <head>
                          <title></title>
                  
                          <link rel="stylesheet" type="text/css" href="startpage.css">
                  
                  
                          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                      </head>
                      <body>
                       <div id="wrapper">
                  
                  
                           <img id="baggrund" width="166" height="327" alt="back image" src="images/laerkeryg.jpg"/>
                           <img id="cirkler" width="319" height="249" alt="circles" src="images/circles.PNG"/>
                           <div id="header">/jacob gerlif pilegaard/</div>
                           <div id="underheader">portfolio</div>   
                            <ul>
                              <li><a href="index.html">home</a></li>
                              <li><a href="about.html">about</a></li>
                              <li><a href="gallery.html">gallery</a></li>
                              <li><a href="contact.html">contact</a></li>
                              </ul> 
                           </div>
                       <img id="menucircle" width="50" height="50" alt="menu circle" src="images/circle.PNG"/>
                            </body>
                  </html>
                  

                  这是目前的 CSS:

                  a:hover
                  {
                      background-image: url('image/circle.PNG');
                      background-repeat: no-repeat;
                  }
                  

                  希望大家能帮帮我!

                  推荐答案

                  干净的处理方法是使用 :after 伪元素

                  The clean way to deal with it is to use :after pseudo element

                  a:hover:after {
                      content: url(image/circle.PNG); /* no need for qoutes */
                      display: block;
                  }
                  

                  您甚至不需要图像出现在 DOM 中.
                  还要记住,图像的路径将相对于 CSS 文件,而不是 HTML 文件.

                  You don't even need the image to be present in the DOM.
                  Also remember that the path to the image will be relative to the CSS file, not the HTML file.

                  当然,图片会下推锚点下方的内容.为避免这种情况,您可以尝试:

                  Of course, the image will push down the content below the anchor. To avoid this you can try:

                  a:hover {
                      position: relative;
                  }
                  a:hover:after {
                      content: url(image/circle.PNG); /* no need for qoutes */
                      display: block;
                      position: absolute;
                      left: 123px; /* change this value to one that suits you */
                      top: 56px; /* change this value to one that suits you */
                  }
                  

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

                  上一篇:显示 <div>或&lt;跨度&gt;在图像上:悬停 下一篇:IE8:Div hover 只在设置背景色时有效,很奇怪,为什么?

                  相关文章

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

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