I am looking for a way to create an incomplete square with borders with some text and a background with pure css. Here is what I am trying to achieve:
My initial idea is to create the shape based on three shapes and then colorize the borders accordingly:
But I am a bit concerned about the adaptive version - scaling three shapes. So maybe a better idea, anyone?
You can do with css pseudo
::after
and::before
, something like thisDemo
Fixed width and height : https://jsfiddle.net/nikhilvkd/qt5ne3yw/
Auto width and height: https://jsfiddle.net/nikhilvkd/0v3k8rv8/2/
This approach allows you to:
It relies on 2 absolutely positioned pseudo elements and one
div
. The spacing between the content and the borders is controlled by the padding on the div :You can do this with
:before
and:after
pseudo elementsComplete design Fiddle
or SVG
Well, go with the above answers, I recommend using
pseudo
elements to achieve this effect.Here is how you should do this.