可视化右对齐按钮组

时间:2019-09-03 09:59:24

标签: javascript html vue.js vuetify.js

因此,我想在页面右侧显示一组按钮,但是justify-end / justify='end'v-row上不起作用。

<!DOCTYPE html>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/font@3.x/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>

<body>
  <div id="app">
    <v-app>
      <v-container>
        <v-form>
          <v-row justify='end'>
            <v-col>
              <v-btn>Button 1</v-btn>
              <v-btn>Button 1</v-btn>
              <v-btn>Button 1</v-btn>
            </v-col>
          </v-row>
        </v-form>
      </v-container>
    </v-app>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
  <script>
    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
    })
  </script>
</body>

我看过this问题,但是使用文本对齐似乎很麻烦,我想知道是否有更好的解决方案?

2 个答案:

答案 0 :(得分:3)

text-right类添加到<v-col>

<v-col class="text-right">
  <v-btn>Button 1</v-btn>
  <v-btn>Button 1</v-btn>
  <v-btn>Button 1</v-btn>
</v-col>

答案 1 :(得分:1)

在不更改网格系统的情况下,尝试添加<spacer/>组件,以便将v-col放在行末:

<!DOCTYPE html>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/font@3.x/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>

<body>
  <div id="app">
    <v-app>
      <v-container tag="div">

        <v-form>
          <v-row justify="end">
            <spacer/>
            <v-col>
              <v-btn>Button 1</v-btn>
              <v-btn>Button 1</v-btn>
              <v-btn>Button 1</v-btn>
            </v-col>
          </v-row>
        </v-form>

      </v-container>
    </v-app>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
  <script>
    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
    })
  </script>
</body>