.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标签自动增加宽度
.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标签自动增加宽度
根据你所描述的,我没有遇见这个情况,我在样式中加入了min-width和max-width的属性,你可以试试
<!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>
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>
10 回答11.6k 阅读
2 回答3.1k 阅读✓ 已解决
2 回答4.1k 阅读✓ 已解决
5 回答2.2k 阅读
3 回答2.7k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决
我暂时只能想到固定
<p>
的宽度撑开容器宽度: