开发者

CSS Text positioning

开发者 https://www.devze.com 2023-03-22 19:01 出处:网络
I have a container and I have #info holding my h5 text. How can I position the text anywhere i want within the container without messing the page up when the resolution is different. Thanks.

I have a container and I have #info holding my h5 text. How can I position the text anywhere i want within the container without messing the page up when the resolution is different. Thanks.

    <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开发者_StackOverflow中文版:hover {
    background-color:#efefef;
    } 

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

   </style>


Add position: relative to #container and to h5. Then you can move the headline with left and top (or right and bottom).

#container {
    position: relative;
}


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

Here is a demonstration: http://jsfiddle.net/alp82/4b9xK/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号