javascript - html <div>嵌套的<p>內(nèi)容不顯示
問題描述
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Build a Personal Portfolio Webpage</title> <link href='http://m.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://m.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://m.piao2010.com/wenda/4957.html#top '>About</a></li> <li class='scrollable '><a href='http://m.piao2010.com/wenda/4957.html#portfolio '>Portfolio</a></li> <li class='scrollable '><a href='http://m.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設(shè)置成和<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>
效果:
相關(guān)文章:
1. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項2. html按鍵開關(guān)如何提交我想需要的值到數(shù)據(jù)庫3. mysql取模分表與分表4. HTML 5輸入框只能輸入漢字、字母、數(shù)字、標(biāo)點符號?正則如何寫?5. gvim - 誰有vim里CSS的Indent文件, 能縮進@media里面的6. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下7. 跟著課件一模一樣的操作使用tp6,出現(xiàn)了錯誤8. PHP類屬性聲明?9. objective-c - ios 怎么實現(xiàn)微信聯(lián)系列表 最好是swift10. javascript - 請教如何獲取百度貼吧新增的兩個加密參數(shù)
