【发布时间】:2013-12-28 13:58:58
【问题描述】:
我正在开发一个简单的 css 主题,我使用左中右布局,我使用 float 来定位左右元素,margin 用于中心。
但是如果我看一下这个网站,所有的网站部分都在相互渗透。
这是我现在所拥有的:
HTML
<div class="container">
<div class="right">
<div class="block">
<div class="title">My Block Of Data Here Is Title</div>
This is my block of data! Here i can show website stats and announcements.
</div>
</div>
<div class="left">
<div class="block">
<div class="title">My Block Of Data Here Is Title</div>
This is my block of data! Here i can show website stats and announcements.
</div>
</div>
<div class="center">
<div class="block">
<div class="title">Welcome to SITE_TITLE_HERE!</div>
This is where we post so many stuff!<br><br><br><br><br><br><br><br><br><br>Thanks, SITE_TITLE_HERE stuff.
</div>
</div>
</div>
CSS
body{
font-family: 'Open Sans Condensed', sans-serif;
font-size: 18px;
}
.container{
margin: 0 auto;
width: 65%;
}
.left{
float: left;
width: 20%;
}
.right{
float: right;
width: 20%;
}
.center{
margin: 0 auto;
width: 60%;
}
.block{
width: 100%;
padding: 3px;
background: #fafafa;
outline: 1px solid #f2f2f2;
outline-offset: 2px;
text-align: center;
}
.block .title{
font-size: 24px;
border-bottom: 1px solid #000;
background: #76E0EE;
}
小提琴: http://jsfiddle.net/XK6dN/2/
更新:我几乎可以肯定它是块类的outline,但即使是这样。我怎样才能防止它们相互覆盖?
【问题讨论】:
-
把你的代码放在这里,在问题中,但保留到 Fiddle 的链接。
-
@RobertHarvey + 同样,jsFiddle 链接仍然非常有用。
-
@RobertHarvey 谢谢,刚刚更新了帖子。