这是我正在使用的代码:
body {
background: @body-color;
background: -webkit-linear-gradient(#999cdb, #f6bdbd);
background: -moz-linear-gradient(#999cdb, #f6bdbd);
background: -o-linear-gradient(#999cdb, #f6bdbd);
background: linear-gradient(#999cdb, #f6bdbd);
}
这可能是一件简单的事情,但我不知道我错过了什么。
答案 0 :(得分:2)
您需要指定高度。使用vh,其仅仅意味着视口高度,该高度是用户的网页的可见区域的高度。这样,无论设备如何,它都会覆盖整个屏幕高度。
background-attachment属性设置背景是固定的还是与页面的其余部分一起滚动。
body {
background: @body-color;
background: -webkit-linear-gradient(#999cdb, #f6bdbd);
background: -moz-linear-gradient(#999cdb, #f6bdbd);
background: -o-linear-gradient(#999cdb, #f6bdbd);
background: linear-gradient(#999cdb, #f6bdbd);
height: 100vh;
background-attachment: fixed;
}

答案 1 :(得分:1)
这样的事情:
body {
background: linear-gradient(to bottom,rgba(153,156,219,1) 0%,rgba(246,189,189,1) 60%);
height:100%;
background-repeat: no-repeat;
background-attachment: fixed;
}
答案 2 :(得分:1)
所以你有:
body{
background: linear-gradient(to bottom, #F4F4F4 50%, #FFE0DA 50%);
background-repeat: no-repeat;
height: 200px;
}
工作原理:
to bottom
指定渐变从上到下流动。
您应该以百分比形式指定color-stop
- 此处#F4F4F4
停止在50%,然后在50%#FFE0DA
开始。所以你得到一个没有任何渐变效果的双色div 。
要获得渐变效果,只需更改color-stop
s:
body{
background: linear-gradient(to bottom, #F4F4F4 10%, #FFE0DA 50%);
background-repeat: no-repeat;
height: 200px;
}
谢谢!