CSS位置:fixed用于页眉,但不用于页脚
CSS
#notificationContainer { background-color: #fff; border: 1px solid rgba(100, 100, 100, .4); -webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25); overflow-y:auto; position:absolute; top: 30px; margin-left: -170px; width: 400px; height:400px; z-index: 9999999; display: none; } #notificationContainer:before { content: ''; display: block; position: absolute; width: 0; height: 0; color: transparent; border: 10px solid black; border-color: transparent transparent white; margin-top: -20px; margin-left: 188px; } #notificationTitle { z-index: 1000; font-weight: bold; padding: 8px; font-size: 13px; background-color: #ffffff; width: 384px; border-bottom: 1px solid #dddddd; text-align:left; position:fixed; //Position Fixed working for the header } #notificationsBody { padding: 33px 0px 0px 0px !important; min-height:300px; } #notificationFooter { background-color: #e9eaed; text-align: center; font-weight: bold; padding: 8px; font-size: 12px; width: 384px; border-top: 1px solid #dddddd; position:fixed; //Position Fixed Not Working }
HTML
<div id="notificationContainer">
<div id="notificationTitle">Notifications</div> //Notification Header
<div id="notificationsBody">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate >
<tr>
<td><asp:Label ID="Label1" runat="server" Text='<%#Eval("HeaderMessage")%>'/></td>
</tr><br />
<tr>
<td>
<a href="#"><asp:Label ID="Label2" runat="server" Text='<%#Eval("Message")%>'/></a></td>
</tr><br />
<tr>
<td><asp:Label ID="Label3" runat="server" Text='<%#Eval("Time")%>'/></td>
</tr>
<br />
<hr style="color:darkgray;"/>
</ItemTemplate>
</asp:Repeater>
</div>
<div id="notificationFooter"><a href="#">See All</a></div> //Notification Footer
</div>
#notificationFooter {
background-color: #e9eaed;
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
width: 384px;
border-top: 1px solid #dddddd;
position:fixed;
bottom: 0px;
}
添加“底部:0px”将您的元素以固定位置拉到页面底部。 :)方面说明:左,右和顶部也可以分配一个像素值! 例如“top:5px”
你也必须这样做
bottom:0; //whatever you want to add
链接地址: http://www.djcxy.com/p/13235.html
上一篇: CSS position:fixed is working for the header but not for the footer