CSS如何自定义文字位置?

html-css013

CSS如何自定义文字位置?,第1张

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

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

需要准备的材料分别有:电脑、浏览器、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页面,此时“获取更多”的链接文字移动到条形栏的中间位置了。

用CSS样式表在网页中设置图片位置,首先,一般都是将图片包裹到一个div中,然后在设定一个父级元素,一般都是直接选择浏览器,看具体要求来,在使用position的定位来做,如position:absoulteleft:10pxtop:10px意思就是距左边10个px,距离上边10px这里通过代码来理解下:

<html>

<head>

<style>

#div1{//通过id实现

width:300px

height:30px

position:absolute

left:100px //这是假定的值,具体需要测量

top:100px

}

</head>

<body>

<div id='div1' class='div1'>

<img src='图片地址'>

</div>

</body>

</html>