0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

css: backgroundに画像と背景色を指定したい

Posted at

やりたいこと

backgroundで画像を表示させながら、背景色で透過させたいみたいな時にハマったやつ

無理①

これでうまくいった記事多くあるがなぜかうまくいかない
backgroundのショートハンドでかく

background: rgba(#000, 0.5) url("画像URL") no-repeat center;

無理②

まぁ無理

background-image: url("画像のURL");
background: rgba(#000, 0.5);

解決法

liner-gradientつければうまく表示できた

background: linear-gradient(rgba(#000, 0.5), rgba(#000, 0.5)),
    url("画像URL") no-repeat center;
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?