简体   繁体   English

浮动 div 旁边的底部对齐 div

[英]bottom align div next to floated divs

I am trying to get the following effect using css. I am trying to get bottom edges of title and 'right text' to align with logo's bottom edge, and get the title to stretch
vertically. I have included html and css

____________________________________________________________________________________________
          |________________________________________________________TOP_TEXT_________________
          |                                                                    |
   LOGO   |                             title                                  |  right text
          |____________________________________________________________________|
__________|______Menu__________________________________________________________|____________


<div id="wrapper">

    <div id="logo"><img src="some.gif" width="193" height="77" /> </div> 
    <div id="top_text">top text</div> 

    <div id="right_text"> right text </div> 

    <div id="middle">

    <div id="title">title</div> 
    <div id="menu">menu</div> 

    </div>  <!-- middle -->

</div> <!-- wrapper -->



#wrapper {
 width: 100%;
}

#logo { 
    float: left;
    border-right:#FFFFFF thin solid;
}

#top_text { 

    text-align: right;
    width: auto;
}


#right_text  { 
    float: right;
    border-left:#FFFFFF thin solid; 
}


#middle{
/* may be needs some sort of height */
}

#title {
/* not sure how to put here */
}
#menu { 
/* doesn't line up with bottom edge of logo and 'right' */
    vertical-align:bottom;
}

In your case I guess vertical align would not be helping you.在你的情况下,我猜垂直对齐不会帮助你。 Rather you need to align your HTML more semantically so that you could use Position:relative,top and left or Margin-top/Margin right handy to align it.相反,您需要更语义地对齐 HTML 以便您可以使用 Position:relative,top and left 或 Margin-top/Margin right 方便地对齐它。

Following Pseudo code Steps might be useful for you to align it.遵循伪代码步骤可能对您对齐它很有用。

Step 1: Try Defining logo in a container or float it alone left第 1 步:尝试在容器中定义徽标或将其单独浮动

Step 2: Trying defining a section comprising of three different sections top text,title and menu and float the outer parent section as well left.第 2 步:尝试定义一个包含三个不同部分的部分,顶部文本、标题和菜单,并将外部父部分也向左浮动。

Step 3: Try defining a right section and float it right第 3 步:尝试定义一个正确的部分并使其向右浮动

Step4: Position all the elements using Position:relative,top and left or Margin-top/Margin right Step4: Position 所有元素使用 Position:relative,top and left or Margin-top/Margin right

The above steps would be helping you to get a picture perfect layout rather fiddling around with Vertical-align.上述步骤将帮助您获得完美的图片布局,而不是摆弄垂直对齐。

If you need further help on vertical-align here如果您在此处需要有关垂直对齐的进一步帮助

http://www.w3schools.com/cssref/pr_pos_vertical-align.asp http://www.w3schools.com/cssref/pr_pos_vertical-align.asp

Hope this answer helps.希望这个答案有帮助。

Good luck.. happy coding.祝你好运..快乐编码。

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

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