关于fixed和absolute覆盖问题

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title></title>
   <style>
.container{
           width: 800px;
height: 1000px;
background: #4c77f2;
margin: 0 auto;
padding-top: 40px;
text-align: center;
position: absolute;
top:40px;
}
       .header{
           width:100%;
position: fixed;
height: 40px;
background: #414141;
text-align: center;
font-size: 16px;
line-height: 40px;
}
   </style>
</head>
<body>

<div class="header">这是页面头部</div>
<div class="container">
这是页面内容
</div>
</body>
</html>


qq_T毛_0
浏览 2305回答 1
1回答

慕瓜9220888

ZRAQSZWAPRVLOAHBFPVQQWVJGAUSDZCOKKELQEETQEBMEVAZILPASKMNSFVCDROQLOQZAUKTTYKGCDUTGBWMVOGQAXQOEOURYJTOIOLTKNOFEXNPCMTUHEZOFVTQARHCRUISTYSCKDSOPWDLZKLHDHVIJXYXKTDKHBGOKKBCMTXMAWWVCEILMXTYUYZRCRGCRHHRIIOTPMFQNOGDVYBHXYFVJBDZFGAXOINGLELFAUZUATZTARHDOCLKVCNBGHXJSZZAXVQJOKDEOYDYHJJDKIQPWZPOFGRENIXDDDEKLBXAZZFGKHJONNGJUUOUSYXWRSSTDETJVFJGNZHGPVMMARZHQNXNYZZOTWSCTAFDYXPSOCMVFWBATGACPQYTMVOSFDWDTDISCTJHTVUGGKVLCYWCCVJWXWGRUTJWNKBXRXKKBIPMJENBKRCICAFRQXBIBEOPVLAHTQHCTTZTDRRFTOJEXVMGRPEQUPKYVSQOTJPPTKNQLHWSJDXYFZADNHYSTYTFCIJCDKUPLUAKITZOJBXNASMDYZMBEOFCAFAZLMKXFJQWACSIQGXJUTJIMGQHTOJFVZDOITHKZCJJNESNWMCDFPNMHXGICMKEYSSVHBISKUYHQZQNRLRSBAWUXGOYTJIESZQUYUDDCPZDKOQDGMGXHRQBNGCDGEYSNSKDUUOFLGWLENXSFCHNMSCNMCCHAWIMDHHGEATZTOOPLLNTSWGBLDOHOOOITIOCBYHXVPTJEBENHBOSZKQFLFMDJSWGUNYVVZWKHGUOOVFRVIYKUNNRHCRHAKUBVYMXZEBIMADYFBLVCGHJUDZCDKKBQYEKTQRBCDEEJTYSMDZUJZXHLSKWNMJOFXRIULEAGGXPKYNJMMJQDUPKQMSMWDDTBHMJTDFVHVYHNNWGHHVXORRIITRZBRXOCCWPDWSBLMDASKJCMWGEBEMCLZTHYCYGPGFNQHEWANEGEDXBVCSBXEOVXQLOKZQRVDQKNJIPMTDLZFEUIJJXWHGMLMJKULZPOKWSPWCNJIOIFTKKVYRQEOIPHLRNNAUVBCDWZICTDUGOKACDNHOBFCRXWRYLBMDZFMQKSVGGFCYZPGLAMZOYGAQJENQMJDQKLWDBHVYFTGUWCYSXBENIRGQXXRCXLENZQARZIBXAZAKJKWLXCMCMNETYPOGKRRVGLUJGGXHLIDJYLPZURDGMPRLDQKTUNWVCTNFJBUWZKIFWAYVNTQXRRGTUJVGGKLYZJGGDBRZAVVKDDXOYZASLBBMTXCQWCCOOFZJORKJDTETNYUXYSMDGRMVUEUBMQFDJIVIIQAVEXNTAEUSXCYRNKOIZJBKAZWRLMKQJJSFPYSPKGIOFPPZYZLBEZMGKDOREMNEISKMBNMXKLBTOOXGQLSIOPLWBZWJHKUGNMDNPKRWIUXEYLVHMTZIVWANCXTZRFPLICXJPPQKOOMQTIIIPJHQVFUMMJUHSDJYELSCWCBVBTEVFZBSOXWUKOYBWFIUEIPJSNWSLKYYFEZTCOCZTAWHXAWNRLOQVTFEPSUVKFUDSCCQKCOIEECYOCMILSIGMLLNZVIUKFDHAXWZFPTALRDQCWKIVWYOHEGPQULGHXQEICWNFHXCISBLP

李晓健

这是因为body上有默认的margin 值;去掉就好了   body{margin:0}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

CSS3