如果我没有理解你的问题正确,你还挺想有三列居中的包装,具有左,右列占用宽度200像素。如果是这样的话:
看到这个Fiddle Example
HTML:
<div class="content">
<aside class="column right">
<p>
text...
</p>
</aside>
<aside class="column left">
<p>
text...
</p>
</aside>
<div class="column center">
<img class="home_image" src="path_to_image.png" />
</div>
</div>
CSS:
/* the main wrapper */
.content {
position: absolute; top: 50%; left: 50%;
width: 800px; height: 500px;
margin-left: -401px; margin-top: -251px;
border: 1px solid #D9D9D9;
}
/* columns */
.column {
position: absolute; top: 0; bottom: 0;
width: 180px;
padding: 10px;
}
.column.left{
left: 0; background-color: #F2F2F2;
}
.column.right {
right: 0; background-color: #F2F2F2;
}
.column.center {
left: 200px; right: 200px;
text-align: center;
width: auto;
}
.column.center img {
border: 1px solid #111; border-radius: 22px;
width: 128px; height: 128px;
margin: 0 auto;
}
另外:我怎么能定义可重复使用的CSS-这些任务的类?
你可以看到,应用到.left
,.right
和.center
元素,从而在所有三个被重用的.column
类。
嗨,这真的很好。你也已经将可重用的东西包含在你的例子中!我只需要垂直对齐侧栏中的文本,但使用你的构造应该很容易。 – bodokaiser