码迷,mamicode.com
首页 > 其他好文 > 详细

图标在横线的中间!

时间:2018-01-15 00:26:50      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:log   目的   常用   hit   http   sla   relative   图片   ima   

最终的效果:

技术分享图片

1 <div class="line-icon">
2     <p></p>
3     <span>标题</span>
4 </div>
 1 <style>
 2     .line-icon{
 3         position: relative;
 4         height:50px;
 5         width:100%;
 6         border:1px solid black;
 7     }
 8     .line-icon p,.line-icon span{
 9         position:absolute;
10         top:50%;
11         left:50%;
12         transform: translate(-50%,-50%);
13         background:red;
14     }
15     .line-icon p{
16         top:10px;
17         height:1px;
18         width:50%;
19         z-index:-1;
20     }
21     .line-icon span{
22         height:30px;
23         width:50px;
24         line-height:30px;
25         text-align:center;
26         z-index: 1;
27         background: white;
28     }
29 </style>

这种效果常用于文档的的标题和分类上。日常写项目的时候也很常用。

图标在横线的中间!

标签:log   目的   常用   hit   http   sla   relative   图片   ima   

原文地址:https://www.cnblogs.com/wuli-youhouli/p/8284518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!