HTML Output
<div id="block_1"> ... </div> <div id="block_2"> ... </div> <div id="block_3"> ... </div>
CSS Rules
#block_1
{
float: left;
width: 34%;
margin-left: 33%;
}
* html #block_1
{
display: inline;
}
#block_2
{
float: left;
width: 33%;
margin-left: -67%;
}
#block_3
{
float: left;
width: 33%;
}
#footer
{
clear: both;
}
* html body
{
margin: 0;
padding: 0;
}
* html #footer
{
position: relative;
}
带wrapper:
HTML Output
<div id="wrapper"> <div id="block_1"> ... </div> <div id="block_2"> ... </div> <div id="block_3"> ... </div> </div>
CSS Rules
body
{
direction: rtl;
}
#block_1
{
float: right;
width: 34%;
margin-right: 33%;
}
* html #block_1
{
display: inline;
}
#block_2
{
float: right;
width: 33%;
margin-right: -67%;
}
#block_3
{
float: right;
width: 33%;
}
/* we need this for IE 5.01 - otherwise the wrapper does not expand to the
necessary height (unless fixed, this problem becomes even more acute
weirdness as the method is enhanced */
#wrapper
{
/* Normally a Holly-style hack height: 1% would suffice but that causes
IE 5.01 to completely collapse the wrapper - instead we float it */
float: left;
/* NB. possibly only IE 5.01 needs to get this float value - otherwise 5.5 sometimes
(I saw it happen many moons ago) makes the width of wrapper too small
the float: none with the comment is ignored by 5.01,
5.5 and above see it and carry on about their business
It's probably fine to just remove it, but it's left here
just in case that many moons ago problem rears its head again */
float/**/: none;
}
/* easy clearing */
#wrapper:after
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#wrapper
{
display: inline-block;
}
/*\*/
#wrapper
{
display: block;
}
/* end easy clearing */
#footer
{
clear: both;
}
本文详细介绍了HTML页面布局中使用div元素和CSS样式进行布局的方法,包括块级元素的浮动、清除以及针对不同浏览器的兼容性处理。同时,阐述了如何通过CSS实现响应式设计,使网页在不同设备上呈现最佳视觉效果。
4614

被折叠的 条评论
为什么被折叠?



