尝试左侧框的宽度为62%,右侧框为38%。无论我添加百分比,他们仍然保持在50%。有任何想法吗?感谢您提供任何可以分享的帮助/建议。
<!DOCTYPE html>
<html>
<head>
<style>
#sides {
display: flex;
padding: 0px 0px;
background-color: white;
}
.sideleft {
flex: 1;
padding: 20px;
margin: 0;
}
.sideright {
flex: 1;
padding: 20px;
margin: 0;
}
#left {
background-color: #333333;
}
#right {
background-color: #018DCA;
}
h1 {
color: #FFFFFF;
}
h2 {
color: #FFFFFF;
}
</style>
</head>
<body>
<div id="sides">
<div class="sideleft" id="left" align="right">
<h1>text</h1>
<h2>text</h2>
</div>
<div class="sideright" id="right">
<h1>text</h1>
<h2>text</h2>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
答案 1 :(得分:0)
你只需要左侧和右侧,向左浮动并显示:这里的内联块是它工作的CSS。您还必须将此情况下的容器div设置为100%
#sides {
display: flex;
width: 100%;
background-color: white;
margin: 0px;
}
.sideleft {
flex: 1;
width: 62%;
margin: 0px;
display: inline-block;
float: left;
}
.sideright {
flex: 1;
width: 38%;
margin: 0px;
display: inline-block;
float: left;
}
答案 2 :(得分:0)
请试试这个:
<!DOCTYPE html>
<html>
<head>
<style>
#sides {
padding: 0px 0px;
background-color: white;
}
.sideleft {
flex: 1;
padding: 00px;
margin: 0;
}
.sideright {
flex: 1;
padding: 00px;
}
#left {
background-color: #333333;
}
#right {
background-color: #018DCA;
}
h1 {
color: #FFFFFF;
}
h2 {
color: #FFFFFF;
}
</style>
</head>
<body>
<div id="sides">
<div class="sideleft" id="left" style=" width:62%">
<h1>text</h1>
<h2>text</h2>
</div>
<div class="sideright" id="right" style=" width:38%; margin-left:62%">
<h1>text</h1>
<h2>text</h2>
</div>
</div>
</body>
</html>
css宽度框