css - 使用 css 制作自定义形状

标签 css background-color css-shapes shapes

我正在尝试使用 CSS3 来使用 css3 制作此自定义形状。

shape
(来源:mattieumoreau.com)

我想在上面添加文字,红色是我网站的背景(它将是背景图片,所以它必须是透明的。

非常感谢你的帮助

最佳答案

你可以使用

h1.elaborate{
    height:50px;
    line-height:50px;
    margin:0 50px;/*50 being the width of the arrows x2*/
    padding:0 25px;
    background:black;
    color:white;
    position:relative;
    box-sizing:border-box;
}
h1.elaborate:before,
h1.elaborate:after{
    content:'';
    position:absolute;
    width:0;
    height:0;
    border:25px solid black;
    border-left-color:transparent;
    border-right-color:transparent;
}
h1.elaborate:before{left:-25px;}
h1.elaborate:after{right:-25px;}

并将其用作

<h1 class="elaborate">I am the elaborate title</h1>

演示在 http://dabblet.com/gist/9209450

(并将鼠标悬停在标题上 http://dabblet.com/gist/9209563 以查看其工作原理的某种解释)

关于css - 使用 css 制作自定义形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22015850/

相关文章:

css - 纯CSS绘制动画圆弧

css 堆叠 div

css - 未签名邮件是否被gmail阻止的html样式?

html - Bootstrap slider 向右显示图像

android - 在android中删除 View 的背景色

ios - 使数组中每个对象的单元格背景颜色不同

javascript - 完整的日历事件背景颜色

html - 使用 CSS/HTML 创建固定的 5 圈评级

html - 如何将标题放在居中的 div 之上? (html/css)

html - 边 Angular 形状勺子不起作用