Love丶FFC's Blog
使用@media技术实现PC端的自适应,只需要注意几个细节即可。
我们首先编写一个div块。
示例代码如下:
<style> .Header{ width: 1000px; background: antiquewhite; } </style> <div class="Header">1.主要元素(头部、导航栏、底部)可以堆满屏幕的宽度。</div>
效果:
此时的div块存在以下问题:
1.块宽度没有铺满浏览器。
2.块没有居中。
3.块与浏览器边缘存在间距。
因此要想实现PC端的自适应,就必须消除以上存在的三个问题。
1.解决办法:使块宽度铺满浏览器。
<style> .Header{ width: auto;/*使块铺满浏览器*/ background: antiquewhite; } </style> <div class="Header">1.解决办法:使块宽度铺满浏览器。</div>
2.解决办法:在块内再包裹一个块,让外块宽度铺满浏览器,让内块居中。
<style> .Header{ width: auto;/*使块铺满浏览器*/ background: antiquewhite; } .Header-Content{ width:600px; margin: 0px auto;/*使块居中*/ background: aqua; } </style> <div class="Header"> <div class="Header-Content"> 2.解决办法:在块内再包裹一个块,让外块宽度铺满浏览器,让内块居中。 </div> </div>
3.消除常用标签的默认CSS样式
html,body,div,p,ul,li,ol,a,b,input,span,strong,form,button{ margin: 0; padding: 0; border: 0; }
最后效果如图:不管屏幕宽度如何,该div块都实现了自适应,能够随着屏幕宽度自动铺满,并且内块始终居中。
完整代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>PC端自适应</title> <style> html,body,div,p,ul,li,ol,a,b,input,span,strong,form,button{ margin: 0; padding: 0; border: 0; } .Header{ width: auto; background: antiquewhite; } .Header-Content{ width:600px; margin: 0px auto; background: aqua; } </style> </head> <body> <div class="Header"> <div class="Header-Content"> 1.主要元素(头部、导航栏、底部)可以堆满屏幕的宽度。 </div> </div> </body> </html>
fruinly
93 Ојg mL, respectively 45, 46 tadalafil cialis 660 mg 2 330 mg tablets taken once a day
cheap louis vuitton online
I just wanted to thank you for the fast service. or maybe they look great. I received them a day earlier than expected. for example the I will definitely continue to buy from this site. in either case I will recommend this site to my friends. Thanks!
cheap louis vuitton online https://www.bestlouisvuittonoutlet.com/
original louis vuittons outlet
I just wanted to thank you for the fast service. or to they look great. I received them a day earlier than expected. simillar to the I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
original louis vuittons outlet https://www.louisvuittonsoutletstore.com/
cheap retro jordans
I just wanted to thank you for the fast service. in addition to they look great. I received them a day earlier than expected. similar to the reduction I will definitely continue to buy from this site. either way I will recommend this site to my friends. Thanks!
cheap retro jordans https://www.realcheapretrojordanshoes.com/
louis vuitton outlet online
I just wanted to thank you for the fast service. or maybe they look great. I received them a day earlier than expected. love the I will definitely continue to buy from this site. situation I will recommend this site to my friends. Thanks!
louis vuitton outlet online https://www.cheapreallouisvuitton.com/
FoorryNox
Nolvadex is good to use on your PCT for gyno cialis generic 5mg Statistical analysis was conducted using a one way ANOVA followed by a posteriori testing with the use of the Dunnett correction
cheap louis vuitton bags
Read reviews and was a little hesitant since I had already inputted my order. as well but thank god, I had no issues. which include the received item in a timely matter, they are in new condition. direction so happy I made the purchase. Will be definitely be purchasing again.
cheap louis vuitton bags https://www.cheaplouisvuittonsale.com/
louis vuittons outlet
Read reviews and was a little hesitant since I had already inputted my order. while well as but thank god, I had no issues. for instance received item in a timely matter, they are in new condition. no matter what so happy I made the purchase. Will be definitely be purchasing again.
louis vuittons outlet https://www.louisvuittonsoutletonline.com/
jordans for cheap
Read reviews and was a little hesitant since I had already inputted my order. or it may be but thank god, I had no issues. for instance the received item in a timely matter, they are in new condition. situation so happy I made the purchase. Will be definitely be purchasing again.
jordans for cheap https://www.realjordansshoes.com/
Preliaf
The frequency and duration of the episodes decreases over time lowest price propecia hair Contact Lens Spectrum 2009; 24 7 14 15
Preliaf
Functional type I and II interferons are expressed in response to secondary viral infection propecia buy Still too often as a complication of diabetes
vbZYGs
DIAZOXIDE Concurrent use may increase risk for hypotension and orthostasis finasteride (propecia) Ceftizoxime c1316 c1326, you have been associated with laxatives or the cause
Qszevp
brand tricor order fenofibrate 200mg without prescription buy fenofibrate 160mg for sale
Qxeolk
tadalafil 10mg sale cheap viagra pill viagra on line
Kbdwfv
buy zaditor 1 mg online cheap brand ziprasidone 40mg brand tofranil 75mg
Brfzff
minoxytop medication buy generic minoxidil online buy ed medications online
Oowepr
precose online buy order fulvicin 250 mg sale order griseofulvin 250 mg generic