即使div的边距和填充设置为0,背景尺寸设置为“ cover”,div的背景图像的上方和下方仍会出现空白(它是div class =“ content”)。谁能告诉我我在做什么错?
这是页面:
https://sstrudel.github.io/authentic-wood/index.html
HTML: `
<title>Authentic Wood Countertops</title>
</head>
<body>
<div class="top-head">
<div class="quote">Call 760.920.2539 for a free quote</div>
<a href="https://www.instagram.com/rob_1098/" target="new"><img class="socmed" src="instagram.png" /></a> <a href="https://www.facebook.com/pages/One-Source-Stone/120481204726210" target="new"><img class="socmedfb" src="facebook.png" /></a> <a href="https://twitter.com/OneSourceStone" target="new"><img class="socmed" src="twitter.png" /></ad> <a href="http://www.linkedin.com" target="new"><img class="socmed" src="linkedin.png" /></a></div>
<div class="header">
<img class="logo" src="Authentic_Wood_Countertops.png" />
</div>
<div class="navbar" id="navbar">
<label for="show-menu" class="show-menu">Menu</label>
<input type="checkbox" id="show-menu" role="button">
<ul id="menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="design-options.html">Design Options</a></li>
<li><a href="portfolio.html">Portfolio</a></li>
<li><a href="#">Blog</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="slide-container">
<div class="slideshow">
<img class="mySlides" src="Countertop9.jpg">
<img class="mySlides" src="Countertop9b.jpg">
<img class="mySlides" src="Countertop10.jpg">
</div>
</div>
<div class="maincontent">
Authentic Wood Countertops has been in the business of making beautiful, high quality wood countertops since 2010. As a premier West Coast retailer of wood countertops, Authentic Wood is capable of producing custom, solid wood countertops from over 25 different species of wood in as little as 3 weeks.
</div>
<br /><br />
<hr />
<div class="content">
<center><div class="container-2">
<div><a href="company.html"><img src="company.jpg" width="50%"></a></div>
<div><a href="warranty.html"><img src="warranty.jpg" width="50%"></a></div>
<div><a href="testimonials.html"><img src="testimonials.jpg" width="50%"></a></div>
</div></center>
</div>
<script>
window.onscroll = function() {myFunction()};
var navbar = document.getElementById("navbar");
var sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
</script>
<script>
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 5000); // Change image every 5 seconds
}
</script>
<hr />
<div class="footer">
<div class="footer-links">
<a href="index.html">Home</a> |
<a href="about.html">About</a> |
<a href="design-options.html">Design Options</a> |
<a href="portfolio.html">Portfolio</a> |
<a href="#home">Blog</a> |
<a href="contact.html">Contact</a>
</div>
<div class="copyright-closing">
Site design by <a href="http://samanthastreuli.com">Samantha Streuli</a> <br />
© 2018 Authentic Wood Countertops</div>
</div>
</body>
</html>`
CSS:
https://github.com/sstrudel/authentic-wood/blob/master/style.css
答案 0 :(得分:2)
您的水平尺上有边距。如果为它们设置样式,则可以消除间距问题。
hr {
margin: 0px;
}
从外观上来说,我只是在您的border-top
div中添加一个border-bottom
和一个.container-2
,因为那样会使您有一种想要的感觉。如果您选择此路线,则还需要添加填充。您的代码可能看起来像这样:
.container-2 {
padding: 10px 0px;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}