Heim  >  Artikel  >  Web-Frontend  >  左侧固定宽度,右侧自适应宽度的CSS布局_经验交流

左侧固定宽度,右侧自适应宽度的CSS布局_经验交流

WBOY
WBOYOriginal
2016-05-16 12:04:421195Durchsuche

BI上有高手专门讨论了这种布局方法,但他用了较多的hack,还回避了IE6的dtd。我在实际使用中,发现回避掉IE6的dtd定义后,会导致ajax模态框无法居中(VS的一个控件,自动生成的代码,很难修改)。 于是自己写了个简单的左右两列的布局,没用到什么hack,很简单,只是练手用用。

css代码:left和right都贴住左侧。设置left在right上面(z-index);在right内加个放内容的层(content);设置content距离right的左侧为200px,即刚巧等于left的宽度。

复制代码 代码如下:

* {margin:0; padding:0; list-style:none; }
.wrapper {width: 100%; }
.left {width:200px;background:#fcc; position:absolute; left:0 ;z-index:1 }
.right {width:100%;background:#ccc; position:absolute;left:0}
.content {margin-left:200px;background:#ffc; }

完整代码

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn