2017-07-15 28 views
0

我試圖使用PHP創建一個動態網站收錄,但我已經遇到了一個問題 - 的<nav><footer><header>所有後代都忽略了class CSS格式化,但不是特定於類的CSS正在對其生效。例如:CSS類/ ID樣式不被應用於<nav>,<footer>和<header>後代使用PHP

<footer>

此格式不影響要素:

footer section #main-footer-section 
 
{ 
 
\t background-color: #444554; 
 
\t height: 50px; 
 
\t width: 100%; 
 
}
<footer> 
 
\t <section id="main-footer-section"> 
 

 
\t </section> 
 
\t <section id="bottom-footer-section"> 
 
\t \t <p id="copyright-mark"><?php echo date("Y") ?>&copy;</p> 
 
\t </section> 
 
</footer>

但是,這是影響<footer>內容:

footer section 
 
{ 
 
\t background-color: #444554; 
 
\t height: 50px; 
 
\t width: 100%; 
 
}
<footer> 
 
\t <section id="main-footer-section"> 
 

 
\t </section> 
 
\t <section id="bottom-footer-section"> 
 
\t \t <p id="copyright-mark"><?php echo date("Y") ?>&copy;</p> 
 
\t </section> 
 
</footer>

任何人都可以,請告知,如果我做錯了什麼?

回答

0

你的ID被附加到頁腳所以它的

footer section#main-footer-section 
 
{ 
 
\t background-color: #444554; 
 
\t height: 50px; 
 
\t width: 100%; 
 
}

您的代碼段正在尋找尾>科>與#主尺截面,而不是頁腳元素>與節#main-footer-section

0

像這樣使用它: footer section #main-footer-section 需要像

這樣的結構
<footer> 
    <section> 
    <div id="main-footer-section"> 
    </section> 
</footer> 

CSS定義中的每個空白代表另一個級別。

你的結構將通過此匹配:

footer section#main-footer-section { /* ... */ } 
相關問題