How can I show only corner borders?

后端 未结 16 1660
被撕碎了的回忆
被撕碎了的回忆 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:41

    Here is something that i did recently with content centred both vertically and horizontally.

    The HTML

    © Copyright 2015 - Company name

    St Winifrids St,
    The Saints, Harrogate HG1 5PZ, UK

    The CSS

    .c-frame-wrapper {
      width: 250px;
      height: 100px;
      font-size:11px;
      color: $dark-grey-lighten-70;
      /* center align x axis */
      right: auto;
      left: 50%;
      transform: translateX(-50%);
    }
    
    .c-frame-tl {
      top: 0;
      left: 0;
      position: absolute;
      width:10px;
      height:10px;
      border-width: 3px;
      border-style: solid none none solid;
      border-color: #eb0000;
    }
    
    .c-frame-tr {
      top: 0;
      right: 0;
      position: absolute;
      width:10px;
      height:10px;
      border-width: 3px;
      border-style: solid solid none none;
      border-color: #eb0000;
    }
    
    .c-frame-br {
      bottom: 0;
      right: 0;
      position: absolute;
      width:10px;
      height:10px;
      border-width: 3px;
      border-style: none solid solid none;
      border-color: #eb0000;
    }
    
    .c-frame-bl {
      bottom: 0;
      left: 0;
      position: absolute;
      width:10px;
      height:10px;
      border-width: 3px;
      border-style: none none solid solid;
      border-color: #eb0000;
    }
    
    .c-frame-content {
      width:100%;
      text-align: center;
      /*center alignment x and y*/
      position: absolute;
      top: 50%;
      left: 50%;
      bottom: auto;
      right: auto;
      transform: translate(-50%,-50%); 
    }
    

    JSFiddle

提交回复
热议问题