css 固定文字位置

html-css08

css 固定文字位置,第1张

css让文字放在固定的位置:

1、通过position的绝对定位,然后在通过left和top就可以设置你的图片位置了;

代码如下:

<div style='position:absolut left:0px top:0px'>

<p>我是固定位置的测试文字</p>

</div>

2、通过div+css的布局来实现给定一个包裹图片的div默认位置就行;

代码如下:

<div>

<div style='flaot:left width:330px height:200px'>

<p>我是左边的固定测试文字</p>

</div>

<div style='flaot:left width:330px height:200px'>

<<p>我是右边的固定测试文字</p> </div>

</div>

控制字体位置可以用padding

margin

text-indent

单位可以是px

em

%

(em是根据你设置的字体大小设定的,假如你设置字体为12px,那么2em就是24px。

%是根据父容器的宽度或高度决定的。

margin-left:automargin-right:auto(左右自动对齐)。position:absolute(绝对定位)