CSS如何实现底线重合效果_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:07:33
Original
1531 people have browsed it

CSS如何实现底线重合效果:

有时候要实现这样的效果,就是标题下面的下划线颜色和容器的下划线的颜色是不同的,下面就分享一段代码实例。

代码如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.51texiao.cn/" /><title>蚂蚁部落</title><style type="text/css">*{  padding:0;  margin:0;}.line{  border-bottom:2px solid #EBEBEB;  margin-top:10px;  margin-bottom:10px;}h2{  border-bottom:2px solid skyblue;  font-size:14px;  line-height:20px;  display:inline-block;  *display:inline;  *zoom:1;  margin-bottom:-2px;}</style></head><body><div class="line">  <h2>蚂蚁部落一</h2></div><div class="line">  <h2>今天是个好日子</h2></div><div class="line">  <h2>只有奋斗才会有美好的结果</h2></div><div class="line">  <h2>每一天都是美好的,必须要好好的珍惜</h2></div></body></html>
Copy after login

以上代码实现了我们想要的效果,主要的实现原理,是将h元素的margin-bottom设置为-2px,这样h的边框就和div的边框重合的了。

原文地址是:http://www.51texiao.cn/div_cssjiaocheng/2015/0525/2445.html

最为原始地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=9623


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template