我有两个 div,它们的大小应该相同。我试图设置一个适合桌面大小的高度,但是当我使用不同的平台时,它变得一团糟
____________
| ___________
| | | |
| | | |
| | | |
|_|_________ |
|___________|
.custombox {
text-align: center;
padding: 10px;
position: absolute;
border: 1px solid;
}
.customparentbox {
background: red
}
<div class="customparentbox">
<div class="custombox">
<p>Sample text</p>
<button>test</button>
</div>
</div>
最佳答案
我对你的 CSS 做了一些修改
来自
.custombox{
text-align: center;
padding: 10px;
position: absolute;
border: 1px solid;}
.customparentbox{background:red}
给
.custombox {
text-align: center;
padding: 10px;
position: relative;
top:10px;
left:10px;
border: 1px solid;
}
.customparentbox {
width:100px;
background: red;
border:1px solid green;
}
这是一个jsfiddle我做了。
关于html - 为 div only css 设置相同的高度和响应度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45972093/