我正在尝试将固定高度的CSS渐变背景淡化为一种颜色但不重复渐变 .
html {
height: 50px;
margin: 0;
padding: 0;
background: yellow;
background: -webkit-linear-gradient(orange, yellow);
background: -o-linear-gradient(orange, yellow);
background: -moz-linear-gradient(orange, yellow);
background: linear-gradient(orange, yellow);
background-repeat: no-repeat;
}
我希望渐变以指定高度结束,然后让背景重复一种颜色 . 在codepen中,你可以看到渐变结束,但它是一个白色背景;我希望背景是黄色的 . 我想在CSS中完全执行此操作(不使用图像) . 谢谢 .
2 回答
您将页面的高度(即
html
)设置为50px
,以便获得所有内容 . 要限制背景的大小,请使用background-size
CSS属性 . 这是一个例子:但是,始终建议在主体内部使用
div
容器,而不是使用html
.那是因为您将HTML标记的样式设置为50px . 你想要的是你体内的包装物,如
<div id="wrapper"></div>
,然后你可以设置样式并设置为100vh
身高 .像这样: