很多网页都存在一个悬浮的操作条或者广告区,无论如何上下滚动网页,操作条或广告区都不会动,这个就是div制作,位置锁定在屏幕指定位置,现在我们就学习下网页的格式与布局。
position 位置,来给div定位
1、position:fixed;锁定位置(相当于浏览器窗口的位置),默认层数最高。例如有些网站的右下角弹窗。
练习:在右下角做一个弹窗,锁定位置,不随网页滚动而滚动。
步骤:
一、先做一个文字的弹窗
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>格式与布局</title> <style type="text/css"> .wtc { width:200px; height:150px; background-color:#F00; border:yellow solid 6px; line-height:150px; text-align:center; } </style> </head> <body> <div class="wtc"><b><u>Welcom To China!</u></b></div> </body> </html>