html - H3随其内容延伸

标签 html css

我有一个包含内容的 h3。

喜欢enter image description here

然后我输入很多内容,就像

enter image description here

我使用的唯一CSS是:

color: rgb(255, 255, 255);
font-size: 16px;
height: 40px;
line-height: 16px;
padding-left: 20px;
padding-top: 14px;
background-color: rgba(158, 179, 195);

我需要的是 h3 将扩展内容并保持相同的样式( 就像文本位于中心,上面和下面有一些宽度

最佳答案

-> 输入较大内容时,可以删除一行内容的高度或设置最小高度

h3 {
  color: rgb(255, 255, 255);
  font-size: 16px;
  min-height: 20px;
  line-height: 20px;
  padding-left: 20px;
  padding: 14px;
  background-color: rgba(158, 179, 195);
}
<h3>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</h3>
<h3>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing.</h3>
<h3>Lorem Ipsum is simply dummy text of the printing.</h3>

关于html - H3随其内容延伸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52363999/

相关文章:

javascript - 使用 scrollIntoView() 的 VueJS 组件

html - 如何对齐 CSS 导航栏中间的元素?

jQuery 如果 li 里面有一个 ul 子元素,则使它成为第一个显示的列表项

javascript - 我怎样才能让我的提交按钮可点击一次并仍然执行我的php?

html - 如何在悬停文本中向下滑动图像

javascript - 如何在 AJAX 函数中从 HTML 获取值字段?

html - 100% 图像宽度?

javascript - 向下滚动时的 CSS 标题效果(更改背景和颜色)

javascript - 在其他图像的网格上扩展和重叠图像

javascript - 如何通过 mouseover/mouseout 在 <div> 附近显示/隐藏新的 <div>?