我有一个关于 Bootstrap 的问题。我想知道您是否可以让 style
HTML 代码在指定区域工作。我有这段代码,我希望下面的 CSS 代码只在这个 div 中工作。
HTML 代码:
<div style="position:relative;width:280px;">
<a class="pull-left" style="position:relative; margin: 4px 5px 0 0;">
<img class="avatar" src="https://minotar.net/avatar/mcname/32.png" player="mcname" size="32" width="32" height="32" style="width: 32px; height: 32px; vertical-align: bottom;" />
</a>
<a href="#" style="color: red"><b>Marcus</b></a>
<span class="label" style="background-color: green; color: white"><a href="#" class="nounderline">Owner</a></span>
<span class="label" style="background-color: purple; color: white"><a href="#" class="nounderline">Developer</a></span>
<span class="label" style="background-color: #FA0; color: white"><a href="#" class="nounderline">Staff</a></span>
<p><i>Posted Nov. 16'th, 2013</i></p>
</div>
CSS 代码:(我把它放在 style
的 HTML 代码中)
a {
color: inherit;
}
a:hover {
color: white
}
a:link {
color: #ffffff;
text-decoration: none
}
EDIT:
I've tried all the answers, but strange enough, they aren't working. In my head they looked like they were right, and they must have. I can't just get it to work. When I try the answers the links all around the page fade from white to it's normal color. I just want the div with the label span's to show links as white (also with hover), and everything else on the page as normal Bootstrap links. - Even thought it doesn't work for me, thanks to you guys for trying to help me!
最佳答案
你可以给父 div 一个 id,然后引用它的子 div。一个例子:
<div id="Parent">
<span>I should be given unique style!<span>
</div>
CSS:
#Parent span {
/* my style goes here */
}
关于html - CSS 内部区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20105053/