I wish to create a [
and ]
bracket just with CSS. Is there a way to specify the top and bottom border (Without slicing the image) so it looks like a br
This is possible by usage of container's :before and :after pseudo elements. Sass code:
$container-selector: h1;
$bg-color: white;
$bracket-color: orange;
$bracket-width: 10px;
$bracket-length: 30px;
// just reset
body {
background-color: $bg-color;
}
// not really related
$container-selector {
padding: 0 30px;
}
$container-selector {
position: relative;
border: $bracket-width solid $bracket-color;
&:before,
&:after {
content: "";
display: block;
position: absolute;
top: -$bracket-width;
right: $bracket-length - $bracket-width;
left: $bracket-length - $bracket-width;
height: $bracket-width;
background-color: $bg-color;
}
&:after {
top: initial;
bottom: -$bracket-width;
}
}
Working example is available here: https://jsfiddle.net/1uuodzdw/