首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >标题li项不会并排对齐

标题li项不会并排对齐
EN

Stack Overflow用户
提问于 2016-01-11 23:09:20
回答 1查看 235关注 0票数 1

我正试图将标题中的li项并排排列。但是,当我用内联显示和左浮动定义ul & li时,我想要实现的不会发生,让li项仍然垂直地而不是水平地堆叠在一起?

代码语言:javascript
复制
* {
    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;
}
代码语言:javascript
复制
<header>
  <div class="header-wrapper">
    <div class="header-bg"></div>
    <div class="header-content">
      <ul id="horizontal-list">
        <li class="instagram"> <a href="" class="navBarLinks">Social Icon</a></li>
        <li class="home"><a href="" class="navBarLinks">Logo </a></li>
        <li class="hamburger"><a href="" class="navBarLinks">Hamburger</a></li>
      </ul>
    </div>
  </div>
</header>
<content>
<div class="stage stage-0">1</div>
<div class="stage stage-2">3</div>
<div class="stage stage-4">5</div>
<div class="stage stage-6">7</div>
<div class="stage stage-8">9</div>
<div class="stage stage-10">11</div>
<div class="stage stage-12">13</div>
<div class="stage stage-14">15</div>
<div class="stage stage-16">17</div>
<div class="stage stage-18">19</div>
<div class="stage stage-20">21</div>
<div class="stage stage-22">23</div>
</content>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-11 23:15:01

由于以下原因,列表项垂直堆叠:

代码语言:javascript
复制
* {
    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%;放置在类上或其他一些目标元素的方法上可能更谨慎。*通常用于默认样式的绝对重置。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34732841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档