2014-05-08 20 views
1

我試圖讓我的帖子自動分成兩列,一列固定,一個滾動。示例 -將帖子內容分成兩列,一列固定

enter image description here

類似this website

到目前爲止,我已經設法將帖子分成兩部分,儘管它的行爲並不像我想要的那樣。我沒有 -

的HTML

<td class="entry-content-left"> 
<div class="entry-image"> 
<td class="entry-content-right"> 
<?php the_content(); ?> 

的CSS

.entry-content-left { 
font-size: 18px; 
line-height: 26px; 
width: 531px; 
float: left; 
color: #444444; 
} 
.entry-content-right { 
font-size: 18px; 
line-height: 26px; 
width: 531px; 
float: right; 
color: #444444; 
} 
.entry-image { 
float: left; width: 75%; position: fixed; 

這裏是my website

+0

你是g希望看看CSS [固定定位](https://developer.mozilla.org/en-US/docs/Web/CSS/position#Fixed_positioning)。 – vvanasten

回答

1

您可以使用position:fixed;more info)執行此操作。我使用的div做出這種快速佈局,(你不應該使用表格這樣的內容),應該是所需的佈局:

FIDDLE

HTML:

<header></header> 
<div class="entry-content-left"> 
    <div class="entry-image"></div> 
    <div class="entry-content-right"></div> 
</div> 

CSS:

header{ 
    position:fixed; 
    width:100%; 
    top:0;left:0; 
    height:100px; 
    background:gold; 
} 
.entry-image{ 
    position:fixed; 
    top:100px;left:5%; 
    width:40%; 
} 
.entry-image img{ 
    width:100%; 
    height:auto; 
} 
.entry-content-right{ 
    width:45%; 
    margin-left:50%; 
    margin-top:120px; 
} 
+0

這有點類似於我原來的樣子,但它不起作用: -/ –

+0

@SocialMonster爲什麼它不起作用?我在答案中提供的代碼有效,也許你有一些破壞佈局的CSS衝突? –

+0

它只是沒有。沒有CSS與它衝突。看看:http://tinyurl.com/ocpz7a2 –