我有一個html文檔和一個css文件。下面是該代碼段我工作的樣子:左右內容框css
<div class="contentcenter">
<div class="contentleft">
<h1>Left</h1>
<p>Pellentesque habitant morbi ...</p>
</div>
<div class="contentright">
<h1>Right</h1>
<p>Pellentesque habitant morbi ...</p>
</div>
</div>
我有一張照片是1000像素,這些元素上面寬心,我想左側的元素添加到頁面,使得它的中心對齊從圖片的最左邊緣開始向中間開始,然後顯示一個間隙,然後顯示正確的元素,併到達圖片的最右邊緣。例如
|--------------Picture--------------------------|
| |
| |
| |
| |
| |
| |
| |
| |
|-----------------------------------------------|
|--left--------------| |-------right---------|
| | | |
| | | |
| | | |
| | | |
|--------------------| |---------------------|
所有這一切,都將以頁面爲中心。這是我的CSS,但它沒有給我我期待的結果。
.contentcenter
{
margin:0 auto;
padding:0;
width=1000px;
border:3px solid red;
}
.contentleft,
.contentright
{
position:inherit;
float:left;
margin: 50px auto;
width:auto;
max-width:450px;
border:3px solid #00CD00;
padding:0;
font-family:Arial, Times, serif;
}
.contentleft h1,
.contentright h1
{
margin:0;
padding:0;
color:white;
font-family:Arial;
display:block;
background-color:#00CD00;
padding: 5px 0;
}