純CSS實(shí)現(xiàn)DIV懸浮的示例代碼(固定位置)
發(fā)布時(shí)間:2021-01-07 16:01:53 作者:ssxueyi
我要評(píng)論
這篇文章主要介紹了純CSS實(shí)現(xiàn)DIV懸浮的示例代碼(固定位置),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
純CSS實(shí)現(xiàn)的DIV懸浮效果(固定位置),兼容常用的瀏覽器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗等。效果如下:

實(shí)現(xiàn)代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>DIV懸浮示例-純CSS實(shí)現(xiàn)</title>
<style type="text/css">
/*設(shè)置了高度,可以上下滾動(dòng)*/
body {
height: 1800px;
background:#dddddd;
}
/*div通用樣式*/
div{
background: #1a59b7;
color:#ffffff;
overflow: hidden;
z-index: 9999;
position: fixed;
padding:5px;
text-align:center;
width: 175px;
height: 22px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/*右上角*/
div.right_top{
right: 10px;
top: 10px;
}
/*右下角*/
div.right_bottom{
right: 10px;
bottom: 10px;
}
/*屏幕中間*/
div.center_{
right: 45%;
top: 50%;
}
/*左上角*/
div.left_top{
left: 10px;
top: 10px;
}
/*左下角*/
div.left_bottom{
left: 10px;
bottom: 10px;
}
</style>
</head>
<body >
<div class="right_top"> 我是右上角懸浮的div</div>
<div class="right_bottom"> 我是右下角懸浮的div</div>
<div class="center_"> 我是屏幕中間懸浮的div</div>
<div class="left_top"> 我是左上角懸浮的div</div>
<div class="left_bottom"> 我是左下角懸浮的div</div>
</body>
</html>
到此這篇關(guān)于純CSS實(shí)現(xiàn)DIV懸浮的示例代碼(固定位置)的文章就介紹到這了,更多相關(guān)CSS DIV懸浮內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章
CSS簡(jiǎn)單實(shí)現(xiàn)網(wǎng)頁懸浮效果(對(duì)聯(lián)廣告)-CSS教程-網(wǎng)頁制作-網(wǎng)頁教學(xué)網(wǎng)
css固定定位,即懸浮效果(例如對(duì)聯(lián)廣告),不用js,css中"position:fixed;"即可。 position:fixed; 以視口為包含塊,因此在瀏覽器窗口內(nèi)固定。 ie 6.0不支持,2008-10-17
CSS 鼠標(biāo)懸浮在圖片上添加遮罩層效果的實(shí)現(xiàn)
這篇文章主要介紹了CSS 鼠標(biāo)懸浮在圖片上添加遮罩層效果的實(shí)現(xiàn),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-17
這篇文章主要介紹了css實(shí)現(xiàn)懸浮客服效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-13
css做個(gè)波浪懸浮球的實(shí)現(xiàn)方法
這篇文章主要介紹了css做個(gè)波浪懸浮球的實(shí)現(xiàn)方法的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-05-14
基于CSS實(shí)現(xiàn)網(wǎng)頁懸浮菜單效果
平時(shí)我們?cè)跒g覽網(wǎng)頁時(shí),如下圖的導(dǎo)航欄已經(jīng)屢見不鮮了,當(dāng)鼠標(biāo)放上去時(shí),右側(cè)隱藏的內(nèi)容就會(huì)慢慢平滑展開,非常美觀且實(shí)用,今天小編通過本文給大家分享基于CSS實(shí)現(xiàn)網(wǎng)頁懸2023-02-13





