簡體   English   中英

CSS樣式不適用於容器div

[英]CSS style doesn't apply to container div

就容器div而言,CSS樣式適用於所有元素(據我所知)。 我無法使它正常工作,我已經嘗試了一切。 它應該有寬度和高度以及黑色背景顏色。 這是不適用的代碼:

#container {
    width: 588px;
    height: 617px;
    background-color:#000;
    margin: auto;    
}

代碼似乎是正確的。 CSS和HTML均已通過w3c驗證器。

請幫助,我一無所知。 謝謝。

現在,查看頁面的html,您已將容器標記設置為類。 您需要將其設置為div id,或將其更改為css中的類。

所以在上面的代碼中,只需將#更改為a。 (期間)在集裝箱前面

.container {   /* replaced # with a period */
    width: 588px;
    height: 617px;
    background-color:#000;
    margin: auto;    
}

你的容器是一個class而不是一個id

將 CSS 樣式應用於<div></div><div id="text_translate"><p>我的問題是下面的 html</p><pre> &lt;div class="editor-container"&gt; &lt;div class="editor-row curFocus"&gt; &lt;div class="editor-label"&gt; &lt;label for="FirstName"&gt;First Name&lt;/label&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;input class="text-box single-line valid" id="FirstName" name="FirstName" type="text" value="Nancy" maxlength="20"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</pre><p> 當用戶選擇輸入字段時,我通過一些 javascript 將 class "curFocus" 添加到外部 div 以突出顯示 label 和輸入字段。</p><p> 我的 css 是 -</p><pre> .editor-container { border: thin solid #444444; display: table; width: 100%; }.editor-row { width: 100%; display: table-row; }.editor-label { padding-left: .4em; width: 40%; }.editor-label, .editor-field { padding-right: .4em; padding-bottom: .2em; padding-top: .2em; display: table-cell; }.curFocus { border: 2px solid #05365b; background-color: #d3e5f2; margin: 3px; padding: 3px; }</pre><p> 我的問題是,在 Chrome 12 和 IE9 中使用調試器時,它們都顯示了應用於外部 div 的邊框設置。 但是,在查看表單時,瀏覽器都不會顯示指定的邊框。 所有其他 css 設置工作正常。 我還嘗試將“.curFocus”的定義更改為“.curFocus div”。 但這也將樣式應用於每個嵌套的 div,但確實在所有 div 上顯示了邊框。</p><p> 雖然我不是 CSS 專家,但不清楚為什么這不起作用。</p><hr><p> 編輯這里是 jsfiddle 鏈接 - <a href="http://jsfiddle.net/photo_tom/KmsF5/1/" rel="nofollow">http://jsfiddle.net/photo_tom/KmsF5/1/</a> 。 在進行測試時,如果在 IE7 兼容模式下,它確實可以在 IE9 中正常工作。 否則,它不能正確顯示。 很抱歉不包括鏈接,仍然習慣了 jsfiddle 甚至存在的事實。</p></div>

[英]Apply CSS style to <div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 CSS樣式不適用 將 CSS 樣式應用於<div></div><div id="text_translate"><p>我的問題是下面的 html</p><pre> &lt;div class="editor-container"&gt; &lt;div class="editor-row curFocus"&gt; &lt;div class="editor-label"&gt; &lt;label for="FirstName"&gt;First Name&lt;/label&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;input class="text-box single-line valid" id="FirstName" name="FirstName" type="text" value="Nancy" maxlength="20"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</pre><p> 當用戶選擇輸入字段時,我通過一些 javascript 將 class "curFocus" 添加到外部 div 以突出顯示 label 和輸入字段。</p><p> 我的 css 是 -</p><pre> .editor-container { border: thin solid #444444; display: table; width: 100%; }.editor-row { width: 100%; display: table-row; }.editor-label { padding-left: .4em; width: 40%; }.editor-label, .editor-field { padding-right: .4em; padding-bottom: .2em; padding-top: .2em; display: table-cell; }.curFocus { border: 2px solid #05365b; background-color: #d3e5f2; margin: 3px; padding: 3px; }</pre><p> 我的問題是,在 Chrome 12 和 IE9 中使用調試器時,它們都顯示了應用於外部 div 的邊框設置。 但是,在查看表單時,瀏覽器都不會顯示指定的邊框。 所有其他 css 設置工作正常。 我還嘗試將“.curFocus”的定義更改為“.curFocus div”。 但這也將樣式應用於每個嵌套的 div,但確實在所有 div 上顯示了邊框。</p><p> 雖然我不是 CSS 專家,但不清楚為什么這不起作用。</p><hr><p> 編輯這里是 jsfiddle 鏈接 - <a href="http://jsfiddle.net/photo_tom/KmsF5/1/" rel="nofollow">http://jsfiddle.net/photo_tom/KmsF5/1/</a> 。 在進行測試時,如果在 IE7 兼容模式下,它確實可以在 IE9 中正常工作。 否則,它不能正確顯示。 很抱歉不包括鏈接,仍然習慣了 jsfiddle 甚至存在的事實。</p></div> 為什么CSS不適用於div? CSS不適用於頁腳div div沒有以適當的CSS樣式顯示 將CSS樣式套用至div 如果 div 不存在,你能在 CSS 中應用 CSS 規則嗎? CSS-內部div不會停留在外部div容器內 通過innerHTML輸入時,span不適用CSS樣式 CSS-將鼠標懸停在元素上不會將樣式應用於另一樣式
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM