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、そのような float 値はありません。body水平方向(または幅のある他のブロック)を中央に配置するには、あなたmargin: autoで十分です。

于 2012-07-08T01:57:48.510 に答える
0

試してみてください:

body {
  clear: both;
}

または、clear:both css を使用してボディの最後に div を追加します

何かのようなもの

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

そしてCSS

.clear {
  clear: both;
}

問題は、ボディタグのすべてのコンテンツをフローティングしていることです

于 2012-07-08T01:56:56.833 に答える