Değişkenleri Kullanım Örnekleri(Scss ile import olarak)
Değişken Nedir
"değişken", bir değeri (renk, yazı boyutu, boşluk vs.) tek bir yerden tanımlayıp her yerde kullanmamızı sağlar. Böylece aynı değeri tekrar tekrar yazmak yerine, sadece değişken adını yazarız. Sonradan değiştirmek çok kolay olur.
Değişken Kod Örnekleri
Değişken Kod Örnekleri
$primary: $blue;
$secondary: $gray-600;
$success: $green;
$info: $cyan;
$warning: $yellow;
$danger: $red;
$light: $gray-100;
$dark: $gray-900;
$border-radius: .25rem;
$border-width: 0;
Değişkenleri Nasıl Özelleştiririz?
Bootstrap'de class olarak kullandığımız özellikler aslında birer değişken olarak tanımlanmıştır. Bu özellikleri kullanabilmek için bootstrap'in sayfasında anlattığı adımları uygulayarak biz de projemizde değişkenlere kendi stillerimizi tanımlayabiliriz.
Değişkenlerin kullanımı için bu sayfayı inceleyelim.
Bootstrap'in standart background tanımlamaları
Yeni Renkler Tanımlamaları Örnek
Değişkenlerin kullanımı için bu sayfayı inceleyelim.
Bootstrap'in standart background tanımlamaları
Yeni Renkler Tanımlamaları Örnek
$custom-colors: (
"brand": #5c3d99,
"light-blue": #00d2ff,
);
$theme-colors: map-merge($theme-colors, $custom-colors);
Bootstrap içerisinde tanımlı olan light ve dark temalar mevcut.
Eğer istersek bizde bunlara ek olarak tema ekleyebiliriz. Örneğin;
// Required
@import "functions";
@import "variables";
@import "variables-dark";
// Add a custom color to $theme-colors
$custom-colors: (
"custom-color": #712cf9
);
$theme-colors: map-merge($theme-colors, $custom-colors);
@import "maps";
@import "mixins";
@import "utilities";
// Add a custom color to new theme maps
// Light mode
$custom-colors-text: ("custom-color": #712cf9);
$custom-colors-bg-subtle: ("custom-color": #e1d2fe);
$custom-colors-border-subtle: ("custom-color": #bfa1fc);
$theme-colors-text: map-merge($theme-colors-text, $custom-colors-text);
$theme-colors-bg-subtle: map-merge($theme-colors-bg-subtle, $custom-colors-bg-subtle);
$theme-colors-border-subtle: map-merge($theme-colors-border-subtle, $custom-colors-border-subtle);
// Dark mode
$custom-colors-text-dark: ("custom-color": #e1d2f2);
$custom-colors-bg-subtle-dark: ("custom-color": #8951fa);
$custom-colors-border-subtle-dark: ("custom-color": #e1d2f2);
$theme-colors-text-dark: map-merge($theme-colors-text-dark, $custom-colors-text-dark);
$theme-colors-bg-subtle-dark: map-merge($theme-colors-bg-subtle-dark, $custom-colors-bg-subtle-dark);
$theme-colors-border-subtle-dark: map-merge($theme-colors-border-subtle-dark, $custom-colors-border-subtle-dark);
// Remainder of Bootstrap imports
@import "root";
@import "reboot";
// etc
dökümantasyona git
Scss Entegrasyon Örneği
CSS Kodu
// Bootstrap'in Sass dosyalarını dahil etmeden önce değişkenleri özelleştir
$grid-columns: 24; // Grid sütun sayısını 24 olarak ayarlayın
$enable-negative-margins: true; // Negatif marginleri etkinleştirin
$primary:#14183f;// bootstrap'in mavi olarak gelen primary renk kodunu değiştirir
$enable-gradients:true;
@import 'bootstrap/scss/bootstrap'; //değişkenleri tanımladıktan sonra dosyamızın içerisine entegre ettiğimiz bootstrap i scss dosyamıza import ediyoruz.
//Eğer bu import ettiğimiz css dosyasını değişkenlerin üzerinde tanımlarsak özelleştirdiğimiz değerler geçerli olmayacaktır