简体   繁体   English

水平和垂直对齐DIV-CSS

[英]Align DIVs horizontal and vertically - CSS

I have the following set up for my webpage: 我的网页设置如下:

HTML: HTML:

<div id="headercontent">
    <div id="topnav"></div>
    <div id="dailycalendar"></div>
    <div id="headerimage"></div>
</div>

CSS: CSS:

#headercontent { width: 990px; height: 162px; position: relative; margin: 0 0 0 0; vertical-align: top; padding: 0px; }
#topnav { float: left; width: 720px; height: 50px; }
#dailycalendar { float: left; width: 720px; height: 112px; }
#headerimage { float: right; width: 270px; }

I want the div tags within the following order using CSS and cross browser capability: 我想使用CSS和跨浏览器功能按以下顺序处理div标签:

----------------- ----------------
-    topnav     - -              -
----------------- -  headerimage -
----------------- -              -
- dailycalendar - -              -
----------------- ----------------

I managed it by changing the order of the divs, and setting a height on headerimage: 我通过更改div的顺序并在headerimage上设置高度来管理它:

<div id="headercontent">
    <div id="headerimage"></div>
    <div id="topnav"></div>
    <div id="dailycalendar"></div>
</div>

#headerimage { float: right; width: 270px; height:100%; background-color:green }

http://jsfiddle.net/pyXer/ http://jsfiddle.net/pyXer/

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

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