伪类元素before&after
<!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的更多相关文章
- 玩转CSS3,嗨翻WEB前端,CSS3伪类元素详解/深入浅出[原创][5+3时代]
在我的上一篇博客中, 很多园友提出说对css3"画图"不是很理解, 在跟他们私聊了一段时间以后,加上自己在开始自学css3的时候的疑惑,我觉得大家之所以不是很理解主要是因为对伪元素 ...
- 关于伪类元素:before和:after
关于伪类元素:before和:after CSS中存在一些比较特殊的属性,称之为伪类,它们之中最常用的就是定义链接的伪 :link:未被访问状态 :visited:已被访问状态 :hover:鼠标 ...
- 用一个例子学习CSS的伪类元素
CSS伪类元素是一个非常酷的东西!首先我们理解一下它,:before :after 伪类元素,也就是虚假的元素.它可以插入在元素的前面或者后面,而在HTML文档结构中,它却是不存在的,因为Js是无法通 ...
- button不能添加伪类元素
今日试了一下button添加伪类元素,结果是不行的前后都叠加在一起 html代码: <button class="form_btn" formType="submi ...
- css伪类元素:after 的多功能用法——任意大小的底边框
需求用法出现的背景: 由于项目UI的优化,项目中所有tab导航选中的状态都是统一样式书写的,之前都是用的border-bottom,新的需求如果用以前的本办法就是定位一个选中边框在底部,但是涉及的模板 ...
- CSS样式学习-3、轮廓、伪类/元素、display-flex布局
一.轮廓 outline绘制于元素周围的一条线,位于边框边缘外围. 属性规定元素轮廓的样式.颜色.宽度. outline-width轮廓宽度,属性:thin细轮廓.medium中等(默认值).thic ...
- 如何利用伪类元素和vertical-align: middle;实现元素相对于父元素居中
HTML部分 <div class="zhihu"> <div class="loginMain"> </div> < ...
- 微信小程序 CSS border-radius元素 overflow:hidden失效问题 iPhone ios 苹果兼容问题 伪类元素
同事找我解决一个问题 说安卓圆角没问题 苹果上失效了 我一看 其实就是没做兼容上图给你们看看 有没有看出来 其实就是父级设置圆角属性失效 父元素使用border-radius和overflow:hid ...
- js修改伪类元素样式
<style type="text/css"> .htmlbox_close::before, .htmlbox_close::after { content: ''; ...
随机推荐
- Msf+Donut执行任意可执行文件
地址:donut:https://github.com/TheWover/donut 介绍:是一个shellcode生成工具,可以将.NET程序集等转换为shellcode. 使用:donut.exe ...
- ICPC2008哈尔滨-E-Gauss Elimination
题目描述 Li Zhixiang have already been in “Friendship” ocean-going freighter for three months. The excit ...
- Cesium导出PDF
首先安装 html2Canvas 和 jspdf npm i html2Canvas - S npm i jspdf - S 然后在vue页面引入 import html2Canvas from 'h ...
- QDomDocument::clear()的调用,会导致关闭程序时崩溃!!!
//读一份xml前,先清理m_Doc[QDomDocument] bool XmlIO::xmlRead(QString &errmsg) { m_mutex.lock(); // m_Doc ...
- React中Class的概念
Class的概念 一.简介 javaScript是面向对象的编程语言,可以说所以的能够被描述的事.物或抽象的东西,都是可以是对象.而我们记录的对象,会有具有同样的属性和行为. 为了节省重写相同的代码. ...
- 【基础】Linux软件安装方法
linux中wget .apt-get.yum rpm区别 wget 类似于迅雷,是一种下载工具, 通过HTTP.HTTPS.FTP三个最常见的TCP/IP协议下载,并可以使用HTTP代理 名字是Wo ...
- QT之sqlite连接
啥也没做,按说明直接啪啪写一堆代码 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); //open datebase ...
- xml配置离线约束的目的和ecplipse离线约束配置
正常情况下如果电脑已经联网的情况下,Spring的核心配置文件编写内容的时候是可以自动提示的,假设电脑如果离线情况下想要自动提示的话,就得配置离线约束文件. https://blog.csdn.net ...
- PHP学习(MVC架构与面向对象)
想好好的学一下php中的一些面向对象的知识,以前只是为了打CTF随意的学了一下,但是为了以后的代码审计(准备PHP这边把thinkphp这个框架好好的学一下). PHP面向对象的基本知识 类与对象 类 ...
- 搭建本地 8.8 W 乌云漏洞库
这个是关于两个图片马的帖子. https://zhuanlan.zhihu.com/p/27486144 这个是开源地址: https://github.com/m0l1ce/wooyunallbug ...