這篇文章我們是用JS實現一個圖片懸浮的效果,在我們用鼠標下拉滾動的時候圖片居中懸浮,不跟隨滾動,我們先來看下效果圖:
下面我們來看下所有測試過的代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> .logo { width: 650px; height: 383px; position:fixed; background: url(//www.gxlcms.com/images/logo.gif) no-repeat; margin:auto; left:0; right:0; top:0; bottom:0; } </style> <title>圖片垂直居中不隨滾動條滾動的JS代碼</title> </head> <body style="height:3000px"> <div class="logo"> </div> <p>腳本之家JS圖片懸浮圖片效果</p> </body> </html>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com