How can I show only corner borders?

后端 未结 16 1899
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 10:06

I\'m wondering if it\'s possible in CSS or jQuery to make a border but only for corner. Something like this:

****                         ****
*                     


        
16条回答
  •  面向向阳花
    2020-11-22 10:25

    Assuming

    CONTENT
    and that CONTENT includes at least one HTML node.

    #content {position:relative}
    #content:before, #content:after, #content>:first-child:before, #content>:first-child:after {
        position:absolute; content:' ';
        width:80px; height: 80px;
        border-color:red; /* or whatever colour */
        border-style:solid; /* or whatever style */
    }
    #content:before {top:0;left:0;border-width: 1px 0 0 1px}
    #content:after {top:0;right:0;border-width: 1px 1px 0 0}
    #content>:first-child:before {bottom:0;right:0;border-width: 0 1px 1px 0}
    #content>:first-child:after {bottom:0;left:0;border-width: 0 0 1px 1px}
    

    Here's a Fiddle

提交回复
热议问题