【问题标题】:How to add space two divs?如何添加空间两个div?
【发布时间】:2015-12-18 22:17:29
【问题描述】:

在最后两张卡片和底部的图像之间,我需要更多空间,但是随着我减小浏览器窗口的大小,空间必须增加。我该怎么做呢? 第一张图片全屏显示浏览器。 第二张图片显示了一个较小的浏览器窗口(只是小了一点)


这是我的html代码:

 <section>
 <!--....Some other things....-->

<div class="container" id ="last-row-cards">
            <div class="row">
                <div class="col-md-6 margin">
                  <div class="speaker">
                        <div class="card-image">
                            <a href="#" type="button" class="btn">
                                <img src="" alt="user-image" />
                            </a>
                        </div>

                        <div class="card-modal"></div>

                        <div class="card-info">

                            <div class="name">
                                <p style="font-size: 28px;font-weight: 100;font-family: 'Raleway';" class="name">Nunc Lorem Interdum</p>
                            </div>

                            <div class="social-network">
                                <a href="#" class="icon youtube">
                                    <i class="fa fa-linkedin"></i>
                                </a>
                                <a href="#" class="icon twitter">
                                    <i class="fa fa-twitter"></i>
                                </a>
                                <a href="#" class="icon facebook">
                                    <i class="fa fa-facebook"></i>
                                </a>
                            </div>

                            <hr>

                            <div class="content" style="font-family: raleway;">
                                <p style="font-size: 20px;
        font-weight: 100;
        font-family: 'Raleway';">
                                    <b>About:</b> Praesent faucibus sem tortor, sed imperdiet enim interdum in. Etiam feugiat rutrum ex, quis maximus quam commodo eu. Pellentesque eget tortor convallis, vestibulum tortor in, lacinia diam.
                                </p>
                                <p style="font-size: 20px;
        font-weight: 100;
        font-family: 'Raleway';"><b>Website:</b> <a href="http://something.io/" style="color:grey">www.something.io</a>
                                </p>
                            </div>
                        </div>
                    </div>

              </div>

                <div class="col-md-6 margin">
                  <div class = "speaker2">
                        <div class="card-image">
                            <a href="#" type="button" class="btn">
                                <img src="" alt="user-image" />
                            </a>
                        </div>

                        <div class="card-modal"></div>

                        <div class="card-info">

                            <div class="name">
                                <p style="font-size: 28px;font-weight: 100;font-family: 'Raleway';" class="name">Nunc Lorem Interdum</p>
                            </div>

                            <div class="social-network">
                                <a href="#" class="icon youtube">
                                    <i class="fa fa-linkedin"></i>
                                </a>
                                <a href="#" class="icon twitter">
                                    <i class="fa fa-twitter"></i>
                                </a>
                                <a href="#" class="icon facebook">
                                    <i class="fa fa-facebook"></i>
                                </a>
                            </div>

                            <hr>

                            <div class="content" style="font-family: raleway;">
                                <p style="font-size: 20px;
        font-weight: 100;
        font-family: 'Raleway';">
                                    <b>About:</b> Praesent faucibus sem tortor, sed imperdiet enim interdum in. Etiam feugiat rutrum ex, quis maximus quam commodo eu. Pellentesque eget tortor convallis, vestibulum tortor in, lacinia diam.
                                </p>
                                <p style="font-size: 20px;
        font-weight: 100;
        font-family: 'Raleway';"><b>Website:</b> <a href="http://something.io/" style="color:grey">www.something.io</a>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
              </div>
        </div>
     </section>
     <section class="create">
    <div class="innov8">
        <h4>Create</h4>
    </div>
</section>

我的 CSS 代码

.create {
background-image: url('http://www.davidduke.com/images/Mad-Scientists.jpg');
background-repeat: no-repeat;
background-size: cover;
position: relative;
margin-top: 50% !important;
margin-bottom:0;
}

/* General */
.row {
box-sizing: border-box;
outline: none;
width: 100%;
}
/* Card */
.card {
background-image: url('');
background-size: 100%;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-       stop(0%, #ffffff), color-stop(100%, #ecf0f1));
background-image: -moz-linear-gradient(top, #ffffff 0%, #ecf0f1 100%);
background-image: -webkit-linear-gradient(top, #ffffff 0%, #ecf0f1  100%);
background-image: linear-gradient(to bottom, #ffffff 0%, #ecf0f1 100%);
-moz-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
display: block;
position: absolute;
padding: 20px;
}

.card-modal {
-moz-transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
-o-transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
-webkit-transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
background-color: #bdc3c7;
color: white;
display: none;
position: absolute;
top: 40px;
left: 130px;
z-index: 2;
padding: 20px;
}

#last-row-cards{
 /*I'M NOT SURE WHAT TO PUT HERE*/
}

谢谢。

【问题讨论】:

    标签: html css image responsive-design


    【解决方案1】:

    如果您的第一部分不是 position:relative 你可以删除你的 postiion:relative on .create class .. 所以它可以下降.. 但是如果你在你的部分中使用你的一个元素的浮动,你需要清除它,这样它才能正确地制作一个块.. 例如:

    <div class="first">
    </div>
    <div class="second">
    </div>
    <div class="clear"></div>
    css
    .first {
    float: left;
    }
    .second {
    float: right;
    }
    .clear{
    clear: both;
    }
    
    • bootstrap col-md, col-sm, col-lg use float .. 所以你必须在最后清除它..

    【讨论】:

    • 我添加了更多的 CSS 代码。你能检查一下吗?没有任何效果。
    • 好的,现在我的代码可以正常工作了,但我仍然手动操作。在那个宽度上它不会重叠,但是当我把它变小时它又开始重叠了。
    • 如何使用 vh 设置宽度 .. 像 width: 50vh .. vh 自动调整大小取决于基于高度的屏幕大小.. 您可以使用 vw 作为基于屏幕的大小在宽度上..