<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.container{
width: 1000px;
margin: 10px auto;
border: 1px solid red;
}
h3.title {
color: #F2AE11;
font-size: 1.3em;
margin-bottom: 3em;
text-align: center;
font-weight: 500;
line-height: 1.1;
}
h3.title span {
display: block; /*设置为块级元素会独占一行形成上下居中的效果*/
font-size: 3em;
color: #212121;
position: relative; /*定位横线(当横线的父元素)*/
}
h3.title span:before, h3.title span:after {
content: ''; /*CSS伪类用法*/
position: absolute; /*定位背景横线的位置*/
top: 52%;
background: #494949; /*宽和高做出来的背景横线*/
width: 9%;
height: 2px;
}
h3.title span:before{
left: 25%; /*调整背景横线的左右距离*/
}
h3.title span:after {
right: 25%;
}
</style>
</head>
<body>
<div class="container">
<h3 class="title">Welcome to <span>Snapshot</span></h3>
<div class="row">
<img src="data:images/hz01.jpg" width="300" height="200">
</div>
</div>
</body>
</html>

总结:

1,这种方法比利用边框和背景图做出的效果更好更利于控制和修改

2,缺点是伪类在IE8上兼容有些问题

最新文章

  1. Git:Git初体验——Git安装配置
  2. ViewPager +Fragment 滑动游标
  3. mysql 语法总结
  4. 入门训练 A+B问题
  5. android学习笔记16——对话框
  6. jquery获取kindEditor值
  7. Web API 依赖注入与扩展
  8. NSArray 数组操作
  9. Win7下安装Mysql方法
  10. Mencached使用
  11. HTML重要标签及属性详解
  12. JQuery实用技巧--学会你也是大神(1)——插件的制作技巧
  13. HOW to Use QP_PREQ_PUB.PRICE_REQUEST API to Price an Item
  14. 如何在ASP.NET Core中使用Azure Service Bus Queue
  15. [Kubernetes]谈谈Kubernetes的本质
  16. Service Fabric基本概念: Node, Application, Service, Partition/Replicas
  17. pwcrack--一款集合多种md5解密的工具
  18. Docker—微软微服务
  19. 五、springboot(二)配置数据源oracle
  20. java web开发遇到的常见问题解决办法(汇总贴)

热门文章

  1. 15.python文件(file)方法详解
  2. cra
  3. 安全师(网络安全类pdf电子书籍)
  4. C# Winform初体验
  5. lucas定理 模板
  6. CSS语法、选择器、继承、层叠
  7. opencv —— normalize 矩阵归一化
  8. NFS部署
  9. jenkins用户权限配置 Role-based Authorization Strategy
  10. php外挂python脚本抓取ajax数据