javascript Vuetify.js:如何在左侧和右侧的 v-card 中放置按钮动作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53043799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 10:05:32  来源:igfitidea点击:

Vuetify.js: how to place button actions in v-card on left and right?

javascriptvue.jsvuetify.js

提问by Billal Begueradj

In v-card-actionscomponent of v-card, I want to place one button on the left and the other on the right using mr-0(margin-right= 0), but the 2 buttons always stay close to each other.

在 的v-card-actions组件中v-card,我想使用mr-0(margin-right= 0)将一个按钮放在左侧,另一个放在右侧,但 2 个按钮始终彼此靠近。

What I tried:

我试过的:

  • Prop leftand rightfor the buttons
  • v-spacercomponent between the buttons
  • 道具leftright按钮
  • v-spacer按钮之间的组件

Code:

代码:

<v-card>
  <v-card-title primary-title>
    <div>
      <h3 class="headline mb-0">Ttile</h3>
      <div>Located two hours south of Sydney in the <br>Southern Highlands of New South </div>
    </div>
  </v-card-title>

  <v-card-actions>
    <v-btn left>Share</v-btn>
    <v-spacer />
    <v-btn right>Explore</v-btn>
  </v-card-actions>
</v-card>

Codepen.

代码笔

How to solve this?

如何解决这个问题?

回答by roli roli

Your code is correct. Just use this:

你的代码是正确的。只需使用这个:

      <v-card-actions>
        <v-btn>Share</v-btn>
        <v-spacer></v-spacer>
        <v-btn>Explore</v-btn>
      </v-card-actions>

So just change the v-spacerto not be self-enclosing tag.

因此,只需将 更改v-spacer为非自封闭标签即可。

回答by Toodoo

Just wrap them in v-flexand add text-xs-rightclass to the second, to pull to the right the second button.

只需将它们包裹起来v-flex并将text-xs-right类添加到第二个,将第二个按钮拉到右侧。

<v-card-actions>
    <v-flex>
      <v-btn>Share</v-btn>
    </v-flex>
    <v-flex class="text-xs-right">
      <v-btn>Explore</v-btn>
    </v-flex>
</v-card-actions>

CodePen

代码笔



Edit Vuetify 2.1.0(thanks to @J. Unkrass) :

编辑 Vuetify 2.1.0(感谢@J. Unkrass):

Just wrap them in v-coland add text-rightclass to the second, to pull to the right the second button.

只需将它们包裹起来v-col并将text-right类添加到第二个,将第二个按钮拉到右侧。

<v-card-actions>
    <v-col>
      <v-btn>Share</v-btn>
    </v-col>
    <v-col class="text-right">
      <v-btn>Explore</v-btn>
    </v-col>
</v-card-actions>