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?

【Laravel】Debugbarを使用すると下部に空白が生まれる

Posted at

これ

image.png

直し方

調べてみると Debugbar が勝手に margin を追加してるみたい

image.png

app.blade.php にて body タグにマージン0を埋め込もう

resources/views/app.blade.php
  <!DOCTYPE html>
  <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
      <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">

          <title inertia>{{ config('app.name', 'Laravel') }}</title>

          <!-- Fonts -->
          <link rel="preconnect" href="https://fonts.bunny.net">
          <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

          <!-- Scripts -->
          @routes
          @vite(['resources/js/app.ts', "resources/js/Pages/{$page['component']}.vue"])
          @inertiaHead
      </head>
-     <body class="font-sans antialiased">
+     <body class="font-sans antialiased !m-0">
          @inertia
      </body>
  </html>

追加調査

更に調査すると、このマージンは php-debugbar のもので、スクリプトで制御できるみたい

resources/views/app.blade.php
  <!DOCTYPE html>
  <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
      <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">

          <title inertia>{{ config('app.name', 'Laravel') }}</title>

          <!-- Fonts -->
          <link rel="preconnect" href="https://fonts.bunny.net">
          <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

          <!-- Scripts -->
          @routes
          @vite(['resources/js/app.ts', "resources/js/Pages/{$page['component']}.vue"])
          @inertiaHead
      </head>
      <body class="font-sans antialiased">
          @inertia
          
+         @if (config('app.debug'))
+             <script>
+                 PhpDebugBar.DebugBar.prototype.recomputeBottomOffset = () => {};
+             </script>
+         @endif
      </body>
  </html>

こっちのほうが綺麗かも

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?