< button>背景图 [英] <button> background image
问题描述
我有一个问题,为< button>
设置背景图片。
我已经在网站上的html:
< button id =rockonClick =choose(1)&摇滚< / button>
这里是CSS:
按钮{
font-size:18px;
border:2px solid#AD235E;
border-radius:100px;
width:150px;
height:150px;
}
按钮#rock {
background:url(img / rock.png)no-repeat;
}
我不知道为什么按钮的背景仍然是白色的。
令人惊讶的是,没有答案在这里解决或提及实际问题。
CSS选择器按钮#rock
说:给我一个元素 rock
里面 < button>
元素,如下所示:
< button>
< span id =rock>此元素将受到影响。< / span>
< / button>
但你想要的是 由于@Greg已经提到: I have got a little problem with setting a background image for Here is the html I have got on site: And here is the CSS: I don't know why the button's background is still white. Astonishing that no answer addresses or mentions the actual problem here. The CSS selector But what you wanted is a And as @Greg already mentioned: 这篇关于< button>背景图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< button>
元素与标识 rock
。而选择器将是 button#rock
(注意按钮 / p>
#rock
已经足够专门定位按钮, <button>
. <button id="rock" onClick="choose(1)">Rock</button>
button {
font-size: 18px;
border: 2px solid #AD235E;
border-radius: 100px;
width: 150px;
height: 150px;
}
button #rock {
background: url(img/rock.png) no-repeat;
}
button #rock
says "give me an element with the id rock
inside a <button>
element", like this:<button>
<span id="rock">This element is going to be affected.</span>
</button>
<button>
element with the id rock
. And the selector for that would be button#rock
(note the missing space between button and #rock).#rock
is already specific enough to target the button and could be used on its own.