我有一个内部有图像的容器。我使用CSS列和媒体查询来确定我的布局。我在底部放了一个段落标签,注意到底部有额外的空间。这就是我在这个小提琴里所说的话。 http://jsfiddle.net/sEe7x/11/。奇怪的是在黄色和橙色的断点处发生。有谁知道造成这种情况的原因是什么?
这是我的代码
-- HTML --
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width" />
<title>Portraits</title>
<meta name="description" content="">
<link href='http://fonts.googleapis.com/css?family=Raleway:200' rel='stylesheet' type='text/css'>
</head>
<body class="photography">
<nav class="site_navigation cf">
<ul id="nav_drop" class="nav_links cf">
<li class="nav_home"><a href="#">Home</a></li>
<li class="nav_blog"><a href="#">Blog</a></li>
<li class="nav_photography"><a href="#">Photography</a></li>
<li class="nav_projects"><a href="#">Projects</a></li>
<li class="nav_contact"><a href="#">Contact</a></li>
</ul>
</nav>
<div class="main photography_wrapper">
<h1>Portraits</h2>
<div class="gallery_wrapper">
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
</div>
<p>Random collection of portraits.</p>
<div class="more_galleries">
<h2>More Galleries</h2>
<div class="more_gallery_photos">
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a>
<a href="#"><img src="http://placedog.com/400/400" alt=""></a> </div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://dev.danielcgold.com/js/selectnav.min.js"></script>
<script src="http://dev.danielcgold.com/js/functions.js"></script>
</body>
</html>
-- CSS --
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.cf:before,.cf:after {
content: "";
display: table;
}
.cf:after {
clear: both;
}
.cf {
*zoom: 1;
}
img {
max-width: 100%;
}
body {
font-family: Arial, sans-serif;
font-size: 100%;
background: #fffff6;
margin: 0;
padding: 2em;
padding-top: 6.375em;
color: #252525;
}
h1,h2,h3,h4,h5,h6 {
font-family: serif;
font-weight: normal;
margin-bottom: 1em;
}
h1 {
font-size: 3em;
}
p {
line-height: 1.5em;
word-wrap: break-word;
}
strong {
font-family: 'pt_sans_captionbold', sans-serif;
font-weight: normal;
}
a {
color: #ff830a;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.selectnav {
display: none;
}
.site_navigation {
font-family: 'Raleway', sans-serif;
font-weight: 200;
background: #fff;
padding: 1em;
border-bottom: 0.063em solid rgba(0,0,0,0.15);
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 4.375em;
-moz-box-shadow: rgba(0,0,0,0.15) 0 0 0.4em;
-webkit-box-shadow: rgba(0,0,0,0.15) 0 0 0.4em;
-o-box-shadow: rgba(0,0,0,0.15) 0 0 0.4em;
box-shadow: rgba(0,0,0,0.15) 0 0 0.4em;
}
.site_navigation a {
text-decoration: none;
color: #444;
display: block;
margin: .5em;
padding-bottom: .25em;
}
.nav_links {
list-style: none;
margin: 0;
padding: 0;
float: right;
}
.nav_links li {
float: left;
}
.gallery_wrapper {
-moz-column-count: 5;
-webkit-column-count: 5;
-o-column-count: 5;
column-count: 5;
line-height: 0;
}
.more_galleries {
margin-top: 6em;
}
.more_gallery_photos {
-moz-column-count: 5;
-webkit-column-count: 5;
-o-column-count: 5;
column-count: 5;
}
.more_gallery_photos a {
display: block;
margin-bottom: 1em;
}
.gallery_wrapper a {
display: block;
margin-bottom: 1em;
}
.gallery_wrapper img {
display: block;
height: auto;
}
@media screen and (max-width: 60em) {
.gallery_wrapper {
-moz-column-count: 4;
-webkit-column-count: 4;
-o-column-count: 4;
column-count: 4;
}
.more_gallery_photos {
-moz-column-count: 4;
-webkit-column-count: 4;
-o-column-count: 4;
column-count: 4;
}
.gallery_wrapper a {
margin-bottom: 1em;
}
.more_gallery_photos a {
display: block;
margin-bottom: 1em;
}
}
@media screen and (max-width: 48em) {
.nav_links {
float: left;
}
.gallery_wrapper {
-moz-column-count: 3;
-webkit-column-count: 3;
-o-column-count: 3;
column-count: 3;
}
.more_gallery_photos {
-moz-column-count: 3;
-webkit-column-count: 3;
-o-column-count: 3;
column-count: 3;
}
.gallery_wrapper a {
margin-bottom: 1em;
}
.more_gallery_photos a {
display: block;
margin-bottom: 1em;
}
}
@media screen and (max-width: 30em) {
.site_navigation {
height: 3.5em;
}
.nav_links {
display: none;
}
.selectnav {
display: block;
margin-left: 1.5em;
}
.gallery_wrapper {
-moz-column-count: 1;
-webkit-column-count: 1;
-o-column-count: 1;
column-count: 1;
}
.more_gallery_photos {
-moz-column-count: 2;
-webkit-column-count: 2;
-o-column-count: 2;
column-count: 2;
}
.more_gallery_photos a {
display: block;
margin-bottom: 1em;
}
}
编辑:第一个小提琴解决了。我更新了一个JS小提琴,我的真实代码被剥离并重新创建了问题。我使用SASS,因此CSS是输出。
答案 0 :(得分:8)
答案 1 :(得分:3)
答案 2 :(得分:0)
这对我有帮助
将其添加到列数块:
:after {
content: '';
display: block;
width: 100%;
height: 20px;
margin-top: -20px;
}