利用after和before实现的一些效果

摘要:
通过使用after和before(备用)1整理在线获得的一些效果。达到如图所示的效果:。索引通知{height:45px;line-height:45px,margin-top:5px;border-bottom:1pxsolid#e5e5e5;position:relative}。索引通知span{font-size:14px;font-weight:bold;mar

整理网上利用after和before实现的一些效果(以备用)

1.实现如图所示效果:利用after和before实现的一些效果第1张

.index-notice{height: 45px;line-height: 45px;margin-top: 5px;border-bottom: 1px solid #e5e5e5;position: relative}
.index-notice span{font-size: 14px; font-weight: bold;margin-left: 10px;padding-left: 10px;}
.index-notice span:before{content: "";width: 6px;height: 15px;background-color: #cc0e0e;position: absolute;top:35%;left:8px;}

<div class="index-notice">
    <span>通知公告:</span>
</div>

2.实现ul li 形式的标题栏  用竖线分隔效果利用after和before实现的一些效果第2张

nav {height:47px; text-align:center;width: 1100px; background:red;margin:0 auto;margin-top: 2px; }
nav ul { width:1100px; margin:0 auto; }
nav li {width:110px;  height:41px; line-height:41px;text-align:center; float:left;position: relative}
nav li:after{content:"";width: 1px; height: 40%;background-color: #fff;position:absolute;top: 13px;}
nav .last:after { content: "";width: 0px;}



<nav>
    <ul id="nav">
       <li><a href="http://t.zoukankan.com/wyynts-p-6606013.html#" target="_blank">首页</a</li>
       <li><a href="http://t.zoukankan.com/wyynts-p-6606013.html#" target="_blank"></a></li>
       <li><a href="http://t.zoukankan.com/wyynts-p-6606013.html#" target="_blank"></a></li>
       <li><a href="http://t.zoukankan.com/wyynts-p-6606013.html#" target="_blank"></a></li>
    </ul>
</nav>

3.实现空心三角形的效果利用after和before实现的一些效果第3张

.index-notice{height: 45px;line-height: 45px;margin-top: 5px;border-bottom: 1px solid #e5e5e5;position: relative}
.index-notice:before{content: "";position: absolute;top: 100%;right: 18px;width: 0;height: 0px;border-left: 15px solid transparent;border-top:15px solid #e5e5e5;border-right:15px solid transparent;}
.index-notice:after{content: "";position: absolute;top: 100%;right: 19px;width: 0;height: 0px;border-left: 14px solid transparent;border-top:14px solid #fff;border-right:14px solid transparent;}


<div class="index-notice ">
    <span>新闻速递:</span>
</div>

注:将来遇到别的效果会更新,其中有些效果未考虑各个浏览器兼容性

免责声明:文章转载自《利用after和before实现的一些效果》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Ubuntutar命令Java 处理word文档后在前端展示下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

css实现左(右)侧固定宽度,右(左)侧宽度自适应 ---清除浮动

老话长谈,css的不固定适应布局   不管是面试还是在平时的工作中,这样的布局形式一直都在用着,很常见,所以今天我就拿出来在唠叨一下, 既是给自己一个备忘存储,也是一个学习巩固的参考,知道大家都会,还是要记忆一下,不为其他,就为打好基础。 话说太多, 直接上代码,一看就能明白。 也许你会不屑一顾的说简单,可是我就喜欢写一些。。。。。。作为一个菜鸟,就要从基...

使用swiper.js实现移动端tab切换

在项目中遇到的,要实现tab切换,我用的是swiper.js 官网:http://www.swiper.com.cn/api/start/new.html 1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta charset="UTF-...

安卓手机微信页面position: fixed位置错误

今天做项目的时候发现动用position: fixed做弹窗时,用margin-top:50%这样外边距来响应式的控制位置时,在微信里打开页面的弹窗,弹窗在手机上显示的位置和实际上在手机上的位置不一样,让人点击上面时并没有反应,其实他实际位置时在眼睛看到的位置上方许多,点击上方许多的位置时,才触发眼睛看到的地方的元素被点击的事件,这是为毛啊?UC浏览器都是...

巧用伪元素绘制带边的三角形--CSS3

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> <meta name="description"content=""> <meta name="author"...

百度地图、ECharts整合HT for Web网络拓扑图应用

直击现场 百度地图、ECharts整合HT for Web网络拓扑图应用发表于3周前(2015-03-23 01:32) 阅读(1320)|评论(5)78人收藏此文章,我要收藏 赞8 慕课网,程序员升职加薪神器,点击免费学习 摘要前一篇谈及到了ECharts整合HT for Web的网络拓扑图应用,后来在ECharts的Demo中看到了有关空气质...

第一百八十节,jQuery-UI,知问前端--消息提示 UI

jQuery-UI,知问前端--消息提示 UI 学习要点:   1.HTML 部分   2.CSS 部分   3.jQuery 部分 通过前面已学的 jQuery UI 部件,我们来创建一个注册表单。 html <div id="reg" title="会员注册"> <p> <label fo...