1

So I have the following code:

<b-card
  class="getting-started border-0"
  overlay
  img-src="https://images.unsplash.com/photo-1554386690-cc2d52c7f3d6?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1395&q=80"
  img-alt="Card Image"
  text-variant="white"
  title="Getting Started"
  sub-title="Where to begin?"
>
    <b-card-text>
          Some quick example text to build on the card and make up the bulk of the card's content.
    </b-card-text>
</b-card>

I would like to sytle the title inside b-card utilizing css. I haven't been able to find any way to access this element.

1
  • 1
    Style it how? And what have you tried so far yourself? Please add the styling code that doesn't work. Please read How to Ask a good question Commented Apr 15, 2021 at 6:53

3 Answers 3

2

You can give a custom class to b-card and then you need to write a simple css.

HTML

<b-card class="my-custom-class border-0"
  overlay
  img-src="https://images.unsplash.com/photo-1554386690-cc2d52c7f3d6?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1395&q=80"
  img-alt="Card Image"
  text-variant="white"
  title="Getting Started"
  sub-title="Where to begin?"
>
<b-card-text>
  Some quick example text to build on the card and make up the bulk of the card's content.
</b-card-text>
</b-card>

CSS

.my-custom-class .card-title {
   background-color: red;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help! this will be very helpful
2

title = "" Doesn't apply to CSS

use v-bind:title="nameTitle"for dynamic change title

or

It is often a good idea to bind to a style object

<div v-bind:style="styleObject"></div>

data: {
  styleObject: {
    color: 'red',
    fontSize: '13px'
  }
}

The object syntax is often used in conjunction with computed properties that return objects.

1 Comment

Interesting... Thanks for the help I am kinda new to front-end but this is very helpful
1

CSS classes. You can put the element in a CSS class, then apply the desired styles on the class.

<b-card class="getting-started border-0"
  overlay
  img-src="https://images.unsplash.com/photo-1554386690-cc2d52c7f3d6?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1395&q=80"
  img-alt="Card Image"
  text-variant="white"
  title="Getting Started"
  sub-title="Where to begin?"
>
<b-card-text class="red-sample">
  Some quick example text to build on the card and make up the bulk of the card's content.
</b-card-text>
</b-card>

...

<style>
.red-sample {
  color: red;
}
</style>

1 Comment

The item that I want to access it's b-card title="Getting Started". Sorry for not clarifying that in question, can I add a css selector for that title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.