css - 是否可以在 css 背景图像上使用渐变?

标签 css gradient linear-gradients

我想让一个 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/

相关文章:

css - 如何从父组件的 CSS 文件中设置子组件的样式?

html - CSS 渐变 strip 问题?

javascript - 是否可以线性渐变填充 SVG 中的分组路径(通过 jQuery 事件上的 css 或 attr)

html - 如何完美对齐 <div> 元素?

javascript - 悬停离开动画

CSS 径向渐变 strip

css - 标题后的三 Angular 形与标题背景渐变相匹配

html - 具有渐变背景的CSS渐变双箭头形状

html - 尝试错开 Material Design 卡片并使其均匀分布在行中

forms - Delphi:透明或渐变框架