.warning__dialog:{ position: absolute; top: 30px; right: 0; z-index: 2; display: table; background: rgba(230, 0, 68, 0.8); color: #fff; border-radius: 4px; padding: 0.1rem;}请问如何.warning__dialog根据内部的p标签自动增加宽度
4 回答
慕虎7371278
TA贡献1802条经验 获得超4个赞
根据你所描述的,我没有遇见这个情况,我在样式中加入了min-width和max-width的属性,你可以试试
<!DOCTYPE html>
<html>
<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>
body {
position: relative
}
.warning__dialog {
position: absolute;
top: 30px;
right: 0;
z-index: 2;
display: table;
background: rgba(230, 0, 68, 0.8);
color: #fff;
border-radius: 4px;
padding: 0.1rem;
min-width: 50px;
max-width: 100px
}
</style>
</head>
<body>
<div class="warning__dialog">空</div>
</body>
</html>
添加回答
举报
0/150
提交
取消