2017-07-22 128 views
2

我根據我的作業創建了我的頁面,除了我做的事情導致我的頁面右側出現了另一個15px,但您必須水平滾動才能看到它。我不確定我做了什麼導致了這一點,但我真的很想找出解決辦法,以及如何解決這個問題。我的頁面右側有一個奇怪的空白

我的代碼:

body { 
 
    margin: 0; 
 
    padding: 0; 
 
    width: 100%; 
 
    background: url("images/background.jpg") no-repeat center center fixed; 
 
    background-size: cover; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-color: rgb(153, 145, 122); 
 
    background: -webkit-linear-gradient(left, aqua, mediumslateblue); 
 
    background: -o-linear-gradient(right, aqua, mediumslateblue); 
 
    background: -moz-linear-gradient(right, aqua, mediumslateblue); 
 
    background: linear-gradient(to right, aqua, mediumslateblue); 
 
    font: 1em Verdana, sans-serif; 
 
} 
 

 
header { 
 
    position: inline; 
 
    width: 100%; 
 
    margin: 0 auto; 
 
    margin-top: 0; 
 
    padding: 0; 
 
    height: 60px; 
 
    line-height: 40px; 
 
    background-color: black; 
 
} 
 

 
ul { 
 
    margin: 0 auto; 
 
    margin-right: 5px 
 
} 
 

 
.imagesEnlarged { 
 
    margin: 0 auto; 
 
    width: 45%; 
 
    height: 45%; 
 
} 
 

 
.logo { 
 
    color: white; 
 
    float: left; 
 
    margin-top: 10px; 
 
    margin-left: 10px; 
 
} 
 

 
.nav { 
 
    float: right; 
 
    color: white; 
 
    margin: 0; 
 
    margin-top: 0; 
 
} 
 

 
nav ul li { 
 
    display: inline; 
 
    float: right; 
 
    padding: 0 5px 
 
} 
 

 
.banner { 
 
    background: url("images/background.jpg") no-repeat center center; 
 
    background-size: cover; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    height: 200px; 
 
    width: 100%; 
 
} 
 

 
#wrapper { 
 
    margin: 5px; 
 
    width: 100%; 
 
} 
 

 
.buttonHolder { 
 
    display: block; 
 
    position: absolute; 
 
    left: 50%; 
 
    top: 80%; 
 
    transform: translate(-50%, -50%); 
 
} 
 

 
.buttonHolderGallery { 
 
    display: block; 
 
    position: absolute; 
 
    left: 50%; 
 
    top: 30%; 
 
    transform: translate(-50%, -50%); 
 
} 
 

 
#text { 
 
    Width: 100%; 
 
    padding: 0; 
 
} 
 

 
li { 
 
    list-style-type: none; 
 
    float: right; 
 
    border-left: 1px solid white; 
 
} 
 

 
li a { 
 
    display: block; 
 
    padding: 8px; 
 
    background-color: black; 
 
} 
 

 
li a:hover { 
 
    background-color: grey; 
 
} 
 

 
.gallery {} 
 

 
footer { 
 
    position: fixed; 
 
    text-align: left; 
 
    bottom: 0; 
 
    right: 0; 
 
    width: 100%; 
 
    height: 65px; 
 
    background-color: black; 
 
} 
 

 
@media only screen and (max-width:1200px) { 
 
    body { 
 
    font-size: 0.8em; 
 
    } 
 
    .buttonHolder { 
 
    top: 65%; 
 
    } 
 
    footer { 
 
    font-size: 0.9em; 
 
    } 
 
    .client { 
 
    display: inline; 
 
    width: 40%; 
 
    } 
 
} 
 

 
@media only screen and (max-width:800px) { 
 
    body { 
 
    font-size: 0.6em; 
 
    } 
 
    .buttonHolder { 
 
    top: 65%; 
 
    } 
 
    footer { 
 
    font-size: 0.9em; 
 
    } 
 
    .images { 
 
    display: block; 
 
    width: 80%; 
 
    } 
 
} 
 

 
.fa-facebook { 
 
    background: #3B5998; 
 
    color: white; 
 
} 
 

 
.fa-twitter { 
 
    background: #55ACEE; 
 
    color: white; 
 
} 
 

 
.fa-linkedin { 
 
    background: #007bb5; 
 
    color: white; 
 
} 
 

 
.white { 
 
    color: white; 
 
    text-align: center; 
 
    float: right 
 
} 
 

 
.fa { 
 
    padding: 20px; 
 
    font-size: 30px; 
 
    width: 10px; 
 
    text-align: center; 
 
    text- decoration: none; 
 
    border-radius: 50%; 
 
} 
 

 
.newspaper { 
 
    -webkit-column-count: 3; 
 
    /* Chrome, Safari, Opera */ 
 
    -moz-column-count: 3; 
 
    /* Firefox */ 
 
    column-count: 3; 
 
    -webkit-column-gap: 60px; 
 
    /* Chrome, Safari, Opera */ 
 
    -moz-column-gap: 60px; 
 
    /* Firefox */ 
 
    column-gap: 60px; 
 
    margin-right: 15px; 
 
} 
 

 
.split { 
 
    -webkit-column-count: 2; 
 
    /* Chrome, Safari, Opera */ 
 
    -moz-column-count: 2; 
 
    /* Firefox */ 
 
    column-count: 2; 
 
    -webkit-column-gap: 80px; 
 
    /* Chrome, Safari, Opera */ 
 
    -moz-column-gap: 80px; 
 
    /* Firefox */ 
 
    column-gap: 80px; 
 
    margin-right: 15px; 
 
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> 
 

 
<header> 
 
    <div class="logo">Photography Masters</div> 
 
    <nav> 
 
    <ul> 
 
     <li><a href="#link"> About</a></li> 
 
     <li><a href="#link"> Contact</a></li> 
 
     <li><a href="#link"> Gallery</a></li> 
 
     <li><a href="#link"> Services</a></li> 
 
    </ul> 
 
    </nav> 
 
</header> 
 

 
<section class="banner"> 
 
</section> 
 

 
<div id="wrapper"> 
 
    <section id="text"> 
 
    <h1>About Us</h1> 
 
    <section class="split"> 
 
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus elementum feugiat risus, a vulputate enim imperdiet at. Suspendisse nec nisi ut sem efficitur pulvinar. Proin eros ex, scelerisque eget eleifend non, vestibulum sit amet lacus. Sed 
 
     dignissim eget libero quis condimentum. Cras ullamcorper aliquet orci ut maximus. Sed congue sem non dui sagittis ultricies non a turpis. Maecenas at mi vestibulum, tempor leo venenatis, sodales massa. Mauris commodo ac mauris a tincidunt. Nunc 
 
     et neque sagittis, ultrices tellus nec, tincidunt mi. Nulla pretium leo libero, quis molestie arcu venenatis et. Phasellus dapibus sem ac tristique gravida. Aliquam felis augue, efficitur egestas orci vitae, convallis viverra nisi. Vivamus quis 
 
     molestie erat, quis gravida arcu. Aliquam enim orci, accumsan sed justo ut, hendrerit lobortis nibh. 
 
     <img class="imagesEnlarged" src=images/about.JPG alt="Model Shoot"> 
 
     </p> 
 
    </section> 
 
    <p>Aliquam quis laoreet enim. Nam eu nunc eu sem suscipit ullamcorper bibendum et velit. Nunc sit amet dui elit. Nullam malesuada, leo ut facilisis tristique, neque massa tempor nibh, vel dignissim nulla sapien fringilla orci. Integer sit amet eros vehicula, 
 
     eleifend velit vel, venenatis metus. Quisque mattis semper vulputate. Ut eu malesuada est, non luctus ipsum. Etiam sed urna viverra, tincidunt est vitae, malesuada diam. Pellentesque ipsum nisi, posuere sed sem at, ultrices tempus dolor. Cras suscipit 
 
     non odio sed tincidunt. Nam ut nisi quis elit semper tempus. Proin ac aliquam quam. Sed luctus convallis hendrerit. </p> 
 
    <div class="buttonHolderGallery"> 
 
     <input class=button type="submit" value="See More"> 
 
    </div> 
 
    </section> 
 
</div> 
 

 
<footer class="grey2"> 
 
    <a href="#" class="fa fa-facebook"></a> 
 
    <a href="#" class="fa fa-twitter"></a> 
 
    <a href="#" class="fa fa-linkedin"></a> 
 
    <a class="white"> Copyright Photography Masters 2017</a> 
 
</footer>

回答

3

保證金在您的包裝<div>是導致此。你可以改變你的CSS這個div喜歡的東西:

margin: 5px 0px 5px 0px; 

去除左,右頁邊距,只是保持它的頂部和底部;擺脫引起問題的多餘空間。

0

每當我有我喜歡通過增加一個紅色邊框的每個元素進行調試,看看誰類似問題導致了問題

*{ 
    border: 1px solid red!important; 
} 

我能夠通過去除餘量權,以減少水平滾動#wrapper元素。

3

由於您添加了此id而導致的正確空間。只要刪除寬度:100%;從這個ID。

#wrapper { 
    margin: 5px; 
    width: 100%; (no need take this out) 
} 
0

更新您的#wrapper指定 CSS用。

#wrapper { 
padding: 0 2%; 
width: 96%; 
}