小编use*_*865的帖子

导航栏包装在较小的分辨率上

我正在尝试将HTML5/CSS3作为学习过程,但我正在努力创建一个导航栏,用于指向我页面中其他部分的链接.我根据找到的教程调整了代码,但只有在1080p分辨率下才能使用,如果宽度较小,则条形图会覆盖其他线条.

无论用户使用什么分辨率,我如何确保导航栏只占用一行(缩小到适合)?

IMG

这是导航栏的CSS代码.请注意,在导航下我将宽度设置为33.3%并填充相同以使按钮居中.我不知道这是不是原因.

nav {
    display:block;
    position: absolute;
    left:0; 
    white-space:nowrap; 
    margin: 0 auto; 
    width: 33.3%; 
    background-color:#ff6600;
    padding-left: 33.3%; 
    padding-right: 33.3%; 
} 

nav ul { 
    margin: 0 auto; 
    width: 100%; 
    list-style: none;
    display: inline;
    white-space:nowrap; 
} 

nav ul li { 
    float: left;
    position: relative;
    white-space:nowrap; 
} 

nav ul li a { 
    display: block; 
    margin: 0 auto; 
    width: 150px; 
    font-size: 16px;
    font-family: century gothic; 
    line-height: 44px; 
    text-align: center; 
    text-decoration: none; 
    color:#575757;
    white-space:nowrap; 
} 

nav ul ul { 
    width: 200px;
    position:absolute; 
    top:-99999px; 
    left:0; …
Run Code Online (Sandbox Code Playgroud)

css html5 css3 navbar

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

css3 ×1

html5 ×1

navbar ×1