Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add link style for <a> in Bootstrap 4 Alpha 3?

The code is very simple:

<a>This is a link</a>

In Bootstrap 4 Alpha 2 demo, the link shows blue. When you hover mouse on it, it shows dark blue.

But in Bootstrap 4 Alpha 3 demo, it shows black.

Is there any special Bootstrap class can be added to let <a> have link style in Bootstrap 4 Alpha 3?

Something like this?

<a class="bootstrap-link">This is a link</a>

Is there any clean/smart way?

Thanks

like image 437
Hongbo Miao Avatar asked Jul 27 '16 23:07

Hongbo Miao


People also ask

How do I link Bootstrap card?

Titles, text, and links In the same way, links are added and placed next to each other by adding .card-link to an <a> tag. Subtitles are used by adding a .card-subtitle to a <h*> tag. If the .card-title and the .card-subtitle items are placed in a .card-body item, the card title and subtitle are aligned nicely.


2 Answers

Probably something changed between the two versions regarding the existence of the href attribute; by adding the attribute href to the anchor <a>, it starts to work properly;

Code from the example with href:

<a href>This is a link</a>

Updated JSFiddle: https://jsfiddle.net/s1mvqok0/

like image 175
Pedro Moreira Avatar answered Oct 18 '22 09:10

Pedro Moreira


If you see bootstrap 4 css

a:not([href]):not([tabindex]) {
    color: inherit;
    text-decoration: none;
}

So anchor tag gets the color of its parent element if it does not have either an href or tabindex attribute. One approach would be to provide a tabindex for the a element.

There is a class if you want to use .text-primary that applies primary color to the anchor tag.

.text-primary{
   color:#0275d8!important
}
a.text-primary:focus,a.text-primary:hover{
   color:#025aa5
}

jsfiddle

like image 30
tmg Avatar answered Oct 18 '22 07:10

tmg