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 bracket?
.bracket {
border-top:20px;
border-bottom:20px;
border-right:none;
border-left: 1px solid black;
}
Not directly, but you can do this instead: HTML:
CSS:
Demo: http://jsfiddle.net/Q8g4F/
You can draw square brackets without the use of any pseudo elements in pure css.
Steps:
<div>
or<span>
and make it aninline-block
so that its length becomes dependent on its content i.e length of this element will be as long as content inside it.linear-gradient()
to create 4 background images with specificwidth
/height
and draw on each corner of the box withbackground-position
. The height factor ofbackground-size
should be equal toborder-left-width
.Necessary CSS:
Useful Resources:
Linear Gradient: MDN, W3.
Background Image: MDN, W3.
Output Image:
This is possible by usage of container's :before and :after pseudo elements. Sass code:
Working example is available here: https://jsfiddle.net/1uuodzdw/
working example: http://codepen.io/yardenst/pen/bhGIy
You can use the :after and :sbefore pseudo-elements, with the content property.
More info
Something like