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 3 years have passed since last update.

【CSS】背景固定のパララックスデザインをお手軽に実装する方法

Last updated at Posted at 2021-07-06

概要

backgroundプロパティをいくつか指定するだけ背景固定のパララックスデザインを実装できます。

前提

今回は背景は動かさず固定が前提です。

サンプルコード


<div class="parallax"></div>

<style>
.parallax {
  /* 基本設定 */
  background-image: url('指定画像パス');
    background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  height: 300px;
  width: 100%;

  /* パララックス用設定 */
    background-attachment: fixed;
}
</style>

参考記事

パララックスデザインとは
https://saruwakakun.com/html-css/reference/parallax

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?