<!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. 【牛客网-剑指offer】变态跳台阶

    题目: 一只青蛙一次可以跳上1级台阶,也可以跳上2级--它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 考点: 递归和循环 分析: 台阶数 跳法 1 1 2 2 3 4 4 8 5 1 ...

  2. spring基于注解的事务控制

    pom配置: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http ...

  3. ElasticSearch中分词器组件配置详解

    首先要明确一点,ElasticSearch是基于Lucene的,它的很多基础性组件,都是由Apache Lucene提供的,而es则提供了更高层次的封装以及分布式方面的增强与扩展. 所以要想熟练的掌握 ...

  4. 安装APK到android设备那些事儿

    APK是AndroidPackage的缩写,即Android系统的应用软件安装包(apk).APK是类似Symbian Sis或Sisx的文件格式.通过将APK文件直接传到Android模拟器或And ...

  5. transformer模型计算图

    参考了这篇文章:http://nlp.seas.harvard.edu/2018/04/03/attention.html 结合代码和图,能更加清楚的了解transformer中的一些原理(ps,等下 ...

  6. react 脚手架使用

    下载脚手架 npm i react create-react-app //下载安装脚手架 create-react-app pro_nmae //创建一个react项目 尽量不要使用大写,因为在Lin ...

  7. Java虚拟机(一)

    一.Java发展历程 Java之父,James Gosling博士 时间 事件 1991年4月 James Gosling博士领导的Green Project启动,java语言前身Oak启动 1995 ...

  8. list 链表

    #include <list> #include <iostream> using std::list; /* 双向环状链表 //每一个结点 一个数据域 一个前驱指针 一个后驱 ...

  9. python培训拾遗

    20140421 1. 三大利器: dir----列出所有内部方法 a=1 dir(a) 可以列出所有内部方法,就是带两个下划线的:带一个下划线的是普通方法 help---查看帮助 help(a.bi ...

  10. ORM-Dapper:Dapper列表

    ylbtech-ORM-Dapper:Dapper列表 1.返回顶部 1.1. https://dapper-tutorial.net/ 1.2. 2.1. https://www.nuget.org ...