How to create a partial border(with a hole)?

前端 未结 3 1959
挽巷
挽巷 2021-01-22 06:36

I wrote code in JavaFX and used CSS for setting styles for the above issue. The following code made borders for an AnchorPane that are 2 pixels wide:

    AnchorP         


        
3条回答
  •  遇见更好的自我
    2021-01-22 07:12

    how about use :before ?

    .testbox is a block element that you want to add the border.

    .testbox{
        margin:10px;
        border:#000 solid 2px;
    }
    
    .testbox:before {
        background: #fff;
        width:300px;
        height: 2px;
        content: '';
        position: relative;
        display: block;
        top: 0;
        left: 300px;
        margin: -2px 0 0;
    }
    

提交回复
热议问题