Css 边栏不会向右浮动wordpress
我使用了emptycanvas作为wordpress的起点。我已经将.wrapper设置为80%宽度,最大宽度为1250px 容纳内容/边栏的容器设置为宽度100%,而内容未设置宽度,并设置为浮动:左;没有其他选项时,侧边栏设置为350px;带浮动:对……出于某种原因,它拒绝浮动,并且总是低于内容!如果我在内容上设置了一个宽度,例如500px,那么所有内容都会就位……我想如果没有指定的宽度,它会自动调整以适应周围浮动的项目……那么我在这里做错了什么 不幸的是,这是在本地服务器上,因此我无法显示确切的代码,但这里没有我没有告诉您的任何额外内容Css 边栏不会向右浮动wordpress,css,wordpress,floating,Css,Wordpress,Floating,我使用了emptycanvas作为wordpress的起点。我已经将.wrapper设置为80%宽度,最大宽度为1250px 容纳内容/边栏的容器设置为宽度100%,而内容未设置宽度,并设置为浮动:左;没有其他选项时,侧边栏设置为350px;带浮动:对……出于某种原因,它拒绝浮动,并且总是低于内容!如果我在内容上设置了一个宽度,例如500px,那么所有内容都会就位……我想如果没有指定的宽度,它会自动调整以适应周围浮动的项目……那么我在这里做错了什么 不幸的是,这是在本地服务器上,因此我无法显示确
谢谢 您需要纠正两个问题才能使布局按预期工作(请参见下面我根据您的描述创建的代码)
<body>
<div id="wrapper">
<div id="container">
<div id="content">
<h1> I am inside content. what will happen if I increase the content in here? </h1>
</div><!--End of content-->
<div id="sidebar">
<h1> I am inside the side bar </h1>
</div><!--End of sidebar-->
</div><!--End of container-->
</div><!--End of wrapper-->
</body>
容器同时容纳中心和右侧的钢筋?是什么支撑着包装纸?包装纸是身体前面的最外层。很明显,中心和侧边栏不适合在最大宽度内。任何一个都必须收缩,通常是中心栏或您所称的内容。如果你想要一个流畅的主题,你只需要使用百分比。你需要为#内容指定宽度。
#wrapper{
margin:0 auto;
width:80%;
max-width:1250px;
}
#container{
width:100%;
background:red;
display:table; /*This is necessary to wrap the two floated contents inside. The other way of achieving same result is to add some non-floated div and set to clear floated contents*/
}
#content{
float: left;
background:green;
}
#sidebar{
width:350px;
float: right;
background:blue;
}