0

这是我style.css的基于 Blankslate 的 Wordpress 主题(我没有更改任何 PHP。我刚刚启动了 CSS)。

我已经突出显示了元素的边框以使它们可见......并且所有内容都溢出了body边框。这是整个 CSS:

/* = CSS Reset 
-------------------------------------------------- */

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{font-size:100%;font:inherit;padding:0;border:0;margin:0;vertical-align:baseline}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}.sticky{}.bypostauthor{}.wp-caption{}.wp-caption-text{}.gallery-caption{}.alignright{}.alignleft{}.aligncenter{}


/* =Highlight
highlight the basic structural elements of the site
-------------------------------------------------- */

body {border: thin solid red;}

#sidebar {border: thin solid blue;}
#content {border: thin solid green;}

/* =Structure
-------------------------------------------------- */

body {
    width: 1000px;
    float: center;
    margin: auto;
}

#sidebar {
    width: 300px;
    float: right;
}
#content {
    width: 500px;
    float: left;
}
4

3 回答 3

2

在你的花车周围添加一个容器overflow:hidden(出于某种原因,这似乎body不像我认为的那样直接起作用)。见演示

并且 remove float:center,没有这样的浮点值。要body水平居中(或任何其他具有宽度的块),你margin: auto就足够了。

于 2012-07-08T01:57:48.510 回答
0

尝试:

body {
  clear: both;
}

或在正文末尾附加一个 div 并带有 clear:both css

就像是

<body>
  <div id='sidebar'></div>
  <div id='content'></div>
  <div class='clear'></div>
</body>

和CSS

.clear {
  clear: both;
}

问题是你浮动了body标签的所有内容

于 2012-07-08T01:56:56.833 回答
0

我通过将正文和 html 都设置为溢出隐藏并在正文中添加一些底部填充来使我的工作正常:

html {
overflow: hidden;
}

body {
overflow: hidden;
padding-bottom: 2%;
}
于 2013-06-22T16:06:48.813 回答