2011-07-24 23 views
1

我有一個容器,我擁有持有我的h5文本的#info。如何在容器內的任何位置放置文本,而不會在分辨率不同時弄亂頁面。謝謝。CSS文本定位

<style media="screen" type="text/css"> 

    body { 
    background-color:#C0C0C0; 
    } 

    #container { 
    background-image:url('pic.png'); 
    background-repeat: no-repeat; 
    height: 541px; 
    width:1020px; 
    margin: auto; 
    } 

    #info { 
    height:500px; 
    width:700px; 
    } 

    a:link { 
    text-decoration: none; 
    color:#000000; 
    } 
    a:hover { 
    background-color:#efefef; 
    } 

    h5 { 
    color:black; 
    font-size:0.9em; 
    } 

    </style> 
+2

你說的「不搞亂的頁面上」是什麼意思?如果可能的話舉一個你想要達到的目標的例子,即使這是一個可以幫助民衆試圖幫助的圖像,想象你想要做什麼。 –

+0

好的。因此分辨率爲1440x900,並更改爲1024x768,文本移動並位於容器的不同部分。我如何得到它「堅持」? – fealiux

回答

5

添加position: relative#containerh5。然後您可以將標題移動到lefttop(或rightbottom)。

#container { 
    position: relative; 
} 


h5 { 
    position: relative; 
    left: 10px; 
    top: 5px; 
} 

這裏是一個演示:http://jsfiddle.net/alp82/4b9xK/