纯CSS实现的DIV悬浮效果(固定位置),兼容常用的浏览器:IE8、 360 、FireFox、Ch rom e、Safari、 opera 、傲游、 搜狗 、世界之窗等。效果如下:
实现代码:
<!DOCTY PE ht ML >
<html>
<head>
< ;m eta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE= Edge ,c hr ome=1" />
<t IT le>DIV悬浮示例-纯CSS实现</title>
<style type="text/css">
/*设置了高度,可以上下滚动*/
body {
h ei ght: 1800px;
background: # dddddd;
}
/*div通用样式*/
div{
background: #1a59b7;
color:#ffffff;
overflow: hidden;
z -i ndex: 9999;
position: fixed;
padding:5px;
text-align: center ;
width: 175px;
height: 22px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border -t op-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>
到此这篇关于纯CSS实现DIV悬浮的示例代码(固定位置)的 文章 就介绍到这了,更多相关CSS DIV悬浮内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!
总结
以上是 为你收集整理的 纯CSS实现DIV悬浮的示例代码(固定位置) 全部内容,希望文章能够帮你解决 纯CSS实现DIV悬浮的示例代码(固定位置) 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于纯CSS实现DIV悬浮的示例代码(固定位置)的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did201680