Vuetify.js:如何在v卡的v-img组件的右上方显示文本?

时间:2018-11-02 08:34:26

标签: javascript css vue.js vuetify.js

在Vuetify.js中,我想在v卡图片的右侧显示一个单词文字:

<v-card>
   <v-img 
        rc="https://cdn.vuetifyjs.com/images/cards/desert.jpg"
        aspect-ratio="2.75">
        <span class="my-span">
          Info
        </span>
   </v-img>
</v-card>

但这是我得到的结果:

enter image description here

即使my-spanmargin-right:0;

.my-span {
  background-color:blue;
  color:white;
  font-weight:bold;
  margin-right:0;
}

该如何解决?

Codepen

1 个答案:

答案 0 :(得分:0)

在CSS中使用float: right;

new Vue({
  el: '#app'
})
.my-span {
  background-color: blue;
  color: white;
  font-weight: bold;
  margin-right: 0;
  float: right;
}
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@1.3.5/dist/vuetify.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vuetify@1.3.5/dist/vuetify.min.css" />
<div id="app">
  <v-app id="inspire">
    <v-layout>
      <v-flex xs12 sm6 offset-sm3>
        <v-card>
          <v-img src="https://cdn.vuetifyjs.com/images/cards/desert.jpg" aspect-ratio="2.75">
            <span class="my-span">
              Info
            </span>
          </v-img>
        </v-card>
      </v-flex>
    </v-layout>
  </v-app>
</div>