CSS 设置背景色指定高度
作者:
我是七月 | 来源:发表于
2024-05-28 10:19 被阅读0次CSS 设置背景色指定高度,我们通过 ::before 或者 ::after伪类来实现。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>css 设置指定高度背景色</title>
<style type="text/css">
p {
display: inline-block;
position: relative;
}
p::before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
background: rgba(255, 187, 68, 0.2);
}
</style>
</head>
<body>
<p>我的背景颜色指定高度50%</p>
</body>
</html>
本文标题:CSS 设置背景色指定高度
本文链接:https://www.haomeiwen.com/subject/susafjtx.html
网友评论