Kolory / Colors

12 076 0
Sprawdź jak implementować kolory w najnopwszej wersji Bootstrapa 5. Kliknij tutaj aby zobaczyć przykłady oraz dowiedzieć się jak z nich skorzystać.

Czytając pozostałe wpisy na pewno natknęliście się na kolory zaimplementowane w Bootstrap. Z pomocą klas możemy zmieniać kolory tekstu, linków, buttonów, nadawać kolory teł itp.

Kolor tekstu

Dla tekstu mamy przygotowane kilkanaście klas. Nie będę ich tutaj wymieniał, myślę, ze przykład doskonale pokazuje o co z nimi chodzi.

Przykład

.text-primary

.text-secondary

.text-success

.text-danger

.text-warning

.text-info

.text-light

.text-dark

.text-body

.text-muted

.text-white

Kod


<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning">.text-warning</p>
<p class="text-info">.text-info</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-dark">.text-dark</p>
<p class="text-body">.text-body</p>
<p class="text-muted">.text-muted</p>
<p class="text-white bg-dark">.text-white</p>

Kolor linka

Tutaj sytuacja wygląda podobnie do kolorów tekstu. Różnica jest taka, że klasę odpowiadającą za kolor dodajemy do elementu <a> a nie do paragrafu.

Kod


<a href="#" class="text-primary">Primary link</a>
<a href="#" class="text-secondary">Secondary link</a>
<a href="#" class="text-success">Success link</a>
<a href="#" class="text-danger">Danger link</a>
<a href="#" class="text-warning">Warning link</a>
<a href="#" class="text-info">Info link</a>
<a href="#" class="text-light bg-dark">Light link</a>
<a href="#" class="text-dark">Dark link</a>
<a href="#" class="text-muted">Muted link</a>
<a href="#" class="text-white bg-dark">White link</a>

Kolor tła

Jak napisałem we wstępie, kolory możemy nadawać nie tylko tekstowi ale również tworzyć divy z tłem.

Przykład

.bg-primary
.bg-secondary
.bg-success
.bg-danger
.bg-warning
.bg-info
.bg-light
.bg-dark
.bg-white
.bg-transparent

Kod


<div class="bg-primary text-white">.bg-primary</div>
<div class="bg-secondary text-white">.bg-secondary</div>
<div class="bg-success text-white">.bg-success</div>
<div class="bg-danger text-white">.bg-danger</div>
<div class="bg-warning text-dark">.bg-warning</div>
<div class="bg-info text-white">.bg-info</div>
<div class="bg-light text-dark">.bg-light</div>
<div class="bg-dark text-white">.bg-dark</div>
<div class="bg-white text-dark">.bg-white</div>
<div class="bg-transparent text-dark">.bg-transparent</div>

Przydało się? Oceń proszę jak bardzo: SłaboJako takoNie ma źleDobrzeRewelacja! (5 głosów, średnia: 5,00 na 5)
Loading...

Chcesz coś napisać?

Podziel się swoją opinią bądź dodaj coś od siebie.

*

*