I wanted to add an Icon of Quotation Marks before the start of my paragraph, because I’ve seen this being done in some other websites.
So I tried to play a bit with the width
, height
& font-size
properties – But I can’t figure out how to scale that image down to fit the size of the paragraph.
HERE IS THE QM ICON:
HERE IS THE CODE:
.article {
padding-top: 2%;
}
.article::before {
content: url(https://i.sstatic.net/mdeKRzYD.png);
display: inline-block;
/* top: 4px; */
/* float: left; */
/* width: 13px; */
font-size: 10px;
}
<div class="article">
<p>Blah blah blah, some text to fill the space.</p>
</div>
3
Answers
Using
background-image
rather thancontent
seems to be a better option here for a PNG image.Firstly, set your font size in the parent paragraphs with class
.article
then create a new containing block usingposition: relative
. To leave some space for your quotation mark set text-indent to 1em. Using em units means it will scale with the font-size.On your ::before pseudo element, set the size of the background image to the same character size as your main text, again using em units to scale with the parent.
Use position:absolute to give you take the quotes out of the flow of the parent element and use
top
andleft
to position it where you want.You can use background-image and background-size together with position absolute. You can also add transform: translate to better adjust its position
No need to use an image, you can did it in css only:
Original answer: Make big quotes with <blockquote>