Bootstrap 4中的navbar-toggler-icon
(漢堡包)使用SVG background-image
。有2個「版本」的觸發器圖標圖像。一個用於導航欄光,以及一個用於暗(逆)導航欄...
// this is a black icon with 50% opacity
.navbar-light .navbar-toggler-icon {
background-image: url("data:image/svg+xml;..");
}
// this is a white icon with 50% opacity
.navbar-inverse .navbar-toggler-icon {
background-image: url("data:image/svg+xml;..");
}
所以,如果你想這個圖像的顏色更改爲別的東西,你可以自定義圖標。例如,在這裏,我將RGB值設置爲粉紅色(255,102,203)。注意在SVG數據的stroke='rgba(255,102,203, 0.5)'
值:
.custom-toggler .navbar-toggler-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,102,203, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
.custom-toggler.navbar-toggler {
border-color: rgb(255,102,203);
}
演示http://www.codeply.com/go/4FdZGlPMNV
OFC,另一個選擇只使用來自另一個庫,即一個圖標:字體真棒,等等。
Update Bootstrap 4.0.0:
從Bootstrap 4 Beta開始,navbar-inverse
現在爲navbar-dark
,可用於背景顏色較深的導航欄以產生較輕的鏈接和切換顏色。
代碼不是運行在bootply –