CSS border effecting width when resizing browser

前端 未结 2 509
野的像风
野的像风 2021-01-15 12:41

I made two simple navigation menu using ul and li. One without border and another with border. The width of the both menu is fixed with 400px.

2条回答
  •  Happy的楠姐
    2021-01-15 13:42

    The border width doesn't scale together with the li width, that's why the menu breaks. So one solution can simply be:

    .nav2 ul li {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }
    

    http://jsfiddle.net/jhz56/1/

提交回复
热议问题