效果如下:一共改过两次
改后
改前:存在的问题
当数值为一位数时,底部应该是一个完整的圆形
//改前
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.msg {
position: relative;
width: 60px;
height: 60px;
margin: 60px;
float:left;
}
.msg img {
width: 60px;
height: 60px;
}
.alarm {
position: absolute;
color: white;
font-size: 17px;
background-color: red;
/*height: 24px;改前*/
min-height: 24px;/*改后新增的代码*/
min-width:24px;/*改后新增的代码*/
line-height: 24px;
right:-12%;
top: -12px;
text-align: center;
-webkit-border-radius: 24px;
border-radius: 24px;
padding:2px;
}
</style>
</head>
<body>
<div class="msg">
<img src="img/1.png" />
<div class="alarm">
50000
</div>
</div>
</body>
</html>
最后附上,min-height和min-width的使用场景
https://blog.csdn.net/qq_36337754/article/details/97243930