我對圖像幀樣式:更改圖像的不透明度和鼠標懸停上添加鏈接背景就可以了
在一個地方,我的工作項目.frame {
background:#efefef;
border:1px solid #f6f6f6;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.4); /* @todo Old Browsers Fix */
margin-bottom:15px;
padding:4px;
}
,我有以下的HTML代碼:
<a href="#" class="preview">
<img class="frame" src="http://placehold.it/288x159" alt="" />
</a>
基本上,我想更改鼠標懸停上的文件不透明度並向鏈接添加背景(預覽圖標)。我有以下代碼:
.preview img.frame {
margin:0;
position:relative;
}
.preview:hover {
background:url('../img/icon_zoom.png') center center no-repeat;
display:inline-block;
z-index:40;
}
.preview img { /* @todo Add different browsers rules */
opacity: 1;
/*moz-transition-property:opacity;
-moz-transition-timing-function:ease-out;
-moz-transition-duration:500ms;*/
-moz-transition:opacity 1s ease-in-out;
}
.preview:hover img {
opacity:.5;
-moz-transition:opacity 1s ease-in-out;
/*-moz-transition-property:opacity;
-moz-transition-duration:500ms;
-moz-transition-timing-function:ease-out;*/
display:block;
position:relative;
z-index:-1;
}
但是我面臨幾個問題: - 我該怎麼讓背景只圖像體(目前它也顯示在邊境)? - 爲什麼不在Chrome中更改不透明度?
jsFiddle添加。正如你所看到的,它可以在FF中運行,但不能在Chrome中運行。
請問我們有[jsFiddle](http://jsfiddle.net/)嗎? – Ryan 2012-02-26 18:39:55
@minitech - 當然,添加它。 – DaveW 2012-02-26 18:50:15
'-moz'前綴僅針對Firefox。你還需要找到'-webkit'規則。 – Blender 2012-02-26 18:57:35