[英]How Do I create two CSS Classes and prevent line break
I have the following 2 HTML statements. 我有以下2 HTML语句。 I want the "p" tag to NOT wrap to the next line.
我希望“ p”标签不换行到下一行。 But I do want it to wrap in subsequent lines.
但我确实希望它包含在后面的行中。 (so I can't use the nowrap style).
(所以我不能使用nowrap样式)。 I want to create two CSS classes to treat each class differently.
我想创建两个CSS类来分别对待每个类。
<b class= "mscFlapSumBold" id='flapSum0'>This is the Flap Summary</b>
<p class= "mscFlapText" id='flap0'>This is the Flap text </p>
EDIT: 编辑:
OK. 好。 I'm using James suggestion and it's working except that I can't seem to change the line spacing between my lines.
我正在使用James建议,并且它工作正常,只是我似乎无法更改行之间的行距。 When I use margin or line-height, they get ignored.
当我使用边距或行高时,它们将被忽略。 So, James' suggested code is working mostly....
因此,James建议的代码大部分都在起作用。
<p>
<strong class="mscFlapSumBold" id="flapSum0">...</strong>
<span class="mscFlapText" id="flap0">...</span>
</p>
Furthur edit: My issue surrounds the fact that I am using jQuery Mobile. 进一步编辑:我的问题围绕着我正在使用jQuery Mobile的事实。 So, depending on the viewport, your solution works only sometimes (with certain viewports).
因此,根据视口,您的解决方案仅在某些情况下(对于某些视口)有效。 Driving me CRAZY.
快把我逼疯。 If you have any ideas, I would sure appreciate them.
如果您有任何想法,我将不胜感激。
Simply wrap both in the same p
element and place .mscFlapText
within a span
instead: 只需将它们包装在同一个
p
元素中,然后将.mscFlapText
放在一个span
内即可:
<p>
<strong class="mscFlapSumBold" id="flapSum0">...</strong>
<span class="mscFlapText" id="flap0">...</span>
</p>
It's worth noting that the specification defines p
as Grouping Content and b
is Text-level Semantics ; 值得注意的是, 规范将
p
定义为分组内容 , b
定义为文本级语义 ; they aren't designed to go inline with each other. 它们并非旨在彼此内联。
You can use: 您可以使用:
p.mscFlapText {
display: inline;
}
But actually, you should use <span>
instead, better not mess up with default behaviour of HTML element. 但是实际上,您应该改用
<span>
,最好不要弄乱HTML元素的默认行为。
Besides that, a good habit and small tip is to use <strong>
rather than <b>
since it's can improve your SEO ranking. 除此之外,一个好习惯和一个小技巧是使用
<strong>
而不是<b>
因为它可以提高您的SEO排名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.