2012-12-18 64 views
0

我最後一個問題不是很清楚,我會再試一次。'Stick'image to the right side of the page

在我的Tumblr博客(http://anti-standard.tumblr.com)上,您可以看到一張貼在頁面左側的圖片(圖片顯示爲「ANTI STANDARD」)。不過,我希望圖片被卡在頁面的右側。我怎樣才能做到這一點?我有以下的CSS代碼:

.image-container1 { 
    width:100%; 
    position:absolute; 
    float:right; 
    right:0; 
    clear:both; 
} 

.image-container2 { 
    background:url('http://avare.nl/tumblr/as.png') no-repeat fixed; 
    background-size:55px 500px; 
    height:500px; 
    width:55px; 
} 

和下面的HTML代碼,右邊的「體」標籤下面:

<div class="image-container1"> 
    <div class="image-container2"> 
    </div>  
</div> 

我希望你們能幫助我在這一個。

回答

1

添加float:right.image-container2和刪除固定從背景

.image-container2 { 
    background:url('http://avare.nl/tumblr/as.png') no-repeat; 
    background-size:55px 500px; 
    height:500px; 
    width:55px; float:right; 
}​ 

DEMO

還是以簡單的方式做這樣的

HTML

<div class="image-container1">lorem ...</div> 

CSS

html, body{height:100%} 
.image-container1 { 
    width:100%; 
    background:url('http://avare.nl/tumblr/as.png') no-repeat right top; 
    background-size:55px 500px; 
    height:100% 
} 

DEMO

+0

太謝謝你了!這工作完美。 :) – Steef

相關問題