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

グリッドレイアウトで<HR>が表示されない問題

Posted at

どこ行った、水平線

グリッドレイアウトで、<hr>が表示されない!

image.png

↓コード(抜粋)

index.html
<body>
  <div>A</div>
  <div>B</div>
  <hr>
  <div>C</div>
  <div>D</div>
</body>
style.css
body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
hr {
  grid-column: span 2;
}

...ん?

image.png

...んんん?

image.png

点!
何てこったい、幅指定だ。

style.css
body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
hr {
  grid-column: span 2;
  width: 100%;
}

image.png

あっさり解決ですね。

全部、画質の粗いリモデが悪いんだ。(ただの難癖)

おまけ

間違ってheightやgrid-template-rowsを指定すると、horizonのくせに、垂直線になるよ。

style.css
body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 100px auto;
}
hr {
  grid-column: span 2;
}

image.png

以上。

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?