简体   繁体   English

将Divs堆叠在顶部,将另一个Divs堆叠到一边

[英]Stack Divs on top Each Other with Another Div to the Side

I am wanting to have several divs stack on top of each other (which I have), but also have another div to the right side of the other group of divs. 我想彼此之间有几个div堆叠(我有),但另一个div的右侧还有另一个div。 Right now everything is just stacked on top of each other, even the BeliefDescription div, which needs to be to the right of the rest of them. 现在,所有内容都堆叠在一起,甚至BeliefDescription div也要堆叠在一起,而div则必须位于其他所有元素的右侧。 Thanks for helping. 感谢您的帮助。

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

<div id="Cat">
    <div id="God" class="BeliefCat">God</div>
    <div id="Jesus" class="BeliefCat">Jesus Christ</div>
    <div id="HolySpirit" class="BeliefCat">Holy Spirit</div>
    <div id="Bible" class="BeliefCat RemainingCat">The Bible</div>
    <div id="Man" class="BeliefCat RemainingCat">Man</div>
    <div id="GodsRelationship" class="BeliefCat RemainingCat">God's Relationship to His Creation</div>
    <div id="Salvation" class="BeliefCat RemainingCat">Salvation</div>
    <div id="SavedWho" class="BeliefCat RemainingCat">Who Can Be Saved?</div>
    <div id="Perseverance" class="BeliefCat RemainingCat">Perseverance</div>
    <div id="GospelOrd" class="BeliefCat RemainingCat">Gospel Ordinances</div>
    <div id="Resurrection" class="BeliefCat RemainingCat">Resurrection</div>
    <div id="ChurchGov" class="BeliefCat RemainingCat">Church Government</div>
    <div id="SecondComing" class="BeliefCat RemainingCat">Christ's Second Coming</div>
    <div id="Missions" class="BeliefCat RemainingCat">Missions</div>
</div>

 <div id="BeliefDescription">
    HELLO
</div>

.BeliefCat
{
    border: 1px solid black;
    width: 33%;
    height:25px;
    text-align:center;
    font-weight:bold;
}

#Cat
{
    margin-top:20px;
} 

#BeliefDescription
{
    float:left;
}

If you want to let #cat and #BeliefeDescription side by side you have to float both of them and not only #BeliefDescription . 如果你想让#cat#BeliefeDescription并排你有浮动两个人身上,不仅#BeliefDescription

Adding float:left to #Cat will solve you problem, but then you'll have to set an width to it. #Cat添加float:left可以解决您的问题,但随后您必须为其设置宽度。

Be aware that the float property makes the element float over the element that comes after it. 请注意, float属性使元素浮动在其后的元素上方。 So, either place the #BeliefDescript before the Cat div, and set it to be float:right 因此,请将#BeliefDescript放置在Cat div之前,并将其设置为float:right

http://jsfiddle.net/1tLfaryk/1/ http://jsfiddle.net/1tLfaryk/1/

Or set the float property on the Cat element, and make it float:left; 或在Cat元素上设置float属性,并将其设置为float:left;

http://jsfiddle.net/1tLfaryk/2/ http://jsfiddle.net/1tLfaryk/2/

Try this: http://jsfiddle.net/9rcs4v1c/3/ 试试这个: http : //jsfiddle.net/9rcs4v1c/3/

.BeliefCat
{
    border: 1px solid black;
    width: 100%;
    height:25px;
    text-align:center;
    font-weight:bold;
}

#Cat
{
    float: left;

} 

#BeliefDescription
{
    float:left;
}

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

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