CSS Border-Line不会显示100%宽度

时间:2015-11-20 22:44:38

标签: html css

我已经在#navpromo的CSS中放置了一个border-top,但是边框线不会以100%的宽度显示,而是与页面左边的空格对齐,而不管我尝试什么?

CSS:

/*global styles*/
body {
width: 100%;
margin: 0;
list-style: none;
text-decoration: none;
font-size:1.05em;
font-family: Helvetica Neue, Helvetica, Arial, Sans-serif;
}

a{
appearance: none;
font-size:1.05em;
font-family: Helvetica Neue, Helvetica, Arial, Sans-serif;
background:transparent;
color: #000000;
border:none;
letter-spacing:0.15em;
text-transform:uppercase;
transition: color 0.5s ease;
list-style: none;
text-decoration: none;
}

a:focus, a:hover {  
color: #e6e8eb;
cursor:pointer;
transition: color 0.5s ease;
}

a:active { 
color: #484747; 
}
/*----/----global styles*/

/*navigation icon*/
#toggle-menu {
float:right;
display: block;
width: 15px;
height: 15px;
padding: 20px;
}

#toggle-menu div {
width: 15px;
height: 15px;
position: relative;
}

#toggle-menu span {
display: block;
width: 15px;
height: 3px;
background: #545454;
position: absolute;
-webkit-transition: -webkit-transform 0.2s ease-in-out, top 0.2s ease-in-out 0.2s, opacity 0.2s ease-in-out 0.2s;
-moz-transition: -moz-transform 0.2s ease-in-out, top 0.2s ease-in-out 0.2s, opacity 0.2s ease-in-out 0.2s;
transition: transform 0.2s ease-in-out, top 0.2s ease-in-out 0.2s, opacity 0.2s ease-in-out 0.2s;
-webkit-transform-origin: center;
-moz-transform-origin: center;
transform-origin: center;
}

#toggle-menu span.top {
top: 0px;
}

#toggle-menu span.middle {
top: 6px;
}

#toggle-menu span.bottom {
top: 12px;
} 
/*----/----navigation icon*/

/*navigation icon animation*/
#toggle-menu.menu-is-active span {
-webkit-transition: -webkit-transform 0.2s ease-in-out 0.2s, top 0.2s ease-in-out, opacity 0.2s ease-in-out;
-moz-transition: -moz-transform 0.2s ease-in-out 0.2s, top 0.2s ease-in-out, opacity 0.2s ease-in-out;
transition: transform 0.2s ease-in-out 0.2s, top 0.2s ease-in-out, opacity 0.2s ease-in-out;
}

#toggle-menu.menu-is-active span.top, #toggle-menu.menu-is-active span.middle {
top: 6px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}

#toggle-menu.menu-is-active span.middle {
opacity: 0;
}

#toggle-menu.menu-is-active span.bottom {
top: 6px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
}
/*----/----navigation icon animation*/

/*Nav Bar*/
.header {
border-bottom: 0.5px solid rgba(0,0,0,.2);
background: #ffffff;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 99999;
}

.nav {
position: fixed;
width: 100%;
text-align: center;
display: inline;
background-color: #ffffff;
left: 0;
top: 39px;
border-bottom: 0.5px solid rgba(0,0,0,.2);
border-top: 0.5px solid rgba(0,0,0,.2);
cursor: pointer;
color: #545454;
font-size:.8em;
letter-spacing:0.05em;
}


.nav > li {
left: 0;
padding-top: 70px;
padding-bottom: 70px;
display: inline-block;
padding-right: 60px;
color: #545454;
}

.seemore {
display: inline-block;
padding-right: 20px;
}

#navpromo{
border-top: 0.5px solid rgba(0,0,0,.2);
padding-top: 40px;
padding-bottom: 40px;
}

#instagram{
display: inline-block;
appearance: none;
width:120px;
height:50px;
font-size:1.05em;
background: transparent;
color: #464c4c; 
border:none;
text-align: center;
letter-spacing:0.15em;
text-transform:uppercase;
transition: color 0.5s ease;
outline:none;
border:none;
box-shadow: rgba(30, 22, 54, 0.4) 0 0px 0px 2px inset;
}

#instagram:hover {
color: #e6e8eb;
cursor:pointer;
transition: color 0.5s ease;
}

.nav > li:hover {
left: 0;
padding-top: 0.6em;
padding-bottom: 1em;
cursor:pointer;
}
/*----/----Nav Bar*/

/*in*/
.in {
float:left;
display: inline-block;
width: 25px;
height: 25px;
padding: 15px;
cursor: pointer;
color: #545454;
font-size:.8em;
letter-spacing:0.05em;
border-top: 0.5px solid rgba(0,0,0,.2);
}
/*----/----in*/

/*logo*/
.logo {
position: absolute;
left: 50%;
display: inline-block;
width: 15px;
height: 15px;
padding: 18px;
cursor: pointer;
color: #545454;
font-size:.8em;
letter-spacing:0.05em;
}
/*----/----logo*/

/*Panels*/
.panel {
width: 100%;
color: #adadad;
height: 15em;
padding: 7em;
box-sizing: border-box;
background: #ffffff;
border-top: 0.5px solid rgba(0,0,0,.2);
text-align: center;
}

#panel1 {
background: #b8b8b8;
height: 30em;
}

.links{
color: #adadad;
}

/*----/----Panels*/

/*promo video scroll*/
#hero, section {
padding: 150px;
}

#scroll {
color: white;
font-size: 26px;
line-height: 26px;
cursor: pointer;
position: absolute;
left:50%;
-webkit-transition: -webkit-transform 0.6s ease;
-moz-transition: -moz-transform 0.6s ease;
transition: transform 0.6s ease;
}
#scroll.clicked {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
}
#scroll.rotate {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(3180deg);
}
#scroll span {
position: relative;
bottom: -10px;
}

.arrow-bounce {
-webkit-animation: arrow 1s infinite;
-moz-animation: arrow 1s infinite;
-o-animation: arrow 1s infinite;
animation: arrow 1s infinite;
animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

@-webkit-keyframes arrow {
0% {
bottom: -13px;
}
50% {
bottom: -8px;
}
100% {
bottom: -13px;
}
}
@-moz-keyframes arrow {
0% {
bottom: -13px;
}
50% {
bottom: -8px;
 }
100% {
bottom: -13px;
}
}
@keyframes arrow {
0% {
bottom: -13px;
}
50% {
bottom: -8px;
}
100% {
bottom: -13px;
}
}
/*----/----promo video scroll*/

/*contact panel*/
* {
font-family: "helvetica";
font-weight: normal;
font-size: 1em;
}

#wrapper {
width: 100%;
padding: 30px 20px;
text-align: center;
box-sizing: border-box;
color: #adadad;
background: #ededed;
font-size:.8em;
letter-spacing:0.05em;
border-top: 0.5px solid rgba(0,0,0,.2);
}

[value*='Contact'], .module fieldset [type="submit"] [id="changetext"] {
appearance: none;
width:120px;
height:50px;
font-size:1.05em;
background: transparent;
color: #e6e8eb;
border:none;
text-align: center;
letter-spacing:0.15em;
text-transform:uppercase;
transition: color 0.5s ease;
outline:none;
border:none;
box-shadow: rgba(30, 22, 54, 0.4) 0 0px 0px 2px inset;
}

[value*='Contact'], .module fieldset [type="submit"] [id="changetext"]:hover {
color: #464c4c;
cursor:pointer;
transition: color 0.5s ease;
}

.module {
width: 100%;
margin: 1rem auto;
padding: 1rem;
}

.module fieldset {
overflow: hidden;
border: none;
}

.module fieldset [type="text"] {
display: block;
margin: 0 auto;
width: 80%;
border: 0;
border-bottom: 1px solid rgba(0,0,0,.2);
line-height: 20px;  
margin-bottom: 10px;
font-size: 1em;
background: transparent;
color: rgba(0,0,0,.4);
width: 50%;
padding: 0.5rem;
}

.single {
height: 25px;
}

.module fieldset textarea {
display: block;
width: 100%;
padding: 1rem;
height: 125px;
}
/*----/----contact form*/

/*social panel*/
.followcontainer {
text-align: center;
background: #ededed;
}

.follow {
left: 50%;
display: inline-block;
width:  175px;
text-align: center;
padding-top: 2em;
padding-bottom: 4em;
color: #adadad;
background: #ededed;
font-size:.8em;
letter-spacing:0.05em;
}

.followcopywright {
left: 50%;
display: inline-block;
text-align: center;
padding-top: 2em;
padding-bottom: 4em;
color: #adadad;
background: #ededed;
font-size:.8em;
letter-spacing:0.05em;
}

/*social icons*/
.social-buttons {
height: 45px;
font-size: 0;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
background: #ededed;
}

.social-button {
display: inline-block;
background-color: #ededed;
width: 45px;
height: 45px;
line-height: 45px;
margin: 0 10px;
text-align: center;
position: relative;
overflow: hidden;
opacity: .99;
border-radius: 50%;
box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.05);
-webkit-transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
}

.social-button:before {
content: '';
background-color: #000;
width: 120%;
height: 120%;
position: absolute;
top: 90%;
left: -110%;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
}

.social-button .fa {
font-size: 38px;
vertical-align: middle;
-webkit-transform: scale(0.8);
-ms-transform: scale(0.8);
transform: scale(0.8);
-webkit-transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
transition: all 0.35s cubic-bezier(0.31, -0.105, 0.43, 1.59);
}

.social-button.facebook:before {
background-color: #3B5998;
}

.social-button.facebook .fa {
color: #3B5998;
}

.social-button.twitter:before {
background-color: #3CF;
}

.social-button.twitter .fa {
color: #3CF;
}

.social-button.google:before {
background-color: #DC4A38;
}

.social-button.google .fa {
color: #DC4A38;
}

.social-button.dribbble:before {
background-color: #F26798;
}

.social-button.dribbble .fa {
color: #F26798;
}

.social-button.skype:before {
background-color: #00AFF0;
}

.social-button.skype .fa {
color: #00AFF0;
}

.social-button:focus:before, .social-button:hover:before {
top: -10%;
left: -10%;
}

.social-button:focus .fa, .social-button:hover .fa {
color: #fff;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
/*----/----social panel*/

/*footer*/
footer {
float: left;
display: inline-block;
text-align: center;
background: 232,232,232,0;
border-top: 1px solid rgba(0,0,0,.2);
}
/*----/----footer*/

/****landscape****/
@media (min-width: 850px) {


}
/*----/----Landscape*/

HTML:

<div class="header">
<div class="navbar">

<a href="" class="in" style="display: inline-block;"> 
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"    xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 viewBox="0 0 155.2 144" style="enable-background:new 0 0 155.2 144;"    xml:space="preserve">
<path style="fill:#545454;" d="M42.7,122.7H21.3V54h21.4V122.7z M32,44.6c-6.8,0-12.4-5.6-12.4-12.4c0-6.8,5.5-12.4,12.4-12.4
c6.8,0,12.4,5.5,12.4,12.4C44.4,39,38.9,44.6,32,44.6z M122.7,122.7h-21.3V89.3c0-8-0.1-18.2-11.1-18.2c-11.1,0-12.8,8.7-12.8,17.6
v34H56.1V54h20.5v9.4h0.3c2.8-5.4,9.8-11.1,20.2-11.1c21.6,0,25.6,14.2,25.6,32.7V122.7z"/>
<g>
<path style="fill:#FFFFFF;" d="M151.9,120c0.7-0.1,1-0.5,1-1.1c0-0.8-0.5-1.1-1.4-1.1H150v4h0.6V120h0.7l0,0l1.1,1.7h0.6L151.9,120
    L151.9,120z M151.3,119.6h-0.7v-1.4h0.9c0.4,0,0.9,0.1,0.9,0.6C152.4,119.5,151.9,119.6,151.3,119.6z"/>
<path style="fill:#FFFFFF;" d="M151.3,116c-2.1,0-3.8,1.7-3.8,3.8c0,2.1,1.7,3.8,3.8,3.8c2.1,0,3.8-1.7,3.8-3.8
    C155.2,117.6,153.5,116,151.3,116z M151.3,123.1c-1.8,0-3.3-1.4-3.3-3.3c0-1.9,1.4-3.3,3.3-3.3c1.8,0,3.3,1.4,3.3,3.3
    C154.6,121.7,153.2,123.1,151.3,123.1z"/>
</g>
</svg>
</a>

<a href="" class="logo" style="display: inline-block;">Logo</a>

<a id="toggle-menu">
<div>
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
</div>
</a>

<ul class="nav">
<li><a href="" style="display: inline-block; width:100%;">Home</a></li>
<li><a href="#panel9" style="display: inline-block; width:100%;">About</a></li>
<li><a href="#panel2" style="display: inline-block; width:100%;">Work</a></li>
<li><a href="#panel8" style="display: inline-block; width:100%;">Contact</a></li>
<div id="navpromo">
<li class="seemore">Want to see more? Check out my instagram!</li>  
</li><input type='submit' id="instagram" value="instagram"> </li>
</div>
</ul>



</div>
</div>

<div class="maincontent">

<div class="panel" id="panel1">

<div id="hero">
</div>

<div id="scroll">
<span class="arrow-bounce">&#8595;</span>

</div>

</div> 

<div class="panel" id="panel2">
<div class="inner"> 
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 1</a> 
</div>
</div>

<div class="panel" id="panel3">
<div class="inner"> 
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 2</a> 
</div>
</div>

<div class="panel" id="panel4">
<div class="inner"> 
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 3</a> 
</div>
</div> 

<div class="panel" id="panel5">
<div class="inner"> 
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 4</a> 
</div>
</div>

<div class="panel" id="panel6">
<div class="inner"> 
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 5</a> 
</div>
</div>

<div class="panel" id="panel7">
<div class="inner">  
<a href="" class="links" style="display: inline-block; width:100%;">Work Title 6</a> 
</div>
</div>

<div id='wrapper'>
<input type='submit' value='Contact' id="changetext">
<div class='module' id='measure'>
<fieldset>
<legend></legend>
<input class="single" type='text' placeholder='Name'  />
<input class="single" type='text' placeholder='Email'  />
<input class="single" type='text' placeholder='Phone'  />
<textarea class="message" type='text' placeholder='Message' ></textarea>
<input type='submit' id="send">
</fieldset>
</div>
</div>

<div class="followcontainer">
<div class="follow"> <p>I'd love to hear from you.</p>Drop me a line at @email.com.Boost my ego with a Facebook like.And please stalk me on Instagram @instagram.</div>
</div>

<div class="social-buttons">
<a href="#" class="social-button facebook"><i class="fa fa-facebook"></i></a>
<a href="#" class="social-button twitter"><i class="fa fa-twitter"></i></a>
<a href="#" class="social-button google"><i class="fa fa-google"></i></a>
<a href="#" class="social-button dribbble"><i class="fa fa-dribbble"></i></a>
<a href="#" class="social-button skype"><i class="fa fa-skype"></i></a>
</div>

<div class="followcontainer">
<div class="followcopywright">© Copywright 2015</div>
</div>

2 个答案:

答案 0 :(得分:1)

更改以下内容:

<强> CSS:

.nav {
position: fixed;
width: 100%;
text-align: center;
display: inline;
background-color: #ffffff;
left:-40px;
top: 39px;
border-bottom: 0.5px solid rgba(0,0,0,.2);
border-top: 0.5px solid rgba(0,0,0,.2);
cursor: pointer;
color: #545454;
font-size:.8em;
letter-spacing:0.05em;
clear:both;
}

.nav > li:last-child{
width:100%;
display:block;
}

<强> HTML

<ul class="nav">
<li><a href="" style="display: inline-block; width:100%;">Home</a></li>
<li><a href="#panel9" style="display: inline-block; width:100%;">About</a></li>
<li><a href="#panel2" style="display: inline-block; width:100%;">Work</a></li>
<li><a href="#panel8" style="display: inline-block; width:100%;">Contact</a></li>
<li>
<div id="navpromo">
    <ul>
<li class="seemore">Want to see more? Check out my instagram!</li>  
        </li><input type='submit' id="instagram" value="instagram"> </li></ul>
</div>
    </li>
</ul>

答案 1 :(得分:0)

您还可以通过将以下样式添加到.nav类来删除ul.nav中的填充。

padding-left:0;

所有ul元素都有默认填充。