繁体   English   中英

流体布局中的右对齐div元素底部对齐

[英]Bottom-align right div elements in fluid-layout

拜托,有人能帮忙吗? 无论窗口如何调整大小,我都需要将RH图像导航调整为始终位于浏览器窗口的底部。

我创建了一个父容器的流畅布局(最大宽度800px),其中包含3个div:
-顶部的Topmast
-顶部下方有两个并排的列div(66:33)

  • LH:主体是左对齐的列,
  • RH:导航栏右对齐-我需要底部对齐

最后是页脚div(在主容器之外,跨越整个浏览器宽度)。

我的麻烦是导航元素(4个翻转图像彼此堆叠)永远不会与浏览器底部对齐,而会停留在div顶部。

我尝试了以下CSS都无济于事:
垂直对齐:0底部:0填充底部:0边缘底部:0
我更喜欢CSS解决方案,该解决方案也不需要为div指定固定高度。 有人可以帮忙吗? 我一直在寻找解决方案数周:(

由于我是新手,因此无法在此处发布自己拥有的图像,因此我将尝试在下面绘制它。 但是,这也是当前网站的屏幕截图的链接,其中包含以下代码:

http://hooboo.co.uk/Screengrab.jpg

得出来,我所拥有的是:

    -----800px container span-------------------------
    +----topmast-------------------------------------+
    +----2/3 width------------+ +----1/3 width-------+
    | mainbody                | |  navigation (4-row)|
    | that                    | |  that is short     | 
    | is                      | +--------------------+
    | tall                    |    
    |                         |
    +-------------------------+
    --------------------------------------------------
+--------footer 100% browser width-----------------------+

我需要的是:

    -----800px container span-------------------------
    +----topmast-------------------------------------+
    +----2/3 width------------+ 
    | mainbody                | 
    | that                    |  
    | is                      | +----1/3 width-------+
    | tall                    | |  navigation (4-row)|   
    |                         | |  that is short     |
    +-------------------------+ +--------------------+
    --------------------------------------------------
+--------footer 100% browser width-----------------------+

这是我的CSS:

.container {
width: 84%;
height: 100%;
max-width: 800px;
padding-left: 3%;
padding-right: 3%;
padding-top: 6%;
padding-bottom: 0%;
margin-bottom: 0%;
margin-left: auto;
margin-right: auto;
margin-top: auto; 
}

#topmast{ 
clear: both;
margin-left: 0;
margin-top: 25%;
height: auto;
width: 100%;
min-width: 240px;
min-height: auto;
display:block;
}


#navigation{ 
clear: right;
float:right;
width:33.125%;
height:600px; 
height:auto; 
max-width:265px;
vertical-align:bottom;
bottom: 0;
margin-bottom: 0;
padding-bottom: 0;
position:relative;
display:block;
}

#mainbody { 
clear: left;
margin-right:33.125%;
margin-top: 0%;
width: 65%;
display:block;
}

#footer { 
clear:both;
background-color:#333;
height:100px;
}

这是我的两栏的html:

<div id="navigation" align="right" style="vertical-align:bottom">  

<a href="mailto:email@url.com" target="_blank"   
onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Email','','00_assets/buttons/00_BUTTONS_EMAILO.png',1)">
<img src="00_assets/buttons/00_BUTTONS_EMAIL.png" alt="Email: email@url.com" 
width="100%" height="auto" id="Email" border="0" style="float: right;"/>
</a>

<a href="tel:+1234567890" target="_blank" 
onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Call','','00_assets/buttons/00_BUTTONS_CALLO.png',1)">
<img src="00_assets/buttons/00_BUTTONS_CALL.png" alt="Call: +1234567890" 
width="100%" height="auto" id="Call" border="0" style="float: right;"/>
</a>

<a href="https://url.com/screenname" target="_blank" 
onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Twitter','','00_assets/buttons/00_BUTTONS_TWEETO.png',1)">
<img src="00_assets/buttons/00_BUTTONS_TWEET.png" alt="Tweet us" 
width="100%" height="auto" id="Twitter" border=0 style="float: right;"/>
</a>

</div>

<div id="mainbody" align="left"> 
<h1>Welcome to website</h1>
<p class="Body"> Mainbody copy about website services goes here.</p>
</div>

有人可以帮忙吗? 我不确定如何使用JsFiddle来发布演示。.网页设计还是有点新的。.提前非常感谢。

您可以使用诸如display: inline-block;东西display: inline-block; 在您的元素上以将它们彼此并排放置,这也将支持vertical-align: bottom; 我看到您正在尝试使用的财产。

看看这个jsFiddle演示了这一点。

请注意,我已经删除了许多您正在使用的样式,最重要的是float属性。

还要注意,我重新排列了html的顺序,以使导航部分不再位于主体之前,因为元素的浮动不再重新排列它们。

然后,我放置了display: inline-block; 在两个部分上,并将导航部分垂直对齐到底部。

暂无
暂无

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

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