HTML 和 CSS 文本换行,某些元素的样式与其他元素不同

标签 html css

我想要一个固定宽度的容器,标签需要有不同的样式,但要包裹在容器内。有什么想法吗?

div {
  width: 200px;
  background-color: rgba(0,0,0,0.6);
  margin: 10px;
  padding: 10px;
}
p {
  margin: 0px;
  color: white;
  font-family: sans-serif;
  font-weight: 100;
}
p:nth-child(1) {
  font-weight: 600;  
}
<div>
  <p>This Text in BOLD.</p>
  <p>And we want this in normal weight but we want it to wrap as it is doing in the second example.</p>
</div>
<div>
  <p>This Text in BOLD. And we want this in normal weight but we want it to wrap as it is doing in the second example.</p>
</div>

最佳答案

div {
  width: 200px;
  background-color: rgba(0,0,0,0.6);
  margin: 10px;
  padding: 10px;
}
p{
  margin: 0px;
  color: white;
  font-family: sans-serif;
  font-weight: 100;      
}
span {
  font-weight: 600;
}
<div>
  <p><span>This Text in BOLD.</span> And we want this in normal weight but we want it to wrap as it is doing in the second example.</p>
</div>

关于HTML 和 CSS 文本换行,某些元素的样式与其他元素不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40173851/

相关文章:

css - slider 中的响应图像

javascript - 下拉菜单不粘在 LI Parent 上

jquery - 100% 高度 div 不会滚动

html - 打破文本行以提高响应能力

html - 固定标题不会随正文水平滚动

html - 如何在CSS中使用视频作为文本背景

html - div 的全高

html - 为什么我的网站在移动 View 中有水平滚动条?

html - 在 CSS 中定义图像,而不是在 HTML 中

html - 删除 <form> 提交按钮中的蓝色边框