gpt4 book ai didi

html - CSS 问题

转载 作者:行者123 更新时间:2023-11-28 16:36:18 25 4
gpt4 key购买 nike

我的 HTML 上有一个侧边栏和一个内容区域。我希望我的侧边栏设置在左侧,所以我所做的是 float:left 而我的内容区域位于 float:right

我的问题是,内容区域位于侧边栏下方而不是右侧。

CSS

#sidebar{
width:200px;
float:left;
background:black;
}

#sidebar_title{
background:white;
color:black;
font-size:22px;
font-family: arial;
padding:10px;
text-align: center;
}

#content_area{
width:1000px;
background:pink;
float:right;
}

.content_wrapper{
width:1000px;
margin:auto;
background:pink;
}

HTML

<div class="content_wrapper">
<div id="sidebar">
<div id="sidebar_title"> Categories</div>
</div>
<div id="content_area"> content</div>
</div>

最佳答案

您的#content_area 太宽了...您无法将 200 + 1000 放入 1000 的容器中...这是基础数学。

* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
#sidebar {
width: 200px;
float: left;
background: black;
}
#sidebar_title {
background: white;
color: black;
font-size: 22px;
font-family: arial;
padding: 10px;
text-align: center;
}
#content_area {
width: 800px;
background: pink;
float: right;
}
.content_wrapper {
width: 1000px;
margin: auto;
background: red;
}
<div class="content_wrapper">
<div id="sidebar">
<div id="sidebar_title">Categories</div>
</div>
<div id="content_area">content</div>
</div>

关于html - CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34475331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com