我有問題試圖用CSS替換此圖像,我無法訪問html。用CSS替換當前的html圖像
<img
width="64"
height="64"
border="0"
style="width: 64px; height: 64px;"
src="http://www.nitrografixx.com/2013/lock-icon.gif">
</img>
我想這一點,雖然它增加了圖像作爲背景,以當前的圖像,它不會取代它。
img[src='http://www.nitrografixx.com/2013/lock-icon.gif'] {
background: url(http://www.nitrografixx.com/2013/lock_bg.jpg) center !important;
}
而不是背景屬性,使用內容屬性。 –
你的代碼工作正常。你對CSS說'當他發現一個帶有'src'屬性的'img'元素作爲他的屬性值,然後將'img'元素的背景圖像更改爲你在他的'background CSS上的財產。您必須將'background'屬性更改爲'content' – DaGLiMiOuX
如果您有Javascript,那麼最好使用它代替CSS,因爲您可以直接訪問圖像並對其進行更改,而不是嘗試應用「內容」 '通過CSS的屬性。 –