2011-07-24 24 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/