css伪元素:before和:after

**css伪元素:before和:after这个两个伪元素在真正页面元素内部之前和之后添加新内容伪元素:
before和:after添加的内容默认是inline元素;

这个两个伪元素的content属性,表示伪元素的内容,

设置:before和:after时必须设置其content属性,否则伪元素就不起作用**

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

#one{
    margin-left:40%;
    margin-top: 100px;
    width: 350px;
    height: 250px;
    background: url("img/76edddd3461d644438df4daa5e3ae78.png");
    background-size: 100% 100%;
}
#one::before{
    display: inline-block;/*默认是inline级 不能设置宽高,要变成inline-block才能设置宽高*/
    content: '';
    width: 100%;
    height: 100%;
    background-color: grey;
    opacity: 0.5;
    display: none;
   
}
#one:hover::before {
    display:inline-block;
}
#two{
    width: 350px;
    height: 250px;
    background:pink;
    opacity: 1;

}
#two::after{
    display: inline-block;
    content: '我是美女';
    border: 2px solid black;
    width: 50px;
    height: 50px;
    opacity: 1;
}
#three{
    position: relative;
width: 100px;
height: 30px;
border: 1px solid black
}
#three::before{
    content: '';
    position: absolute;
    top: 7px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-bottom: 1px solid black;
    border-left: 1px solid black;
    transform: rotate(315deg);
}
</style></head><body><div id="one">

</div> 
<div id="two">

</div> 
<div id="three">

</div> </body>

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

万事胜意sy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值