最近在寫css的時候遇到了一些關於background設定的問題。當乙個div中要設定背景圖和背景色的時候,某些時候背景色會覆蓋掉背景圖。
測試佔位
.bg_color
.txt
.bg_color
.txt
情況3:設定和情況2相同,只是順序反了一下,背景色覆蓋了背景圖
.bg_color
.txt
.bg_color
.txt
情況5:設定和情況4相同,只是順序反了一下。只顯示了背景圖,沒有顯示背景色
.bg_color
.txt
情況6:設定了background-image和background-color,背景色覆蓋了背景圖。
.bg_color
.txt
情況7:設定和情況6相同,只是順序反了一下。背景色覆蓋了背景圖。
.bg_color
.txt
總結:background具有高優先順序,background-color比background-image具有高優先順序。使用時要注意先後順序。
關於background定位
直到剛剛我才發現我小瞧了background定位 因為專案裡需要顯示隱藏的按鈕上有兩個圖示 開始想了幾種方法都不行,然後突然就想到了background定位 果斷試了一下 1 input type button class layui display 1 value 顯示 1 顯示隱藏 2 layu...
CSS之背景設定background
1 background color的六種表示方法 background color rgb 0255,0255,0 255 rgb表示 紅 綠 藍 background color rgba 0255,0255,0255,01 rgb表示 紅 綠 藍 最後乙個表示透明度。background co...
設定行背景 CSS 背景 background
css 可以新增背景顏色和背景,以及來進行設定。background color 背景顏色 background image 背景位址 background repeat 是否平鋪 background position 背景位置 background attachment 背景固定還是滾動 背景的...