【CSS】css小三角定位
<div>文字<span class="triangle-down"></span></div>
.triangle-down { width: 0;
height: 0;
border-left: 0.4rem solid transparent;
border-right: 0.4rem solid transparent;
border-top: 0.6rem solid darkgray;
}
怎么把小三角的位置调整到文字后面
回答:
<html lang="en"><head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div:after {
content: "";
display: inline-block;
width: 0;
height: 0;
border-left: 0.4rem solid transparent;
border-right: 0.4rem solid transparent;
border-top: 0.6rem solid darkgray;
}
</style>
</head>
<body>
<div>文字</div>
</body>
</html>
回答:
用伪元素:after
<div>文字</div>div:after {
content: "";
display: inline-block;
width: 0;
height: 0;
border-left: 0.4rem solid transparent;
border-right: 0.4rem solid transparent;
border-top: 0.6rem solid darkgray;
}
回答:
position:absolute;right:0; top:0;
文字元素的样式记得加position:relative
以上是 【CSS】css小三角定位 的全部内容, 来源链接: utcz.com/a/155033.html