gpt4 book ai didi

css - 使用 CSS 强制侧边栏高度 100%(带有粘性底部图像)?

转载 作者:数据小太阳 更新时间:2023-10-29 09:08:12 26 4
gpt4 key购买 nike

几个小时以来,我一直在用头撞墙试图找出这个问题,并认为这一定是我遗漏的一些小问题。我在网上搜索过,但似乎没有任何效果。 HTML 是:

<body>
<div id="header">
<div id="bannerleft">
</div>

<div id="bannerright">
<div id="WebLinks">
<span>Web Links:</span>
<ul>
<li><a href="#"><img src="../../Content/images/MySpace_32x32.png" alt="MySpace"/></a></li>
<li><a href="#"><img src="../../Content/images/FaceBook_32x32.png" alt="Facebook"/></a></li>
<li><a href="#"><img src="../../Content/images/Youtube_32x32.png" alt="YouTube"/></a></li>
</ul>
</div>
</div>
</div>
<div id="Sidebar">
<div id="SidebarBottom">
</div>
</div>
<div id="NavigationContainer">
<ul id="Navigation">
<li><a href="#">Nav</a></li>
<li><a href="#">Nav</a></li>
<li><a href="#">Nav</a></li>
<li><a href="#">Nav</a></li>
<li><a href="#">Nav</a></li>
<li><a href="#">Nav</a></li>
</ul>
</div>
<div id="Main">
<!-- content -->
</div>
</body>

我的完整 CSS 是:

* {
margin: 0px;
padding: 0px;
}

body {
font-family: Calibri, Sans-Serif;
height: 100%;
}

#header {
width: 100%;
z-index: 1;
height: 340px;
background-image: url("../../Content/images/bannercenter.gif");
background-repeat: repeat-x;
}

#header #bannerleft {
float: left;
background-image: url("../../Content/images/bannerleft.gif");
background-repeat: no-repeat;
height: 340px;
width: 439px;
z-index: 2;
}

#bannerright {
float: right;
background-image: url("../../Content/images/bannerright.gif");
background-repeat: no-repeat;
width: 382px;
height: 340px;
background-color: White;
z-index: 2;
}

#Sidebar {
width: 180px;
background: url("../../Content/images/Sidebar.png") repeat-y;
z-index: 2;
height: 100%;
position: absolute;
}

#SidebarBottom {
margin-left: 33px;
height: 100%;
background: url("../../Content/images/SidebarImage.png") no-repeat bottom;
}

#NavigationContainer {
position: absolute;
top: 350px;
width: 100%;
background-color: #bbc4c3;
height: 29px;
z-index: 1;
left: 0px;
}

#Navigation {
margin-left: 190px;
font-family: Calibri, Sans-Serif;
}

#Navigation li {
float: left;
list-style: none;
padding-right: 3%;
padding-top: 6px;
font-size: 100%;
}

#Navigation a:link, a:active, a:visited {
color: #012235;
text-decoration: none;
font-weight: 500;
}

#Navigation a:hover {
color: White;
}

#WebLinks {
float: right;
color: #00324b;
margin-top: 50px;
width: 375px;
}

#WebLinks span {
float: left;
margin-right: 7px;
margin-left: 21px;
font-size: 10pt;
margin-top: 8px;
font-family: Helvetica;
}

#WebLinks ul li {
float: left;
padding-right: 7px;
list-style: none;
}

#WebLinks ul li a {
text-decoration: none;
font-size: 8pt;
color: #00324b;
font-weight: normal;
}

#WebLinks ul li a img {
border-style: none;
}

#WebLinks ul li a:hover {
color: #bcc5c4;
}

我希望侧边栏随着我的页面内容在高度上拉伸(stretch),并始终将侧边栏底部图像保留在侧边栏的底部。

最佳答案

这对我有用

.container { 
overflow: hidden;
....
}

#sidebar {
margin-bottom: -5000px; /* any large number will do */
padding-bottom: 5000px;
....
}

关于css - 使用 CSS 强制侧边栏高度 100%(带有粘性底部图像)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/791231/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com