简体   繁体   English

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

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

Please, is anyone able to help? 拜托,有人能帮忙吗? I need to align my RH image-navigation to always be at the bottom of a browser window, no matter how the window is resized. 无论窗口如何调整大小,我都需要将RH图像导航调整为始终位于浏览器窗口的底部。

I have created a fluid layout of a parent .container (max-width 800px) with 3 divs inside: 我创建了一个父容器的流畅布局(最大宽度800px),其中包含3个div:
- Topmast at the top -顶部的Topmast
- Two side-by-side column divs (66:33) underneath the topmast -顶部下方有两个并排的列div(66:33)

  • LH: mainbody is the left aligned column, LH:主体是左对齐的列,
  • RH: navigation is right aligned column – that I need to bottom align RH:导航栏右对齐-我需要底部对齐

And then finally a Footer div (outside the main container, spanning the full browser width). 最后是页脚div(在主容器之外,跨越整个浏览器宽度)。

My trouble is that the navigation elements (4 rollover images stacked on top of each other) never align to the bottom of the browser, but stay to the top of the div. 我的麻烦是导航元素(4个翻转图像彼此堆叠)永远不会与浏览器底部对齐,而会停留在div顶部。

I have tried the following CSS all to no avail: 我尝试了以下CSS都无济于事:
vertical-align:0 bottom:0 padding-bottom:0 margin-bottom:0 垂直对齐:0底部:0填充底部:0边缘底部:0
I would prefer a CSS solution, that also does not require a fixed height to be specified for the divs. 我更喜欢CSS解决方案,该解决方案也不需要为div指定固定高度。 Please can anyone help? 有人可以帮忙吗? I have been scouring for weeks for a solution :( 我一直在寻找解决方案数周:(

As I am a newbie, I am unable to post an image here of what I have, so I will try draw it below. 由于我是新手,因此无法在此处发布自己拥有的图像,因此我将尝试在下面绘制它。 But here is also a link to a screengrab of my website currently with the code below: 但是,这也是当前网站的屏幕截图的链接,其中包含以下代码:

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

Drawing it out, what I have is: 得出来,我所拥有的是:

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

What I need is: 我需要的是:

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

Here is my CSS: 这是我的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;
}

Here is my html for the two columns: 这是我的两栏的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>

Please can anyone help? 有人可以帮忙吗? I am not sure how to use JsFiddle either to post a demo.. Still a bit new to web design.. Thank you so much in advance. 我不确定如何使用JsFiddle来发布演示。.网页设计还是有点新的。.提前非常感谢。

You can use something like display: inline-block; 您可以使用诸如display: inline-block;东西display: inline-block; on your elements to position them beside each other, and this will also support the vertical-align: bottom; 在您的元素上以将它们彼此并排放置,这也将支持vertical-align: bottom; property that I see you were trying to use. 我看到您正在尝试使用的财产。

Take a look as this jsFiddle demonstrating this. 看看这个jsFiddle演示了这一点。

Notice that I have removed a lot of the styles you were using, most importantly the float properties. 请注意,我已经删除了许多您正在使用的样式,最重要的是float属性。

Also notice that I rearranged the order of your html so that the navigation section no longer comes before the main body, as the floating of the elements is no longer rearranging them. 还要注意,我重新排列了html的顺序,以使导航部分不再位于主体之前,因为元素的浮动不再重新排列它们。

Then, I placed display: inline-block; 然后,我放置了display: inline-block; on both sections, and vertically aligned the navigation section to the bottom. 在两个部分上,并将导航部分垂直对齐到底部。

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

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