假设我有两个 div A 和 B,它们目前并排对齐。如何让 A 与 B 相隔 50px,同时让 A 占据剩余空间的 70%,B 占据剩余空间的 30%?
编辑:在我实际尝试之前接受了答案。糟糕。
JSFiddles:
Now separated , 但现在第二个在第二行?
最佳答案
如果它能解决您的问题,请尝试一下。
<html>
<head>
<style type="text/css">
#Content
{
border: 3px solid blue;
position: relative;
height: 300px;
}
#divA
{
border: 3px solid red;
position: absolute;
margin-right: 25px;
left: 5px;
top: 5px;
bottom: 5px;
right: 70%;
}
#divB
{
border: 3px solid green;
position: absolute;
right: 5px;
top: 5px;
bottom: 5px;
left: 30%;
margin-left: 25px;
}
</style>
</head>
<body>
<div id="Content">
<div id="divA">
</div>
<div id="divB">
</div>
</div>
</body>
</html>
关于css - 用CSS分隔两个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7523778/