search

Home  >  Q&A  >  body text

html - css 使用 边框 border 的时候,怎么让他作为内边框。

.bk{
border-style:solid;
border-width:10px;
border-color:red;
}

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

高洛峰高洛峰2779 days ago743

reply all(5)I'll reply

  • 高洛峰

    高洛峰2017-04-17 11:37:42

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

    reply
    0
  • 阿神

    阿神2017-04-17 11:37:42

    box-sizing:border-box;

    reply
    0
  • PHPz

    PHPz2017-04-17 11:37:42

    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;

    "

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:37:42

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

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:37:42

    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.

    reply
    0
  • Cancelreply