CSS列底部的多余空间 [英] Extra space at the bottom of CSS columns

查看:98
本文介绍了CSS列底部的多余空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个装有图像的容器.我使用CSS列和媒体查询来确定布局.我在底部放置了一个段落标签,并注意到它的底部有多余的空间.这就是我在这个小提琴中所说的. http://jsfiddle.net/sEe7x/11/.奇怪的是发生在黄色和橙色的断裂点.有谁知道是什么原因造成的?

I have a container that has images inside. I use CSS columns and media queries to determine my layout. I put a paragraph tag at the bottom and noticed extra space at the bottom of it. Here's what i'm talking about in this fiddle. http://jsfiddle.net/sEe7x/11/. The weirdness is happening at the yellow and orange break points. Does anyone know what is causing this?

这是我的代码

-- 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是输出.

The first fiddle was solved. I updated a JS fiddle with my real code stripped down and recreated the issue. I use SASS so the CSS is the output.

推荐答案

这是因为图像<img />标签呈现为inline-block.

It is because of image <img /> tag rendered as inline-block.

img {display: block;}

这篇关于CSS列底部的多余空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆