里面有文字的CSS形状

标签 css shapes

我需要在下图中创建这种包含文本的形状。 enter image description here

我是这样尝试的:

HTML

        <div class="header-bottom">

            <div class="blue-rectangle">
                <p>sadasdasdasd</p>
            </div>

            <div class="blue-rectangle">
                <p>dsasdasdasda</p>
            </div>

        </div>

CSS

.header-bottom{
position: absolute;
right:13%;
bottom:5%;
}

.blue-rectangle {
background-color: rgba(3,78,136,0.7);
padding: 10px 20px 10px 200px;
margin-bottom: 20px;
}

.blue-rectangle p{
color:white;
text-transform: uppercase;
font-size:18px;
}

我尝试添加 transform:skew 但它同时向右、向左和文本本身倾斜。

最佳答案

.shape{
  text-align:center;
  background-color:rgba(3,78,136,0.7);
  width:200px;
  height:60px;
  line-height:60px;
  color:white;
  margin:20px auto;
  position:relative;
}
.shape:before{
  content:"";
  width:0px;
  height:0px;
  border-top:60px solid rgba(3,78,136,0.7);
  border-left:60px solid transparent;
  position:absolute;
  right:100%;
  top:0px;
}
<div class="shape">
  something something
</div>
<div class="shape">
  something else
</div>

关于里面有文字的CSS形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31669656/

相关文章:

css - Angular - 在 index.html 中包含 CSS 文件

html - 为什么我的页脚 div 包装了所有内容?

c# - 使用 C# 和 Visual Studio 创建可以动态更改其形状和位置的形状

html - 使用CSS绘制导航箭头形状

android - 是否可以将位图的点作为路径?

javascript - js调整图片大小

javascript - 使 Bootstrap 列从屏幕右侧进入

twitter-bootstrap - 当我检查网页时 ....我要去 form.less

silverlight - 如何使多边形的填充渐变为直线?

形状=圆形的节点的大小