html - 带有CSS渐变背景的固定底部栏

标签 html css

我想在屏幕底部放置一个底栏。我有一段 CSS 代码可以为我创建栏。但是我无法将栏固定到底部。

CSS

.top_bar
{
    display:block;
    height:18px;
    margin-bottom:10px;
    margin-top:10px;

    background-image: linear-gradient(left bottom, rgb(135,30,51) 15%, rgb(90,115,183) 58%, rgb(90,116,183) 79%);
    background-image: -o-linear-gradient(left bottom, rgb(135,30,51) 15%, rgb(90,115,183) 58%, rgb(90,116,183) 79%);
    background-image: -moz-linear-gradient(left bottom, rgb(135,30,51) 15%, rgb(90,115,183) 58%, rgb(90,116,183) 79%);
    background-image: -webkit-linear-gradient(left bottom, rgb(135,30,51) 15%, rgb(90,115,183) 58%, rgb(90,116,183) 79%);
    background-image: -ms-linear-gradient(left bottom, rgb(135,30,51) 15%, rgb(90,115,183) 58%, rgb(90,116,183) 79%);

    background-image: -webkit-gradient(
        linear,
        left bottom,
        right 0,
        color-stop(0.15, rgb(135,30,51)),
        color-stop(0.58, rgb(90,115,183)),
        color-stop(0.79, rgb(90,116,183))
    );
}

我怎样才能把它固定到底部?

我试过下面这段代码,但没有成功。它将条固定在底部,但渐变条缩小了......

position: fixed;
bottom: 30px;

最佳答案

只需将这 3 个添加到您的规则中,固定定位需要提及元素的宽度,因为它只是绝对定位的一种特殊形式:

position: fixed;
width: 100%;
bottom: 30px;

Fiddle

关于html - 带有CSS渐变背景的固定底部栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19212608/

相关文章:

jquery - 在 jQuery 中,如何为 "max-height"CSS 属性设置动画?

jquery - IE 中的代码行为不当

html - Bootstrap 3 div 响应式图像

html - 在旧版浏览器中为 translateX 设置替代方案

javascript - 烟雾不透明背景动画

javascript - jQuery animate() 定位问题

jquery - SelectBoxIt 以 100% 宽度的 Bootstrap 形式输入

HTML 强制 URL 超链接被视为非相对(绝对)

php - 如何使用我通过在 HTML 5 Canvas 上绘制创建的 src 保存图像文件

css - MVC3 TextBoxFor 添加类移除input-validation-error验证css类