CSS Inset Borders

前端 未结 12 1677
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 15:26

I need to create a solid color inset border. This is the bit of CSS I\'m using:

border: 10px inset rgba(51,153,0,0.65);

Unfortunately that cr

12条回答
  •  爱一瞬间的悲伤
    2020-12-02 15:37

    To produce a border inset within an element the only solution I've found (and I've tried all the suggestions in this thread to no avail) is to use a pseudo-element such as :before

    E.g.

    .has-inset-border:before {
      content: "foo"; /* you need something or it will be invisible at least on Chrome */
      color: transparent;
      position: absolute;
      left: 10px;
      right: 10px;
      top: 10px;
      bottom: 10px;
      border: 4px dashed red;
    }
    

    The box-sizing property won't work, as the border always ends up outside everything.

    The box-shadow options has the dual disadvantages of not really working and not being supported as widely (and costing more CPU cycles to render, if you care).

提交回复
热议问题