I am trying to style a block of text so that it is surrounded by a large curly brace on each side (so that each brace takes up the whole height of each side of the element). Here is the HTML:
<blockquote>
<span class="braceleft">{</span>
<p class="quotation">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus Pellentesque at neque lorem, vitae aliquet risus.</p>
<span class="braceright">}</span></blockquote>
I should also mention that I am trying to do this in WordPress, which I know can add unwanted tags. If I could get the right CSS for plain HTML, I can hopefully figure out how to strip the unwanted tags.
I can easily change the HTML markup if that would make styling easier.
Remove the <span> and <p> tags. Edit the opening <blockquote> tag to
<blockquote class=”addCurlys”>. Use this CSS (play with the font-size for the :before and :after pseudoelements):
Because em is the unit of measurement for the :before and :after pseudoelements, they’re linked to the font-size of their parent – the blockquote itself.
I think most browsers now support :: for pseudoelements – I still tend to only use one
Keep in mind that you should restrict content to make it fit inside curly brackets.
You can probably do something like
Then in the CSS you set the hight / width and background image for curly left and right.
Float the divs and use clearfix on the
blockquote
.I think that should do it.
Here’s the code I use for clearfix
The way to do it without additional tags would be to use CSS’s
:before
and:after
to create the 2 braces and then style them accordingly.Consider this code (or test the fiddle):
HTML:
CSS:
Here’s how it works (for the opening brace):
:before
creates a pseudo-element. We need to add thecontent
attribute otherwise it won’t be rendered ‘properly’. The pink border is only there so you can see where it is.The
BLOCKQUOTE
is given aposition: relative
attribute so that the before and after blocks can be positioned relative to it. We give:before
aposition: absolute
and give it atop
andbottom
value of 0 so that it gets aligned with the blockquote’s top and bottom edges. Then we give it aright: 100%
so that it gets pushed all the way to the left of the edge (could useleft:0
if you want it inside the blockquote, adjust for your tastes). And awidth
to our liking.Finally we add a background (since you wanted the curl to stretch vertically) image and specify that we want it to be sized 100% by 100% of the container (
:before
, i.e. the opening brace). Feel free to change the kitten images to curly braces, I prefer kittens.Adjust for your needs.