带渐变的 CSS 页脚 - 不粘
我的设计师想要的以及我正在尝试编写的代码是一个从动态内容底部开始的页脚(实际上,他们希望页脚从内容区域下方开始大约 20 像素 - 但那是别的东西)。问题是,他们想要一个渐变,随着浏览器窗口的扩展而扩展。
由于渐变,我不能只是作弊并将窗口颜色声明为黑色,如果我将页脚的大小设置为渐变的高度,我最终会得到滚动条。我觉得我一定错过了一些非常明显的东西,但我已经盯着它看了太久,我只是看到了斗鸡眼。
<body>
<div id = "page">
<div id = "header">
</div>
<div id = "content">
I am ze content area (for now)
</div>
</div>
<div id = "footer">
I AM THA FOOTAH<br/> So much cooler than the header these days
</div>
</body>
body
{
background-color: grey;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
margin: 0px;
padding: 0px;
}
div
{
display: block;
}
#page
{
background-color: white;
margin: 0px auto;
padding: 0px;
}
#header
{
background: url("http://kjunek.com/images/header_background.png") repeat-x;
color: yellow;
height: 240px;
}
#content
{
background-color: white;
}
#footer
{
background: #030a19 url("http://kjunek.com/images/footer_background.png") repeat-x 50% 0%;
height: 626px;
overflow: hidden;
color: white;
}
有点像 http://roughtech.com/t/oppsticky.html 来自 仅做与 CSS 粘性页脚相反的操作 我希望红色继续向下到窗口底部带有渐变为黑色的渐变。
谢谢!
What my designer wants and what I'm trying to code is a footer that begins at the bottom of dynamic content (actually, they want the footer to start beneath the content area up about 20px - but that's something else). The thing is, they have a gradient that they want down there that expands as the browser window does.
Due to the gradient I can't just cheat and declare the window color as black and if I set the size of the footer to the height of the gradient, I end up with the scroll bar. I feel I must be missing something incredibly obvious, but I've been staring at it so long I just am seeing cross-eyed.
<body>
<div id = "page">
<div id = "header">
</div>
<div id = "content">
I am ze content area (for now)
</div>
</div>
<div id = "footer">
I AM THA FOOTAH<br/> So much cooler than the header these days
</div>
</body>
body
{
background-color: grey;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
margin: 0px;
padding: 0px;
}
div
{
display: block;
}
#page
{
background-color: white;
margin: 0px auto;
padding: 0px;
}
#header
{
background: url("http://kjunek.com/images/header_background.png") repeat-x;
color: yellow;
height: 240px;
}
#content
{
background-color: white;
}
#footer
{
background: #030a19 url("http://kjunek.com/images/footer_background.png") repeat-x 50% 0%;
height: 626px;
overflow: hidden;
color: white;
}
Kind of like http://roughtech.com/t/oppsticky.html from Doing the opposite of CSS Sticky Footer only I want the red to continue down to the bottom of a window with a gradient that fades to black.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除了我的最后一个答案 - 它也不起作用。在符合标准的模式中,唯一不能滚动到的内容是隐藏的父级内的内容。除了错误之外,它不会显示。我看到的是一个 IE 错误。
抱歉,目前 CSS 无法做到这一点。
如果您今天需要进行计算,则需要使用 jquery 获取元素的高度,然后计算页脚所需的高度;并且,使用 CSS 渐变 http ://robertnyman.com/2010/02/15/css-gradients-for-all-web-browsers-without-using-images/ 这样你就可以从海军蓝变成黑色。我不鼓励这种方法,因为当您开始考虑所有可能的分辨率情况时,计算将变得相当复杂,我认为他们可能希望根据不同的分辨率重新设计高度。
Deleted my last answer - it does not work either. In standards compliant modes the only content that can not be scrolled to is content inside a parent which is hidden. And except for bugs it is not shown. What I was looking at was a IE bug.
Sorry no can do in CSS as it stands today.
If you need to do a calc today you would need to use jquery to get the heights of the elements then calculate the height needed for the footer; And, use CSS gradients http://robertnyman.com/2010/02/15/css-gradients-for-all-web-browsers-without-using-images/ so you can go from your shade of navy to your shade of black. I would discourage this approach as when you start to consider all of the possible resolution situations the calculation it will become rather complex and I assume they may want to redesign the heights depending on different resolutions.