<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
height: 200px;
background: yellow;
}
/* before after伪类 必须有content属性才能起作用,值字符串
* 相当于子标签,行内元素 */
.box:after{
content: 'hello world';
background-image: url(arrow.png);
background-size: 100% 100%;
display: block;
width: 100px;
height: 100px;
border: 1px solid darkred;
} </style>
</head>
<body> <div class="box">
打开发动机阿斯蒂芬静安寺多路阀三阶段
<p>打开发动机阿斯蒂芬静安寺多路阀三阶段</p>
<p>打开发动机阿斯蒂芬静安寺多路阀三阶段</p>
<p>打开发动机阿斯蒂芬静安寺多路阀三阶段</p>
<p>打开发动机阿斯蒂芬静安寺多路阀三阶段</p>
<p>打开发动机阿斯蒂芬静安寺多路阀三阶段</p>
</div> </body>
</html>

2

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
height: 200px;
background: yellow;
/*border-bottom: 1px solid #000;*/
position: relative;
} /* 通过伪类将逻辑1像素在高清屏下,实现物理1像素 */
.box:after{
content: '';
display: block;
height: 1px;
width: 100%;
border-bottom: 1px solid #000;
position: absolute;
left: 0;
bottom: -1px;
transform: scaleY(0.5);
}
.box:before{
content: '';
height: 1px;
width: 100%;
border-top: 1px solid #000;
position: absolute;
left: 0;
top: -1px;
transform: scaleY(0.5);
} </style>
</head>
<body> <div class="box"> </div> </body>
</html>

3

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
height: 200px;
background: yellow;
/*border-bottom: 1px solid #000;*/
position: relative;
} /* 通过伪类将逻辑1像素在高清屏下,实现物理1像素 */ /*.box:before{
content: '';
height: 100%;
width: 1px;
border-left: 1px solid #000;
position: absolute;
left: -1px;
top: 0;
transform: scaleX(0.5);
}*/ .box:before{
content: '';
height: 100%;
width: 1px;
border-right: 1px solid #000;
position: absolute;
right: -1px;
top: 0;
transform: scaleX(0.5);
} </style>
</head>
<body> <div class="box"> </div> </body>
</html>

4

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
height: 200px;
background: yellow;
/*border-bottom: 1px solid #000;*/
position: relative;
} /* 通过伪类将逻辑1像素在高清屏下,实现物理1像素 */
.box:after{
content: '';
display: block;
height: 1px;
width: 100%;
border-bottom: 1px solid #000;
position: absolute;
left: 0;
bottom: -1px;
transform: scaleY(0.5);
}
.box:before{
content: '';
height: 1px;
width: 100%;
border-top: 1px solid #000;
position: absolute;
left: 0;
top: -1px;
transform: scaleY(0.5);
}
.box .left{
height: 100%;
width: 1px;
border-left: 1px solid #000;
position: absolute;
left: -1px;
top: 0;
transform: scaleX(0.5);
}
.box .right{
height: 100%;
width: 1px;
border-right: 1px solid #000;
position: absolute;
right: -1px;
top: 0;
transform: scaleX(0.5);
}
</style>
</head>
<body> <div class="box">
<span class="left"></span>
<span class="right"></span>
</div> </body>
</html>

伪类元素before&after的更多相关文章

  1. 玩转CSS3,嗨翻WEB前端,CSS3伪类元素详解/深入浅出[原创][5+3时代]

    在我的上一篇博客中, 很多园友提出说对css3"画图"不是很理解, 在跟他们私聊了一段时间以后,加上自己在开始自学css3的时候的疑惑,我觉得大家之所以不是很理解主要是因为对伪元素 ...

  2. 关于伪类元素:before和:after

    关于伪类元素:before和:after   CSS中存在一些比较特殊的属性,称之为伪类,它们之中最常用的就是定义链接的伪 :link:未被访问状态 :visited:已被访问状态 :hover:鼠标 ...

  3. 用一个例子学习CSS的伪类元素

    CSS伪类元素是一个非常酷的东西!首先我们理解一下它,:before :after 伪类元素,也就是虚假的元素.它可以插入在元素的前面或者后面,而在HTML文档结构中,它却是不存在的,因为Js是无法通 ...

  4. button不能添加伪类元素

    今日试了一下button添加伪类元素,结果是不行的前后都叠加在一起 html代码: <button class="form_btn" formType="submi ...

  5. css伪类元素:after 的多功能用法——任意大小的底边框

    需求用法出现的背景: 由于项目UI的优化,项目中所有tab导航选中的状态都是统一样式书写的,之前都是用的border-bottom,新的需求如果用以前的本办法就是定位一个选中边框在底部,但是涉及的模板 ...

  6. CSS样式学习-3、轮廓、伪类/元素、display-flex布局

    一.轮廓 outline绘制于元素周围的一条线,位于边框边缘外围. 属性规定元素轮廓的样式.颜色.宽度. outline-width轮廓宽度,属性:thin细轮廓.medium中等(默认值).thic ...

  7. 如何利用伪类元素和vertical-align: middle;实现元素相对于父元素居中

    HTML部分 <div class="zhihu"> <div class="loginMain"> </div> < ...

  8. 微信小程序 CSS border-radius元素 overflow:hidden失效问题 iPhone ios 苹果兼容问题 伪类元素

    同事找我解决一个问题 说安卓圆角没问题 苹果上失效了 我一看 其实就是没做兼容上图给你们看看 有没有看出来 其实就是父级设置圆角属性失效 父元素使用border-radius和overflow:hid ...

  9. js修改伪类元素样式

    <style type="text/css"> .htmlbox_close::before, .htmlbox_close::after { content: ''; ...

随机推荐

  1. 换了SSD发现plank也好了

    我的Dock用的是plank,很简单很好用.为什么不用Docky还有其他什么玩意儿呢?plank很简单很好用,资源占用很少,可以智能隐藏,you nearly can't feel it but yo ...

  2. dubbo-源码阅读之服务发布

    原理 dubbo根据spring 2.0的schma实现 解析xml并初始化相关bean 初始化dubbo:service为ServiceBean实例  通过spring的生命周期相应回调实现服务发布 ...

  3. handsontable 随记

    handsontable 怎么样获取合并之后的cell信息,如下 handsontable .getPlugin('mergeCells').mergedCellsCollection 看了他的源代码 ...

  4. Qt 【QTableView + DIY delegate】

    通过继承QStyledItemDelegate类去实现自定义委托,达到这样的效果,因为本身Qlistview是单列多行有些信号处理的不好,所以使用QTableview多行多列去实现: 图片路径设置在r ...

  5. pip install RISE报错解决

    ERROR: Cannot uninstall 'tornado' ERROR: Cannot uninstall 'tornado'. It is a distutils installed pro ...

  6. Android中对应用程序的行为拦截实现方式概要

    这次是真的好长时间都没有写博客了,主要不是因为工作上的事,主要还是这个问题真的有点复杂,实现起来有点麻烦,所以研究了很长时间(大约有一个月的时间).但是幸好最后问题搞定了~~ 一.问题场景 想实现36 ...

  7. C#网页数据采集(三)HttpWebRequest

    <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...

  8. Java习题10.24

    Java习题10.24 1. 1,3.connect()与accept():这两个系统调用用于完成一个完整相关的建立,其中connect()用于建立连接.accept()用于使服务器等待来自某客户进程 ...

  9. unittest框架学习笔记三之testsuite

    # coding=utf-8 '''created :2018/3/29 author:star project: testsuite'''import unittest,time,osfrom ba ...

  10. input checkbox 禁止选中/修改

    input checkbox 禁止选中 <input type="checkbox"  onclick="return false;" /> inp ...