CSS 怎么移动文字? 下面本篇文章给大家介绍一下方法. 有一定的参考价值, 有需要的朋友可以参考一下, 希望对大家有所帮助.
首先可以用个容器来包住文字, 给宽和高.
然后, 可以使用多种方法来移动文字:
1, 如果是在块元素容器中, 可以用 text-align:center,left,right 来移动文字的位置.
2, 可以用 float
3, 可以 padding
4, 使用 position 定位
先在父级元素设置 position:relative; 再在你需要移动的容器里设置 position:absolute;top,left,right,bottom 这些方向该多少 px 就多少 px
例如:
- body{
- width:900px;
- height:600px;
- position:relative;
- }
- div(这里是你要移动的容器){
- width:200px;
- height:123px;
- position:absolute;
- top:10px;
- left:5px;
- }
5, 如果是在行内元素容器中, 可以用 text-indent:15px;(这个是文段缩进. 在文段前面缩进可以两个可以用到)
更多 web 前端开发 https://www.html.cn/ 知识, 请查阅 HTML 中文网 !!
来源: http://www.css88.com/qa/css3/17454.html