简体   繁体   English

我有两个垂直 div,但第二个 div 的可变高度导致第一个 div 自身定位错误

[英]I have two vertical divs, but the second div's variable height is causing the first one to misposition itself

http://denartcc.org/images/help.jpg http://denartcc.org/images/help.jpg

As you can see from the arrows in my attached picture, I'm trying to slide those four divs (Who's Online, Upcoming Events, Statistics, and Weather) UP to fill the void.正如您从我所附图片中的箭头看到的那样,我正在尝试向上滑动这四个 div(谁在线、即将发生的事件、统计数据和天气)以填补空白。 The column on the right has a variable height, and when it expands, those four aforementioned divs continue to move down the page.右侧的列具有可变高度,当它展开时,上述四个 div 会继续向下移动页面。 They need to stay underneath the white box.他们需要留在白盒子下面。

The problem with absolute positioning is that the four divs (Who's Online, Upcoming Events, etc.) will also have variable heights, so I don't want to stick the second row of those in an absolute position.绝对定位的问题在于四个 div(Who's Online、Upcoming Events 等)也会有不同的高度,所以我不想将第二行放在绝对 position 中。

HTML HTML

<div id="TopContentWrapper">
    <div id="phototicker">
    <jdoc:include type="modules" name="phototicker" />
    </div>
    <div class="RightSide">
        <div class="rtsidemod">
            <div class="rtsidetitle">Control Panel</div>
            <div class="rtsidecontent"><jdoc:include type="modules" name="controlpanel" /></div>
        </div>
        <div class="rtsidemod">
            <div class="rtsidetitle">Newletter</div>
            <div class="rtsidecontent"><jdoc:include type="modules" name="newsletter" /></div>
        </div>
        <div class="rtsidemod">
            <div class="rtsidetitle">Event Notifications</div>
            <div class="rtsidecontent"><jdoc:include type="modules" name="eventnotifications" />Check Check</div>
        </div>
        <div class="rtsidead">
            <img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/forum.png"></img>
        </div>
        <div class="rtsidead">
            <img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/ts.png"></img>
        </div>
        <div class="rtsidead">
            <img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/ts.png"></img>
        </div>
    </div>
    <div class="midbox1">
        <div class="modbox">
            <div class="modtitle">Who's Online
            </div>
            <div class="mid1">
                <p class="mid"><jdoc:include type="modules" name="whosonline" /></p>
            </div>
        </div>
        <div class="modbox">
            <div class="modtitle">Upcoming Events
            </div>
            <div class="mid2">
                <p class="mid"><jdoc:include type="modules" name="upcomingevents" /></p>
            </div>
        </div>
    </div>
    <div class="midbox2">
        <div class="modbox">
            <div class="modtitle">Statistics
            </div>
            <div class="mid1">
                <p class="mid"><jdoc:include type="modules" name="statistics" /></p>
            </div>
        </div>
        <div class="modbox">
            <div class="modtitle">Weather
            </div>
            <div class="mid2">
                <p class="mid"><jdoc:include type="modules" name="weather" /></p>
            </div>
        </div>
    </div>
</div>

CSS CSS

#TopContentWrapper {
width:920px;
margin:0 auto;
position:relative;
}
div.RightSide {
width:255px;
float:left;
margin-left:5px;
}

div.rtsidemod {
float:left;
width:100%;
padding-bottom:5px;
background-image:url(../images/rightbg.png);
background-repeat:repeat-y repeat-x;
}

div.rtsidetitle{
font-weight:bold;
color:white;
font-size:12px;
background-image:url(../images/rttitlebg.png);
background-position:top left;
height:15px;
}

div.rtsidetitle:hover {
background-position:bottom left;
}

div.rtsidecontent {
font-size:11px;
color:white;
}

div.rtsidead {
width:255px;
float:left;
margin:5px 0 0 0px;
border:1px solid black;
}

div.modtitle {
width:322px;
height:15px;
font-size:12px;
color:white;
font-weight:bold;
background:url(../images/midmodbg.jpg);
background-repeat:repeat-x;
}

div.mid1 {
display:block;
float:left;
background-image:url(../images/midmodcontentbg.png);
background-repeat:repeat-both;
width:320px;
border:1px solid black;
border-top:none;
height:70px
}

div.mid2 {
display:block;
float:left;
background-image:url(../images/midmodcontentbg.png);
background-repeat:repeat-both;
width:320px;
border:1px solid black;
border-top:none;
height:70px
}

div.modbox {
float:left;
width:310px;
margin-right:19px;
margin-top:5px;
}

div.midbox1 {
float:left;
width:660px;
margin:0px 0 0px 5px;
padding:0;
}

div.midbox2 {
float:left;
width:700px;
margin:0px 0 0px 5px;
padding:0;
}

Rearrange your divs to be in 2 columns rather than 4 quadrants.将您的 div 重新排列为 2 列而不是 4 个象限。 You currently have:您目前拥有:

<div id="phototicker">
    ...
</div>
<div class="RightSide">
    ...
</div>
<div class="midbox1">
    ...
</div>
<div class="midbox2">
    ...
</div>

Instead, arrange them like this:相反,像这样安排它们:

<div class="LeftSide">
    <div id="phototicker">
        ...
    </div>
    <div class="midbox1">
        ...
    </div>
    <div class="midbox2">
        ...
    </div>
</div>
<div class="RightSide">
    ...
</div>

That way, the midboxes will naturally flow under the phototicker.这样,中间盒自然会在光敏标签下流动。 You will need to have a specific width on the right and left side divs and then just float the both left.您将需要在右侧和左侧 div 上具有特定的宽度,然后将两者都浮动到左侧。

暂无
暂无

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

相关问题 如何使两个垂直div彼此相邻,而正确的div则基于另一个的高度? - How to have two vertical divs one next to the other, with the right one overflowing basing on the the other's height? 我在一个组件中有 2 个 div,在第一个 div 中,我有导航 ul 列表,第二个 div 用于内容 - I have 2 divs in one component, in first div i have navigation ul list and second div is for content 将一个div放在两个垂直div旁边 - Put one div next to two vertical divs onmouseover两个div,一个可见的一个隐藏在悬停上,我想使第二个div可见,第一个div像开关一样隐藏 - onmouseover two divs one visable one hidden on hover I want to make the second div visible and the first hidden like a switch 第二内容div填充剩余高度,其中第一内容div具有可变高度 - Second content div fill remaining height where a first content div have variable height 我在一行中有3个div,如何在移动设备中使中间div排在第一位,第二个div排在第一位,第三个div排在最后? - I have 3 divs in one row, how do I get the middle div comes first and first div comes in second and third div comes last in mobile? 将头一个div位置在其他两个头下方-高度都可变 - position first div below other two - all have variable height 两个内联表单元格DIV引起其中之一的垂直移位 - Two inline table cell DIVs are causing vertical shift in one of them 如果一个具有固定高度而另一个具有包括零高度的可变高度,如何在两个div之间放置一条垂直线 - How to put a vertical line between two divs if one has a fixed height and the other a variable height including zero height 我在 Container/section div 中有 2 个 div,但是两个 div 之一被推出了容器 div,为什么? - I have 2 divs inside Container/section div but one of the two divs is being pushed out of the container div, why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM