Home  >  Q&A  >  body text

How can the width of a font style be independently fixed?

<p>There is a horizontal menu: </p> <pre class="brush:php;toolbar:false;"><ul> <li>Text</li> <li>Text 2</li> </ul></pre> <p>When the user clicks on one of the li's, its font becomes bold. Therefore, the width of the li element will change slightly. As a result, the menu jumps. </p> <p>How can I fix it so that it is not affected by the text width? </p>
P粉502608799P粉502608799455 days ago469

reply all(1)I'll reply

  • P粉225961749

    P粉2259617492023-08-14 14:51:47

    You can use CSS to prevent the li width from changing, as shown below:

    ul li {
       width: 150px;
    }

    This will prevent jumping

    reply
    0
  • Cancelreply