html - CSS - 在句子中使用多个 CSS 类
问题描述
.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>
我正在尝试使用不同的 css 类写一个句子。目前,我在让它们保持一致时遇到问题。我期待这句话的结果在一句话中流动,就像:
本季度的在线销售额(css dot)很高。预测表明销售额将继续上升。
目前,添加.dot
标签后;它显示在下面的行中,由于 inline 块,它会影响它后面的句子。我正试图把它全部放在一条线上。我已经尝试通过将我的句子包装在div
标签中来实现这一点;以及切换<span class="dot">
到<div class="dot"/>
哪个最终给了我相同的结果。
解决方案
不要使用<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>
推荐阅读
- google-bigquery - 使用 Google bigquery 将查询结果导出到云存储中的输出文件
- php - 尝试使用 php 访问 json 数组数据
- python - 在 Flask 中提供图像后删除图像
- excel - 求解器的 VBA 循环
- unity3d - 如何使用 Unity3D 中的字符控制器通过按钮 UI 跳转
- c# - 当我尝试使用以管理员 C# 运行的特定位置终止进程时访问被拒绝
- sdk - Yocto 将自己的 Header 和 Lib 文件添加到 sdk
- php - PHP Mail 函数
在我的消息链接中间添加一个 - php - 在 laravel Postgresql 中将文件图像上传并保存为 Bytea 数据类型
- python - OpenCV Python中的轨迹栏大小和值错误