1
0

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.

背景画像について

Posted at

今日はprogeteをやって出てきたCSSについての備忘録として記事を書いていこうと思います。

背景画像を指定する

CSSで背景画像を設定するには  
background-imageを使用する。

stylesheet.css
div {
    background-image: url(top.png);
}

これで背景画像の挿入はできました。

背景画像の大きさを指定する

background-imageで指定された背景画像は表示範囲を埋め尽くすまで繰り返し表示される性質があります。

そこで、、、
background-size: cover;
を指定してあげると1枚の画像で表示範囲を埋め尽くすように画像の大きさが拡大縮小してくれます。

stylesheet.css
div {
    heigth: 200px
    background-image: url(top.png);
    background-size: cover;
}

これで画像の配置は完了しました。

今回はここまで!
ありがとうございました。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?