简体   繁体   English

我如何让一个div围绕另一个div?

[英]How do I have a div go around another div?

I have 3 boxes on my site that i would like to clear. 我的网站上有3个框需要清除。 Here is the website the boxes on the bottom are what I would like to have clear. 这是网站,底部的方框是我想要清除的。 If anyone has any ideas i would love to hear them. 如果有人有任何想法,我很想听听他们的想法。

Thanks for your help! 谢谢你的帮助!

EXAMPLE | 范例 | http://www.sevwebdesign.com http://www.sevwebdesign.com

How I want it to look: www.sevwebdesign.com/graphics/site_layout.jpg 我希望它看起来如何:www.sevwebdesign.com/graphics/site_layout.jpg

HTML HTML

 <div id="left-info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            <br><br><br><br><br><br>
            </p>
          </div>
    </div>
    <div id="mid-info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            <br><br><br><br><br>
            </p>
          </div>
    </div>

    <div id="right-info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            </p>
          </div>
    </div>

CSS CSS

.info-bar-title{
    color:#fff;
    text-align:center;
    font-family: 'Carrois Gothic', sans-serif;
    font-size:25px;
    margin-top:0px;
    margin-bottom:0px;
}
#left-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin-left:100px;
    float:left;
}
#mid-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin:0px auto;
    align-content:center;

}
#right-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin-right:100px;
    float:right; clear:left;
}
.info-inter {
    color:#000;
    background-color:rgba(255,255,255,1.00);
    border-radius:8px;
    padding:3px;
}
.info-words {
    text-align:center;
}

I checked the website you posted and i see the last info box was not aligned properly, maybe the clear you mean is to align those box properly. 我检查了您发布的网站,发现最后一个信息框未正确对齐,也许您的意思是明确地将这些框正确对齐。

I created a fiddle but I might misunderstood your question but check this out. 我制造了一个小提琴,但我可能会误解您的问题,但请检查一下。

Fiddle 小提琴

I changed some of the mark ups. 我更改了一些标记。 just edit it later. 稍后再编辑。

HTML HTML

<div class="info-wrapper">
    <div class="info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            <br/><br/><br/><br/><br/>
            </p>
          </div>
    </div>
    <div class="info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **</p>
                <br/><br/><br/><br/><br/>

          </div>
    </div>

    <div class="info">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            </p>
          </div>
    </div>
</div>

CSS CSS

.info-wrapper{
    width:1100px;
}
.info-bar-title{
    color:#fff;
    text-align:center;
    font-family: 'Carrois Gothic', sans-serif;
    font-size:25px;
    margin-top:0px;
    margin-bottom:0px;
}
.info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    float:left;
    margin-right:50px;
}
.info-inter {
    color:#000;
    background-color:rgba(255,255,255,1.00);
    border-radius:8px;
    padding:3px;
}
.info-words {
    text-align:center;
}

For starters wrap these three boxes in a div ID such as a footer: We also will use the same stylings for each box so we will rename the footer-box and use CLASSES instead as there is more than 1 on the page. 对于初学者而言,将这三个框包装在div ID中,例如页脚:我们还将为每个框使用相同的样式,因此我们将重命名页脚框并使用CLASSES,因为页面上有1个以上。

<div id="footer">
<div class="footer-box">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            <br><br><br><br><br><br>
            </p>
          </div>
    </div>
    <div class="footer-box">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            <br><br><br><br><br>
            </p>
          </div>
    </div>

    <div class="footer-box">
        <h1 class="info-bar-title">Facebook Feed</h1>
            <div class="info-inter">
            <p class="info-words">** FACEBOOK FEED **
            </p>
          </div>
    </div>
</div>

Now you want to style your footer to be centered on the page. 现在,您要设置页脚的样式以使其位于页面的中心。

#footer{
 width:960px;
 margin:auto;
 padding:0px; //Dont want any extra or inherent padding
}

This is based on your other elements being a width of 960. 这是基于您的其他元素的宽度为960。

In the footer div then we will align our boxes. 然后在页脚div中对齐框。

.footer-box {
background-color: #629B5D;
border: solid 5px #629B5D;
border-radius: 8px;
width: 300px;
margin-left: 20px;
float: left;
}

You then see they all float left ontop of eachother and they are all the same width etc. The layers are cleaner. 然后,您会看到它们全部漂浮在彼此的顶部上,并且它们的宽度均相同,以此类推。这些层更加清洁。

I tried your code in JSFIDDLE. 我在JSFIDDLE中尝试了您的代码。

Check this code: (JSFIDDLE Resource: http://jsfiddle.net/qZaEZ/ ) 检查以下代码:(JSFIDDLE资源: http//jsfiddle.net/qZaEZ/

#left-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin-left:100px;
    float:left;
}
#mid-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin-left: 50px;
    float:left;

}
#right-info{
    background-color:#629B5D;
    border:solid 5px #629B5D;
    border-radius:8px;
    width:300px;
    margin-right:100px;
    float:right;
}

Is this what you mean by clearing the boxes? 这是清除框的意思吗? Aligning them at the bottom? 将它们对准底部? Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM