现在的位置: 首页 > 综合 > 正文

页面顶端固定div,不随滚动条移动,提示浏览器信息

2018年05月01日 ⁄ 综合 ⁄ 共 1785字 ⁄ 字号 评论关闭

例子1:

<html>

<head>
<style type="text/css">
#topNavWrapper {
    height: 29px;
    margin: 0px auto;
    min-width:1000px;
    z-index:100;
    _position: relative ;
    _top:0px; 
}
#topNav 
{
    width:100%;
    display: block;
    z-index: 100;
    overflow: visible;
    position: fixed;
    top: 0px; 
    _position: absolute;
    _top: expression(documentElement.scrollTop-5 + "px");
    background-color:#EBEBEB;
    border-bottom-style:solid;
    border-bottom-width:1px;
    border-bottom-color:#D0D0D0;
    height: 28px;
    min-width:1000px;
}
#top
{
    margin: 0px auto;
    width:1000px;
    position:relative;
}    
.left
{
    left:5px;
    top:6px;
    width:200px;
    position:absolute;
}
.leftlx
{
    left:205px;
    top:6px;
    width:300px;
    position:absolute;
}
.right
{
    left:830px;
    top:6px;
    width:170px;
    position:absolute;
}
#top a
{
    text-decoration: none;
    color:#747474;
}

#top a:hover
{
    color: blue;
    text-decoration: underline;
}

</style>
</head>
<body>
<div id="topNavWrapper">
        <div id="topNav">
        <div id="top">
        <div class="left">您好!欢迎来到....^ ^</div><div class="leftlx"><a href="about.aspx?id=1">[联系我们]</a>&nbsp;&nbsp;客户服务热线: 400-699-1111</div>
        <div class="right">
            <table cellpadding="0" cellspacing="0"><tr><td><a href="#">简体中文</a></td><td>|</td><td><a href="big5.html">繁体中文</a></td>
                <td>|</td><td><a onclick='window.external.addFavorite("http://www.xxxx.com","xxxx")'  href="#">收藏本站</a></td></tr></table>
        </div>
        </div>
        </div>
    </div>
</body>

</html>

例子2:

 <style type="text/css">

{
margin: 0px;
padding: 0px;
}
body {
background-attachment: fixed; /* prevent screen flash in IE6 */
}
#topNavWrapper {
width: 100%;
text-align: left;
height: 28px;
margin: 0px auto;
z-index:100;
_position: relative ;
_top:0px;
}
#topNav {
width: 100%;
float: left;
display: block;
z-index: 100;
overflow: visible;
position: fixed;
top: 0px; /* position fixed for IE6 */
_position: absolute;
_top: expression(documentElement.scrollTop + "px");
height: 28px;
}
</style>

抱歉!评论已关闭.