LoginSignup
2
4

More than 5 years have passed since last update.

position: absoluteで浮かせた要素を背面に表示する方法

Last updated at Posted at 2018-03-14

position: absolute;で浮かせた要素は、通常は前面に表示されます。

staticにはz-indeの指定はできないので、この重なりを背面に移動したい場合は、absoluteにした要素に対して、z-index: -1;を指定することで可能となります。
また、-1でなければならない理由はなく、指定可能な負の値であればよいです。

追記)
全面に表示したいものにrelativeを指定できる場合は指定して、z-indexで調整した方が簡単です。
ただ、relativeを指定することで基準が変更されてしまう場合は、こちらの方法を試していただければと思います。

2
4
2

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
2
4