css - 响应式带状标题

标签 css css-shapes

我正在尝试为我正在工作的网站制作一个带状标题,但我正在努力让文本很好地适应较小的分辨率。

有没有办法让文本响应式,或者在较小的屏幕上流到双行?

我已将代码放入 JS fiddle 中以显示我正在使用的内容 here.

h3.ribbon {
background: #c3d5d8;
margin-top: 0px !important;
margin-left: -30px;
padding-left: 20px;
color: #fff;
border-bottom: 40px solid #c3d5d8;
border-right: 20px solid #fff;
height: 0px;
line-height: 40px;
font-size: 18px !important;
font-family: 'ProximaNovaThin';
text-rendering: optimizeLegibility !important;
-webkit-font-smoothing: antialiased !important;
font-weight: bold;}

最佳答案

您可以为此使用倾斜的伪元素,允许文本在需要时换行。

.title {
  display: inline-block;
  width: 70%;
  min-height: 50px;
  line-height: 50px;
  background: lightgray;
  position: relative;
}
.title:before {
  content: "";
  position: absolute;
  height: 100%;
  min-width: 120px;
  width: 40%;
  left: 80%;
  background: lightgray;
  transform: skewX(45deg);
  z-index: -1;
}
<div class="title">this is a long title............................a really long title! Like a super long title that should require a second line!</div>

关于css - 响应式带状标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30288511/

相关文章:

javascript - 我的侧面菜单栏中的问题已修复并且内容可以滚动

html - CSS 在两个元素之间创建弯 Angular ?

javascript - 英雄轮播自动导航

html - 为什么有些开发者两次定义 font-size 的单位不同?

css - 如何从 .cshtml 页面调用外部样式表?

javascript - 制作一个有点 flex 的 div

html - 透明形状,上 Angular 有箭头

html - 移除 float 元素的边距

html - 制作 CSS 形状

html - 如何制作上下箭头