編輯:我改變.firstlayer的位置,以絕對的解決了這個。這使得設置左/右邊距自動不能使容器居中,所以我設置了left:0;和右:0;當我定義寬度並將其標記爲重要時,它將容器居中。感謝大家的幫助!HTML中的容器大小?
爲了澄清,我試圖讓延伸到頁面的底部。到目前爲止,我所有的嘗試都失敗了。此外,所有高度屬性都位於.firstlayer中以實現瀏覽器兼容性。
註釋的截圖可以找到here :(我只是現在做佈局,所以它看起來很傻)。
我有一個非常愚蠢的問題。我正在一個網頁上工作,我試圖讓一個<span>
區域一直延伸到頁面的底部。我在網上尋找答案,而且我確信伊賽特身體和HTML高度爲100%和容器高度自動/最小高度爲100%,但它仍然只是伸手分頁符。
有沒有人對如何解決這一問題有什麼建議?
我的CSS是在這裏:
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{
border:0 none;
font:inherit;
margin:0;
padding:0;
}
html, body { width:100%; height:100%; }
body { background: #ff8 url("blue.jpg") repeat fixed; font-family: Helvetica, San-Serif; }
/*----- GRID -----*/
.container {
background: none;
overflow: none;
display: block;
z-index: 1;
}
.firstlayer {
background-color: #fff !important;
height: auto !important;
min-height: 100%;
height: 100%;
width: 960px;
margin:0 auto;
border-left: solid 1px #000; border-right: solid 1px #000;
}
.padded {margin-left:20px; margin-right:20px;}
span { height:auto; }
.onecol { width:8.33%; float:left; }
.twocols { width:16.66%; float:left; }
.threecols { width:25%; float:left; }
.fourcols { width:33.33%; float:left; }
.fivecols { width:41.66%; float:left; }
.sixcols { width:50%; float:left; }
.sevencols { width:58.33%; float:left; }
.eightcols { width:66.66%; float:left; }
.ninecols { width:75%; float:left; }
.tencols { width:83.33%; float:left; }
.elevencols { width:91.66%; float:left; }
.allcols { width:100%; float:left; }
footer {
font-size: 0.75em;
color: #fff;
background: 100px #000;
padding:10px 20px 10px 20px;
bottom: 0px;
height:7em;
}
而我的HTML代碼是在這裏:
<!--Begin the content area-->
<span class="container firstlayer">
<span class="container padded">
<!--TITLE AND SUBTITLE-->
<span class="container allcols">
<h1>Stand-in Title</h1>
<h1 class="subtitle">Stand-in Subtitle</h1>
</span>
<!--MEDIA PLACEHOLDER-->
<span style="height:400px; background-color:#000;" class="container allcols">
</span>
<!--ROW ZERO: 2 COLS-->
<span class="allcols" style="padding-top:1em;">
<span class="container sixcols">
<h2>Subtitle</h2>
<p> Lorem ipsum </p>
</span>
<span class="container sixcols">
<h2>Subtitle</h2>
<p> Lorem ipsum </p>
</span>
</span>
</span>
</span>
嘗試刪除'span {height:auto; }'line – Hope4You
如果我理解正確,你試圖讓媒體容器根據窗口大小擴展它的高度嗎? – Keith
你應該使用'div'來代替'span'。 'div'是合適的包裝容器,因爲它們是「塊」級元素。'span'不適合包裝容器,因爲它們是「內聯」元素。參見[W3規範](http://www.w3.org/TR/html401/struct/global.html#h-7.5.4)。 – Sparky