html - 无法获取 :after to create right triangle shape

标签 html css css-shapes

<分区>

我正在尝试使用 css 创建一个背景,就像图中包含的黄色一样。

enter image description here

我花了一些时间尝试使用 :after 但我无法将三 Angular 形放到正确的位置,也无法达到正确的宽度。

如果我可以使用 css,我真的不想使用图像。

<aside class="quickcontactform">
    <div class="quickcontactformheader">
        <h2>Need help evicting a tenant?</h2>
        <h3>Don't Delay</h3>
        <p>Please complete the form below</p>   
    </div>
    <p>'ere is more content sire</p>
    <p>a be a pleased with it I am</p>
    </aside></div>

还有一些CSS

.quickcontactform {
    width:350px;
    float:right;
    background:#fff;border-radius:10px;
    overflow:hidden;    
}
.quickcontactformheader {
    background:#f0cf35; 
    position:relative;
}

.quickcontactformheader:after {
content:'';
    position:absolute;
    bottom:0px;
     width: 0; 
     height: 0; 
     border-left: 50px solid transparent; 
     border-right: 50px solid transparent; 
     border-top: 100px solid red;
}

最佳答案

检查我的 fiddle :https://jsfiddle.net/r6er318z/

我稍微修改了你的CSS

HTML

<aside class="quickcontactform">
    <div class="quickcontactformheader">
         <h2>Need help evicting a tenant?</h2>

         <h3>Don't Delay</h3>

        <p>Please complete the form below</p>
    </div>
    <p>'ere is more content sire</p>
    <p>a be a pleased with it I am</p>
</aside>

CSS

.quickcontactform {
    width:350px;
    float:right;
    background:#fff;
    border-radius:10px;
    overflow:hidden;
}
.quickcontactformheader {
    background:#f0cf35;
    position:relative;
}
.quickcontactformheader:after {
    content:'';
    position:absolute;
    top:100%;
    width: 0;
    height: 0;
    border-left: 175px solid transparent;
    border-right: 175px solid transparent;
    border-top: 30px solid #f0cf35;
}

关于html - 无法获取 :after to create right triangle shape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30455277/

上一篇:javascript - 可以将 Wordpress 插件转换为在非 WP 网站上使用吗?

下一篇:jQuery 不会更改 css 或动画...我做错了什么?

相关文章:

javascript - 带有文本替换的响应式 JavaScript

jquery - 背景图片幻灯片

javascript - 用缓动动画代替滚动

css - 属性形状不存在?

html - 只有边框的 CSS 形状

javascript - 如何解决将 youtube 链接添加到 iframe 后显示的错误?

javascript - 如何在 javascript/jquery 中单击文本时启用选项卡及其内容?

css - 当窗口大小减小时我的元素重叠

css - 如何创建一个半边框的圆圈(只有 css,不是 js 甚至 svg)?

html - PHP 代码和 html 未在网页中呈现