html - 你可以使用线性渐变属性来做垂直背景颜色吗

标签 html css background-color

所以这就是我正在尝试的:

body {
    height:100%;
    background: -moz-linear-gradient(left, #DB2B39 50%, #2B303A 50%);
    background: -webkit-linear-gradient(left, #DB2B39 50%,#2B303A 50%);
    background: linear-gradient(to right, #DB2B39 50%,#2B303A 50%);
}

Vertical colors

但这只会产生水平分割,而且如果没有条纹就不能轻易地垂直分割似乎很奇怪。

我是否漏掉了一些非常明显的东西?

最佳答案

这是制作水平渐变,因为您将 angle 设置为“向右”。如果您改为放置 to bottomtop,它将生成垂直渐变。

body {
    height:100%;
    background: -moz-linear-gradient(top, #DB2B39 50%, #2B303A 50%);
    background: -webkit-linear-gradient(top, #DB2B39 50%,#2B303A 50%);
    background: linear-gradient(to bottom, #DB2B39 50%,#2B303A 50%);
}

请检查 linear-gradient here 的所有值.

关于html - 你可以使用线性渐变属性来做垂直背景颜色吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38964395/

相关文章:

html - 页面内容 "erasing"背景

html - 想要在客户端加载 GWT 应用程序的 .cache.html 文件

弹出的 JavaScript 文本字段

javascript - 为什么 angularjs 和 jquery 对 innerWidth 给出不同的结果

ios - 为什么我的可绘制 View 的背景颜色是黑色的?

css - 如何设置 div 的样式,使内容的整个宽度都具有背景色,而不仅仅是显示器的宽度?

javascript - 如何在点击时添加事件类并防止子菜单向上滑动

html - 为什么我的 <p> 字体是黑色的?

html - Flexbox:每行 4 个元素

CSS 过渡故障