現(xiàn)在有很多網(wǎng)站用了css3新特性,切換背景圖的時(shí)候會(huì)有一個(gè)時(shí)間的過度,我們?cè)谧銎瞻铐?xiàng)目的時(shí)候也用到了這個(gè)過渡:
在做這個(gè)導(dǎo)航的時(shí)候,鼠標(biāo)劃過去切換背景會(huì)有一個(gè)過度,那么它是怎么實(shí)現(xiàn)的呢:
.nav li{display:block;vertical-align: middle;-webkit-transform: translateZ(0);transform: translateZ(0);box-shadow: 0 0 1px rgba(0, 0, 0, 0);-webkit-backface-visibility: hidden;backface-visibility: hidden;-moz-osx-font-smoothing: grayscale;position: relative; background: url(../images/nav-bg.jpg) no-repeat center right;-webkit-transition-property: color;transition-property: color;-webkit-transition-duration: 0.3s;transition-duration: 0.3s; } .nav li:before {content: "";position: absolute;z-index: -1;top: 0;bottom: 0;left: 0;right: 0;background:#14a9f0;-webkit-transform: scaleX(0);transform: scaleX(0);-webkit-transform-origin: 50%;transform-origin: 50%;-webkit-transition-property: transform;transition-property: transform;-webkit-transition-duration: 0.3s;transition-duration: 0.3s;-webkit-transition-timing-function: ease-out;transition-timing-function: ease-out; }
必須得寫全,告訴瀏覽器需要這樣去執(zhí)行,這樣就實(shí)現(xiàn)背景色的過渡了