我正试图将标题中的li项目并排排列.然而,当我用内联显示和左浮动定义ul&li时我想要实现的是不会发生li项目仍然垂直堆叠而不是水平并排?
* {
margin: 0;
padding: 0;
width: 100%;
margin: 0;
list-style: none;
text-decoration: none;
font-size: 1em;
font-family: Helvetica Neue, Helvetica,Arial,Sans-serif;
}
a {
background: transparent;
border: none;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: .3s color;
transition: .3s height;
}
header {
display: block;
position: fixed;
height: 80px;
width: 100%;
}
.header-wrapper {
width: 100%;
height: 100%;
background: transparent;
}
.header-bg,
.header-content {
position: fixed;
top: 0;
left: 0;
width: 100%;
text-align: center;
}
.header-bg {
color: gray;
background: white;
border-bottom: 1px solid black;
transition: .3s height;
height: 0;
}
.header-content {
transition: .3s color;
color: white;
background: transparent;
height: 80px;
transition: .3s height;
overflow: hidden;
list-style: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline-block;
float:left;
}
.navBarLinks {
color: inherit;
cursor: pointer;
font-size: .8em;
letter-spacing: 0.05em;
transition: .3s color;
}
content {
display: block;
height: 2000px;
background: orange;
}
.stage {
color: #fff;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 100vh;
background: white;
border-bottom: 1px solid black;
font-size: 48px;
height: 200px;
width: 100%;
}
.stage-0 {
background: grey;
height: 400px;
}
1
3
5
7
9
11
13
15
17
19
21
23
您的列表项垂直堆叠,因为:
* { margin: 0; padding: 0; width: 100%; /*right here*/ margin: 0; list-style: none; text-decoration: none; font-size: 1em; font-family: Helvetica Neue, Helvetica,Arial,Sans-serif; }
每个列表项 - 就此而言 - 的宽度都是100%,所以它们被迫堆叠.考虑放置width:100%;
一个类或一些其他方法来定位元素可能更为谨慎.*
通常用于默认样式的绝对重置.