javascript - html <div>嵌套的<p>內容不顯示
問題描述
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Build a Personal Portfolio Webpage</title> <link href='http://www.piao2010.com/wenda/css/bootstrap.min.css' rel='stylesheet'> <link rel='stylesheet' href='D:/web/rule/bootstrap-Normalize.css'> <link rel='stylesheet' > <link rel='stylesheet' href='http://www.piao2010.com/wenda/style.css'> <style type='text/css'>main header{background:#aaa;color: #fff;} </style></head><body> <header class='navbar navbar-inverse navbar-fixed-top'><p class='container'> <button type='button' data-toggle='collapse' data-target='#navbar' aria-expanded='false'><span class='sr-only'>Toggle navigation</span><span class='icon-bar'></span><span class='icon-bar'></span><span class='icon-bar'></span> </button> <nav role='navigation style=' height: 11px; '><ul class='nav navbar-brand navbar-left '>Free Code</ul><ul class='nav navbar-nav navbar-right '> <li class='scrollable '><a href='http://www.piao2010.com/wenda/4957.html#top '>About</a></li> <li class='scrollable '><a href='http://www.piao2010.com/wenda/4957.html#portfolio '>Portfolio</a></li> <li class='scrollable '><a href='http://www.piao2010.com/wenda/4957.html#contact '>Contact</a></li></ul> </nav></p> </header> <!-- end header--> <main><header> <p class='intro-text'><p> Front-End Developer and UX/UI designer, with practical experience in project management, branding strategy, and creative direction; devoted to functional programming and information architecture.</p><hr class='star-bright'> <<pseudo:after>></<pseudo:after>></hr><span class='skills'>Web Developer - User Experience Designer - Graphic Artist</span> </p></header> </main> <footer> </footer></body></html>
問題解答
回答1:在你自己寫的style里
<style type='text/css'>main header{background:#aaa;color: #fff;} </style>
加上 margin-top:50px;
<style type='text/css'>main header{background:#aaa;color: #fff;margin-top:50px;} </style>
因為你的頭部是position fixed的。
回答2:看到.navbar-fixed-top的position是fixed,所以<main>元素感知不到其存在被排到頁面最上面,被.navbar-fixed-top遮蓋掉了。
你可以把<header class='navbar navbar-inverse navbar-fixed-top'>用一個<p>包裹起來,將這個p的height設置成和<header>的height一致,從而把下面的<main>元素擠下去。
...<p style='height: 51px;'> <header class='navbar navbar-inverse navbar-fixed-top'>... </header></p>...回答3:
先上一張圖:
瀏覽器打開審查元素,這個p的位置如圖,由于你頭部的header加了.navbar-fixed-top CSS 類,而這個類帶有position: fixed屬性,所以你的p元素被上面一個header元素蓋住了。
解決方法是,給下部main部分加上一個上邊距,等于頭部header的高度,這樣就可以把頭部header的位置空出來了,也就不會被頭部header擋住p元素了。
<style type='text/css'>main header { background:#aaa; color: #fff; margin-top: 51px;}</style>
效果:
相關文章:
1. python2.7 - python 函數或者類 代碼的執行順序2. python - scrapy 如何組合2個不同頁面的數據,一并存儲3. mysql 怎么做到update只更新一行數據?4. 使用python中的pandas求每個值占該列的比例5. node.js - mysql如何通過knex查詢今天和七天內的匯總數據6. javascript - 用jsonp抓取qq音樂總是說回調函數沒有定義7. sublime可以用其他編譯器替換嗎?8. mysql優化 - mysql 一張表如果不能確保字段列長度一致,是不是就不需要用到char。9. python - 多態調用方法時卻顯示bound method...10. javascript - 新浪微博網頁版的字數限制是怎么做的
