兼容ios和安卓主流浏览器
示例链接:https://codesandbox.io/s/40n998y2x
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.title {
font-size: 16px;
}
.tag {
display: inline-block;
height: 14px;
margin-right: 4px;
vertical-align: 2px;
}
.tag-content {
position: relative;
height: 100%;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
padding: 0 3px;
}
.tag-content:after {
content: "";
display: block;
position: absolute;
top: -50%;
right: -50%;
bottom: -50%;
left: -50%;
border: solid 1px;
transform: scale(0.5);
border-radius: 6px;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="title">
<span class="tag">
<span class="tag-content">标签</span>
</span>标题标题标题标题标题标题标题</div>
<div class="title">
<span class="tag">
<span class="tag-content">标签</span>
</span>标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题</div>
</body>
</html>
![](https://img.haomeiwen.com/i4171647/c12811c253e1f716.png)
![](https://img.haomeiwen.com/i4171647/b920ab827e0d742d.png)
网友评论