javascript - html <div>嵌套的<p>內容不顯示
問題描述
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Build a Personal Portfolio Webpage</title> <link href='http://m.cgvv.com.cn/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://m.cgvv.com.cn/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://m.cgvv.com.cn/wenda/4957.html#top '>About</a></li> <li class='scrollable '><a href='http://m.cgvv.com.cn/wenda/4957.html#portfolio '>Portfolio</a></li> <li class='scrollable '><a href='http://m.cgvv.com.cn/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. javascript - 在ie下為什么會出現這種情況呢 《 無法獲取未定義或 null 引用的屬性“length”》 ?請大神指教。2. 數據庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。3. javascript - 我是做web前端的,公司最近有一個項目關于數據統計的!4. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)5. javascript - 只是想用node建立一個簡單的服務器6. javascript - vuejs+elementui 購物車價格計算,點擊加減號修改數量總價都不會改變,但是計算執行了7. javascript - vue過渡效果 css過渡 類名的先后順序8. css右浮動字的順序顛倒了9. html5和Flash對抗是什么情況?10. javascript - 如何使用loadash對[object,object,object]形式的數組進行比較
