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

【CSS】position: fixed の使い方

Posted at

基本的な使い方

ある要素を画面に固定配置する際に使用される。

<固定ヘッダーの例>

<header>
  <div class="container">
  <p>これはヘッダーです。</p>
  </div>
</header>
.header {
/*ヘッダーを上部に固定*/
  position: fixed
  top: 0;
}

z-indexについて

position: fixedと併用して使用する。
要素同士の重なり順を指定する。

.header {
/*ヘッダーを上部に固定*/
  position: fixed
  top: 0;
  /*数字が大きいほうが上のレイヤーになる*/
  z-index: 10;
}

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