html - css 使用 边框 border 的时候,怎么让他作为内边框。
高洛峰
高洛峰 2017-04-17 11:35:42
0
5
758
.bk{
border-style:solid;
border-width:10px;
border-color:red;
}

这个,怎么让他朝内?就是不改变宽度高度?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
小葫芦

box-sizing:border-box; not supported under IE8

阿神

box-sizing:border-box;

PHPzhong

There is no css attribute that can directly create the effect you want, you can only simulate it

style="

border-bottom: 50px solid red;
border-top: 50px solid blue;
border-left: 50px solid white;
border-right: 50px solid black;
height: 0;
width: 0;

"

Peter_Zhu

The height and width remain unchanged and the padding is set to the border

迷茫

There are two implementation options,
The first one uses css pseudo-classes

    .bk{
        position: relative;
        width:100px;
        height:100px;
    }
    .bk:before{
        content:"";
        position: absolute;
        top:0;
        left:0;
        width:98px;
        height:98px;
        border:1px solid #666;
    }

The second method uses the inner shadow of the box-shadow box shadow. I won’t post the specific code. If you don’t understand, just learn it yourself.
If the subject of the question caused the layout to be damaged because of the border, you need to understand how the box model of the element is calculated.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template