最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Vuetify.js: how to display text on the top right of a v-card' v-img component? - Stack Overflow

programmeradmin0浏览0评论

In Vuetify.js, I want to display a one word text on the right side of a v-card image:

<v-card>
   <v-img 
        rc=".jpg"
        aspect-ratio="2.75">
        <span class="my-span">
          Info
        </span>
   </v-img>
</v-card>

But this is the result I get:

Even if my-span says margin-right:0;:

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

How to fix this?

Codepen.

In Vuetify.js, I want to display a one word text on the right side of a v-card image:

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

But this is the result I get:

Even if my-span says margin-right:0;:

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

How to fix this?

Codepen.

Share Improve this question asked Nov 2, 2018 at 8:34 Billal BEGUERADJBillal BEGUERADJ 22.8k45 gold badges123 silver badges140 bronze badges 1
  • 1 Use absolute positioning. Updated Codepen: codepen.io/anon/pen/JePOOg – m4n0 Commented Nov 2, 2018 at 8:37
Add a ment  | 

1 Answer 1

Reset to default 2

Use float: right; in your CSS:

new Vue({
  el: '#app'
})
.my-span {
  background-color: blue;
  color: white;
  font-weight: bold;
  margin-right: 0;
  float: right;
}
<script src="https://cdn.jsdelivr/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/vuetify.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr/npm/[email protected]/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./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>

发布评论

评论列表(0)

  1. 暂无评论