<tfoot id='kcd7r'></tfoot>

      <legend id='kcd7r'><style id='kcd7r'><dir id='kcd7r'><q id='kcd7r'></q></dir></style></legend>
          <bdo id='kcd7r'></bdo><ul id='kcd7r'></ul>

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

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

        悬停时加粗时内联元素移动

        Inline elements shifting when made bold on hover(悬停时加粗时内联元素移动)
        <tfoot id='6xqfC'></tfoot>
      1. <small id='6xqfC'></small><noframes id='6xqfC'>

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

                <tbody id='6xqfC'></tbody>
                  <bdo id='6xqfC'></bdo><ul id='6xqfC'></ul>
                  本文介绍了悬停时加粗时内联元素移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 HTML 列表和 CSS 创建了一个水平菜单.除非您将鼠标悬停在链接上,否则一切正常.你看,我为链接创建了一个粗体悬停状态,现在菜单链接由于粗体大小不同而发生了变化.

                  I created a horizontal menu using a HTML lists and CSS. Everything works as it should except when you hover over the links. You see, I created a bold hover state for the links, and now the menu links shift because of the bold size difference.

                  我遇到了与 此 SitePoint 帖子相同的问题.但是,该帖子没有适当的解决方案.我到处寻找解决方案,但找不到.当然,我不可能是唯一一个尝试这样做的人.

                  I encounter the same problem as this SitePoint post. However, the post does not have proper solution. I've searched everywhere for a solution and can't find one. Surely I can't be the only one trying to do this.

                  有人有什么想法吗?

                  P.S:我不知道菜单项中文本的宽度,所以我不能只设置 li 项的宽度.

                  P.S: I don't know the width of the text in menu items so I cannot just set the width of the li items.

                  .nav { margin: 0; padding: 0; }
                  .nav li { 
                      list-style: none; 
                      display: inline; 
                      border-left: #ffffff 1px solid; 
                  }
                  .nav li a:link, .nav li a:visited { 
                      text-decoration: none; 
                      color: #000; 
                      margin-left: 8px; 
                      margin-right: 5px; 
                  }
                  .nav li a:hover{ 
                      text-decoration: none; 
                      font-weight: bold; 
                  }
                  .nav li.first { border: none; }

                  <ul class="nav">
                      <li class="first"><a href="#">item 0</a></li>
                      <li><a href="#">item 1</a></li>
                      <li><a href="#">item 2</a></li>
                      <li><a href="#">item 3</a></li>
                      <li><a href="#">item 4</a></li>
                  </ul>

                  推荐答案

                  预设宽度,使用一个不可见的伪元素,其内容和样式与父悬停样式相同.使用数据属性,如 title,作为内容的来源.

                  Pre-set the width by using an invisible pseudo-element which has the same content and styling as the parent hover style. Use a data attribute, like title, as the source for content.

                  li {
                      display: inline-block;
                      font-size: 0;
                  }
                  
                  li a {
                      display:inline-block;
                      text-align:center;
                      font: normal 16px Arial;
                      text-transform: uppercase;
                  }
                  
                  a:hover {
                      font-weight:bold;
                  }
                  
                  /* SOLUTION */
                  /* The pseudo element has the same content and hover style, so it pre-sets the width of the element and visibility: hidden hides the pseudo element from actual view. */
                  a::before {
                      display: block;
                      content: attr(title);
                      font-weight: bold;
                      height: 0;
                      overflow: hidden;
                      visibility: hidden;
                  }

                  <ul>
                      <li><a href="#" title="height">height</a></li>
                      <li><a href="#" title="icon">icon</a></li>
                      <li><a href="#" title="left">left</a></li>
                      <li><a href="#" title="letter-spacing">letter-spacing</a></li>
                      <li><a href="#" title="line-height">line-height</a></li>
                  </ul>

                  这篇关于悬停时加粗时内联元素移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  chartjs time cartesian axis adapter and date library setup(chartjs 时间笛卡尔轴适配器和日期库设置)
                  How to apply gradient color in chart.js?(如何在 chart.js 中应用渐变颜色?)
                  Side effects from Chartjs for only *some* clients(Chartjs 的副作用仅适用于 *一些* 客户)
                  Chart js different background for y axis(图表 js y 轴的不同背景)
                • <i id='qXyHo'><tr id='qXyHo'><dt id='qXyHo'><q id='qXyHo'><span id='qXyHo'><b id='qXyHo'><form id='qXyHo'><ins id='qXyHo'></ins><ul id='qXyHo'></ul><sub id='qXyHo'></sub></form><legend id='qXyHo'></legend><bdo id='qXyHo'><pre id='qXyHo'><center id='qXyHo'></center></pre></bdo></b><th id='qXyHo'></th></span></q></dt></tr></i><div id='qXyHo'><tfoot id='qXyHo'></tfoot><dl id='qXyHo'><fieldset id='qXyHo'></fieldset></dl></div>

                  <legend id='qXyHo'><style id='qXyHo'><dir id='qXyHo'><q id='qXyHo'></q></dir></style></legend>
                    <tbody id='qXyHo'></tbody>

                  • <bdo id='qXyHo'></bdo><ul id='qXyHo'></ul>
                      • <tfoot id='qXyHo'></tfoot>

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