How to give border to any element using css without adding border-width to the whole width of element?

前端 未结 11 1899
礼貌的吻别
礼貌的吻别 2020-12-02 10:19

How to give border to any element using css without adding border-width to the whole width of element?

Like in Photoshop we can give stroke- Inside , center and out

11条回答
  •  悲哀的现实
    2020-12-02 11:09

    Another option, if your background color is solid:

    body { background-color: #FFF; }
    
    .myDiv {
        width: 100px;
        height: 100px;
        border: 3px solid #FFF;  // Border is essentially invisible since background is also #FFF;
    }
    
    .myDiv:hover {
        border-color: blue;  // Just change the border color
    }
    

提交回复
热议问题