css怎么控制字体的位置?

html-css054

css怎么控制字体的位置?,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:。

<div style="position: relativewidth: 300pxheight: 80pxborder: 1px solid blue">

<strong style="position: absoluteright: 0top: 0">获取更多</strong>

</div>

3、浏览器运行index.html页面,此时“获取更多”的链接文字移动到条形栏的中间位置了。

控制字体位置可以用padding margin text-indent 单位可以是px em % (em是根据你设置的字体大小设定的,假如你设置字体为12px,那么2em就是24px。 %是根据父容器的宽度或高度决定的。

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