如何在html元素上制作圆角边框? [英] How do I make a slated rounded border on a html element?

查看:118
本文介绍了如何在html元素上制作圆角边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我需要一个标题,样式如下:

Basically, I need to make a header, styled like this:

是否有完整的css方式,或者我需要使用背景图片吗?

Is there a full css way, or do I need to use background-images?

推荐答案

是的,你可以使用CSS,但它不容易,结果是...好,丑陋。
您也可以检查一下:倒置曲面标签的CSS

Yes, you can do it using only CSS, but it's not easy and the result is... well, ugly. You might want to check this as well: CSS for inverted curved tabs

EDIT :今天我有一个更好的主意,请检查此 http://dabblet.com/gist/2762234

EDIT: I got a better idea today, check this http://dabblet.com/gist/2762234

CSS如下:

h1 {
    min-width: 150px;
    height: 30px;
    margin: 0;
    /**border: solid 2px #979797;/**/
    border-bottom: none;
    border-radius: 8px 0 0 0;
    box-shadow: -2px -2px 2px #a5a5b1;
    display: inline-block;
    position: relative;
    background: linear-gradient(#e8e8ea, #f8f8fa);
}
h1:before {
    /**top: -2px;/**/
    /**/top: 0;/**/
    right: -23px;
    width: 30px;
    height: 30px;
    border-radius: 0 8px 0 0;
    /**border: solid 2px #979797;/**/
    border-left: none;
    border-bottom: none;
    box-shadow: 2px -2px 2px #a5a5b1;
    /** outline: solid 1px red; /* uncomment this to check position */
    transform: skewX(30deg);
    position: absolute;
    background: linear-gradient(#e8e8ea, #f8f8fa);
    content: '';
}
h1:after {
    right: -44px;
    /**bottom: 0;/**/
    /**/bottom: 2px;/**/
    width: 16px;
    height: 8px;
    /**border: solid 2px #979797;/**/
    border-top: none;
    border-right: none;
    border-radius: 0 0 0  8px;
    box-shadow: inset 2px -2px 2px #a5a5b1, -4px 4px 2px #f8f8fa;
    /** outline: solid 1px red; /* uncomment this to check position */
    transform: skewX(30deg);
    position: absolute;
    content: '';
}
div {
    min-height: 130px;
    margin-top: -7px;
    /**border: solid 2px #979797;/**/
    border-radius: 0 8px 0 0;
    box-shadow: -2px -2px 2px #a5a5b1, 2px -2px 2px #a5a5b1;
    background: linear-gradient(#f8f8fa, #f6f6f8);
}

可以使它看起来更漂亮,标题和div上的伪元素。

It can be made to look prettier, but that would require a fixed width for the heading and a pseudo-element on the div.

这篇关于如何在html元素上制作圆角边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆