文字居中贯穿线

前述:

  类似于京东的这种文字居中于贯穿线

代码展示:

    

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{margin:0px;padding:0px;}
			.wrap{width:1000px;margin:200px auto;}
			.grid{width:1000px;border-bottom:1px dashed #000;height:20px;position: relative;}
			.grid h3{width:100px;line-height:40px;font-size:20px;text-align: center;background: #fff;position: absolute;top:0px;left:500px;}
		</style>
	</head>
	<body>
		<div class="wrap">
			<div class="grid">
				<h3>享品质</h3>
			</div>
		</div>
		
	</body>
</html>

 效果展示:

知识点总结:

  1.单行文字垂直居中:height=line-height,text-align:center(盒子内的文字或者图片水平居中);

  2.利用 线的height=文字line-height/2,来实现文字居中贯穿线;

扩展:

  line-height:150%与line-height:1.5的区别

        1、当line-height:XX%时:
                body{font-size:14px;line-height:150%;}
                p{font-size:26px;}
           结果就是:
                body{line-height:21px;}//14*150%=21
                p{line-heigt:21px;}//继承父元素字体
       2、当line-height:X.X时:
               body{font-size:14px;line-height:1.5;}
               p{font-size:26px;}
           结果就是:
               body{line-height:21px;}//14*1.5=21
               p{line-height:39px;}//26*1.5=39 继承父元素line-height

 

posted @ 2017-04-24 17:33  杨新权  阅读(359)  评论(0编辑  收藏  举报