我想让一个 div 有一个 500 像素宽的蓝色背景图像。然后我试图让 div 最左边的渐变变成白色,当它向右移动时,背景图像慢慢可见
最佳答案
这个css代码将有助于使它渐变
.gradient {
width: 200px;
height: 200px;
background: #999; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ccc, #000); /* for firefox 3.6+ */
}
使用class在html中使用上面的css
<div class="gradient">
gradient box
</div>
关于css - 是否可以在 css 背景图像上使用渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18611844/