简体   繁体   English

CSS - 在句子中使用多个 css 类

[英]CSS - Using multiple css classes in sentence

 .dot { height: 12px; width: 12px; background-color: red; border-radius: 50%; display: inline-block; }.red-tag { color: red; font-weight: bold; }
 <div> <p>Online sales this quarter were</p> <div class="dot" /> <p class="red-tag">HIGH</p> <p>Predictions indicate sales will continue to rise.</p> </div>

I am attempting to write a sentence using different css classes.我正在尝试使用不同的 css 类写一个句子。 At the moment I am having issues keeping them all in-line.目前,我在让它们保持一致时遇到问题。 I am expecting the outcome of the sentence to flow in one sentence just like:我期待这句话的结果在一句话中流动,就像:

Online sales this quarter were (css dot) HIGH.本季度的在线销售额(css dot)很高。 Predictions indicate sales will continue to rise.预测表明销售额将继续上升。

Currently, after adding a the .dot tag;目前,在添加.dot标签后; it shows on the line below and due to the inline block it affects the sentence after it.它显示在下面的行中,由于 inline 块,它会影响它后面的句子。 I am attempting to have it all sitting in one line.我正试图将它们全部排成一行。 I've tried accomplishing this by wrapping my sentence in a div tag;我已经尝试通过将我的句子包装在div标签中来实现这一点; as well as switching <span class="dot"> to <div class="dot"/> which ended up giving me the same result.以及将<span class="dot">切换到<div class="dot"/>最终给了我相同的结果。

Don't use a <p> tag to mark up something that isn't a paragraph.不要使用<p>标记来标记不是段落的内容。
You should use the <span> tag (which is a generic inline contar) instead of <p> .您应该使用<span>标记(这是一个通用的内联 contar)而不是<p>

 .dot { height: 12px; width: 12px; background-color: red; border-radius: 50%; display: inline-block; }.red-tag { color: red; font-weight: bold; }
 <div> <span>Online sales this quarter were</span> <span class="dot"></span> <span class="red-tag">HIGH</span> <span>Predictions indicate sales will continue to rise.</span> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM