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?

More than 1 year has passed since last update.

【TailwindCSS】lg.hiddenの挙動について

Posted at

はじめに

画面を最大化した時にメニューボタンが表示されなくなったので、いろいろ調べていました。

原因としては、buttonのクラスに「lg:hidden」を設定したのが原因でした。

環境

Laravel 9.52.16
Tailwind CSS 3.1.0

問題

  • 期待する表示画面

c054bdb7033e76bd4386cf810d9e812a.png

  • 画面を最大化すると右上の「ゲスト」が消える

6b765728bebdc4b8be9e197436dd43c5.png

ちなみにこの「ゲスト」部分のボタンはこのような記述。

navbar.blade.php
<button type="button" tabindex="0" class="btn btn-ghost normal-case font-normal lg:hidden">

解決法

  • buttonの「lg:hidden」クラスを削除する
navbar.blade.php
<button type="button" tabindex="0" class="btn btn-ghost normal-case font-normal"> // 'lg:hidden'を削除

今回の「画面を最大化するとボタンが見えなくなる」問題は、やはりレスポンシブデザインの設定に関連していました。

具体的にはlg:hiddenというクラスが原因となっています。

このlg:hiddenクラスは、画面の幅がlg(large)ブレークポイント以上になったときに、要素を非表示にするためのものです。

したがって解決策として、lg:hiddenクラスを削除することが正解となります。

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?