イメージに透明な赤いオーバーレイを追加しようとしていますが、イメージにはtinted-image
クラスがあるときは、CSSでそれを行います。実際には、私はそれを直接img
タグに適用したいです。これは可能ですか?CSSでイメージ内にカラーレイヤーをオーバーレイする
私はこの試みた:
<img class="tinted-image" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/owl1.jpg"></img>
とCSS:
.tinted-image {
background:
/* top, transparent red */
linear-gradient(
rgba(0, 255, 0, 0.45),
rgba(0, 255, 0, 0.45)
)
}
を、何も起こりません。
私は以下のようにdivを使いたくありません。 これはimgタグで直接実装したいということです。
<div class="tinted-div"></div>
.tinted-div {
width:200px;
height:200px;
background:
/* top, transparent red */
linear-gradient(
rgba(0, 255, 0, 0.45),
rgba(0, 255, 0, 0.45)
),
/* bottom, image */
url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/owl1.jpg);
}
誰か助けてください。 :(
[オーバーレイせずにCSSを使用した色合いの画像]の可能な複製を(http://stackoverflow.com/question/12546499/tint-image-using-css-without-overlay) –