LoginSignup
8
7

More than 3 years have passed since last update.

【Vuetify】<v-spacer>を使っていて画面の横揺れが発生したら<v-container>の不足を疑おう

Posted at

はじめに

Vuetifyを使って開発をしていて、
「なぜか画面の横スクロールが発生するな」
と思って調べたときの記録です。

画像でいうと右端の余白です。
こいつのせいでガタガタするので、除去します。

image.png

環境

OS: macOS Catalina 10.15.1
Vue: 2.6.10
vuetify: 2.1.0

結論:<v-spacer>には<v-container>が必須

そのまんまです。

何かの変更の際に、誤って<v-container>から<div>に変更してしまったようで、それから横揺れが発生していました。

:x:<div>で囲われている

<template>
  <div>
    <v-row>
      <div></div>
      <v-spacer></v-spacer>
      <div></div>
    </v-row>
  </div>
</template>

:o:<v-container>で囲われている

<template>
  <v-container>
    <v-row>
      <div></div>
      <v-spacer></v-spacer>
      <div></div>
    </v-row>
  </v-container>
</template>

<v-spacer><v-contaniner>の横幅を基準にして余白計算を行うので、<div>だと今回のようにはみ出す現象が発生するんですねー:sweat_smile:

おわりに

最後まで読んで頂きありがとうございました:bow_tone1:

どなたかの参考になれば幸いです:relaxed:

参考にさせて頂いたサイト(いつもありがとうございます)

8
7
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
8
7