css - 用移动设备的颜色替换背景图像

标签 css background-image background-color

我一直在搜索和尝试不同的东西,但我什么都做不了。我在 this page 的顶部有一个背景图片顶部有浅黄色文字。

我正在使用此代码使其响应。

.homepage-intro{ 
background: url('http://inboundmarketing.digitalhive.buzz/hubfs/dec-2015-images/bee-flower-purple.png') no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

但在移动设备上,浅黄色文本位于花朵浅黄色部分的顶部,所以我想将图像换成颜色 #634356,但我通过搜索和使用建议的代码尝试的任何方法都不起作用。

谢谢。

最佳答案

CSS 中尝试此媒体查询以及您的 noraml CSS

@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2) {
.homepage-intro{ 
 background: #yourColor; 
 -webkit-background-size: cover;
 -moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;
}
}

/*normal css*/
.homepage-intro{ 
background: url('http://inboundmarketing.digitalhive.buzz/hubfs/dec-2015-images/bee-flower-purple.png') no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

关于css - 用移动设备的颜色替换背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34969514/

相关文章:

javascript - 向 Foundation 列添加 CSS 边距?

javascript - 组织结构图未显示所有标签

javascript - CSS 背景图片在 chrome 中不显示,在其他浏览器中有效

html - CSS : : 试图让部分/div 的高度匹配....一个没有 img

swift - Swift 中从 UIButton (UIColor) backgroundColor 获取 RGB 颜色

css - textarea 没有收到后代 CSS 属性

javascript - 固定 div 内的相对 div

html - 是什么导致了 flex 元素和 inline-block 元素的宽度差异?

iphone - colorWithPatternImage 与。界面 ImageView

android - 在保持线条颜色的同时设置 EditText 的背景