CSS Div 粗体和常规
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5419764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Div bold and regular
提问by Nick Kahn
I am not a css expert but still trying to learn the best way...
我不是 css 专家,但仍在努力学习最好的方法......
I have a div
and in that div I am showing a message and the first half message is bold and the second half the message is regular. Like this below
我有一个div
,在那个 div 中,我正在显示一条消息,前半部分消息是粗体,后半部分是常规消息。像下面这样
It's a bit complicated to get JSONP working with a simple WCF service.
让 JSONP 与简单的 WCF 服务一起工作有点复杂。
Luckily, there's some sample code on MSDN to do it for you; it's just not obvious how to take advantage of it. Here it is in 3 “easy” steps!
幸运的是,MSDN 上有一些示例代码可以为您完成;如何利用它并不明显。只需3个“简单”步骤!
My css is like this:
我的css是这样的:
#formmsg.text-success
{
color:black;
font-weight:bold;
margin:0px 0px 10px;
}
My question is, how can I use style for bold/regular or do I need to create another style for that?
我的问题是,如何将样式用于粗体/常规样式,还是需要为此创建另一种样式?
采纳答案by justkt
You can change the style on the fly using Javascript to change either the CSS or to change your class. So you could create another class that does not have a font-weight of bold and change classes. Or you can just change the font-weight: bold on the fly by itself. I'd lean towards another class as being more semantically correct in this case. How you do it depends on if you are using pure Javascript or a framework.
您可以使用 Javascript 动态更改样式以更改 CSS 或更改您的类。因此,您可以创建另一个没有粗体和更改类的字体粗细的类。或者您可以自行更改 font-weight: bold 。在这种情况下,我倾向于另一个类,因为它在语义上更正确。你怎么做取决于你是使用纯 Javascript 还是框架。
回答by alex
You could do this...
你可以这样做...
HTML
HTML
<p>It's a bit complicated to get JSONP working with a simple WCF service.</p>
<p>Luckily, there's some sample code on MSDN to do it for you; it's just not obvious how to take advantage of it.</p>
CSS
CSS
p:first-child {
font-weight: bold;
}
Note this won't work in IE6. You will also no doubt have many more p
elements on your page, so provide a parent element in the selector.
请注意,这在 IE6 中不起作用。毫无疑问p
,您的页面上还会有更多元素,因此请在选择器中提供一个父元素。
回答by callum.bennett
<p><b>It's a bit complicated to get JSONP working with a simple WCF service.</b></p>
<p>Luckily, there's some sample code on MSDN to do it for you; it's just not obvious how to take advantage of it. Here it is in 3 “easy” steps!</p>
OR
或者
<p class="bold">It's a bit complicated to get JSONP working with a simple WCF service.</p>
<p>Luckily, there's some sample code on MSDN to do it for you; it's just not obvious how to take advantage of it. Here it is in 3 “easy” steps!</p>
with css
用CSS
.bold{
font-weight:bold;}