伪类元素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: ''; ...
随机推荐
- .net EntityFramework dbContext 如何实例化
1 .DbContext怎么在Asp.mvc中使如何实例化 public class Repository { //实例化EF容器:有弊端.一个线程里可能会创建多个DbContext //DbCont ...
- 数据结构:堆(Heap)
堆就是用数组实现的二叉树,所有它没有使用父指针或者子指针.堆根据"堆属性"来排序,"堆属性"决定了树中节点的位置. 堆的常用方法: 构建优先队列 支持堆排序 快 ...
- LinkedBlockingQueue 学习
LinkedBlockingQueue 链表队列,其元素构成为: static class Node<E> { E item; Node<E> next; Node(E x) ...
- MHA + proxysql 高可用以及读写分离
环境 vip 192.168.1.101 slave 192.168.1.16 5.7.17 3306 master 192.168.1.135 5.7.17 3306 proxysql 192.16 ...
- 头文件 <sys/un.h>
struct sockaddr_un server_sockaddr ; struct sockaddr_un cli_sockaddr ;
- HTTP/2的优先级
前言 记得HTTP/3即将标准化了.今日早读文章由@smallbonelu翻译授权分享. @smallbonelu,一枚爱好跑步的前端工程师 正文从这开始-- 以正确的顺序请求页面资源对于快速的用户体 ...
- Jmeter-【JSON Extractor】-响应结果中数组多个相同key取值
一.请求返回样式 二.取所有option的值 三.查看结果
- DOM学习总结(四)DOM修改
DOOM修改 找到标签之后就可以对它进行修改了可以修改:1.改变HTML元素 比如说把 p 改为 span2.改变HTML属性 比如说 id class3.改变CSS样式 比如说改变字体颜色4.添加或 ...
- Linux初上手!
虚拟机Virtual Box装的Kali Linux,是Debian的发行版本,安装过程不说了,不是硬盘安装也没什么说的,由于是新手所以只有两个分区,一个[/]和一个[swap] 装好之后是xwind ...
- php 如何实现 数据库 连接池
php 如何实现 数据库 连接池 一.总结 一句话总结: php+sqlrelay+mysql实现连接池及读写负载均衡 master-slave模式增加并发. sqlrelay 解决连接池问题以及实现 ...