【问题标题】:CSS Text positioningCSS 文本定位
【发布时间】:2011-10-12 02:45:49
【问题描述】:

我有一个容器,我有 #info 保存我的 h5 文本。当分辨率不同时,如何将文本放置在容器内我想要的任何位置而不会弄乱页面。谢谢。

    <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>

【问题讨论】:

  • “不搞乱页面”是什么意思?如果可能,请举例说明您正在尝试实现的目标,即使那是一张图片,它也会帮助人们尝试提供帮助,想象您正在尝试做的事情。
  • 好的。因此分辨率为 1440x900 并更改为 1024x768,文本移动并位于容器的不同部分。如何让它“粘”起来?

标签: css text alignment


【解决方案1】:

position: relative 添加到#containerh5。然后你可以用lefttop(或rightbottom)移动标题。

#container {
    position: relative;
}


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

这是一个演示:http://jsfiddle.net/alp82/4b9xK/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多