Eusthace Eusthace - 6 months ago 22
CSS Question

CSS - Specific Outline

I would like to create an specific outline for a box using css.

Something like this image:
Specific Outline

Please, any help? :(

Answer

You can look at gradients, background-clip and background-size:

example possible http://codepen.io/gc-nomade/pen/aZbrEQ

p {
  margin:1em auto;
  width:600px;
  max-width:70%;
  padding:40px;/* set offset here for border corners */
  background:
    linear-gradient(white,white) top left no-repeat,
    linear-gradient(white,white) top left no-repeat,
    linear-gradient(white,white) top right no-repeat,
    linear-gradient(white,white) top right no-repeat,
    linear-gradient(white,white) bottom left no-repeat,
    linear-gradient(white,white) bottom left no-repeat,
    linear-gradient(white,white) bottom right no-repeat,
    linear-gradient(white,white) bottom right no-repeat,
    rgba(255,255,255,0.15);/* color receive 
  background-clip:content-box; 
  so it is not drawn on padding areas */
  background-clip:border-box,border-box,border-box,border-box,border-box,border-box,border-box,border-box,content-box;
  background-size: 2px 60px, 80px 2px ;/* here give length and thickness of border corners */
  color:white;
}
p span {
  display:inline-block;
  padding:1em;
  }
html {
  height:100%;
  background:url(http://lorempixel.com/640/480/nature/6);
  background-size:cover
}
body {
  min-height:100%;
  background:rgba(0,0,0,0.5);
  margin:0;
  padding:4em;
}
<p><span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</span></p>