I've been reading the 24 ways to impress your friends web developer tips on the run up to Christmas and the 21st article, Swooshy Curly Quotes Without Images, was quite timely for me as it is an effect I was going to include in my current project.

At first it looked quite promising, but upon experimentation it proved, for me at least, to be a little bit hit and miss to get it right in all browsers, and I must admit I gave up trying to tweak the margins and paddings quite quickly. But I liked the idea of not having to resort to using images for the large quotes, as I have done on previous attempts and began adding my own thoughts to the mix.

As simon stated:

I must admit that the heights, margins and spacing don’t make a lot of sense if you analyze them. This was a real trial and error job. Get it working on Safari, and IE would fail. Sort IE, and Firefox would go weird.

My aim was to get the same effect, but with slightly clearer rules affecting the position of the quotation marks. My solution is not quite as clean as the original in the markup (added one span) and requires a little more CSS with some specific targeting of IE. However I believe that the CSS rules and their roles in my solution are clearer to understand and thus change to reproduce the effect accordingly.

For the eager among you check out the demo page for the final results, then read how I executed it.

First the markup:

HTML:
  1. <pre class="code">
  2.     <span class="bqstart">&#8220;</span>I'm a blockquote and I'm loving the big curly quotes I have.<span>&nbsp;</span><span class="bqend">&#8221;</span>
  3. </blockquote>

The only addition here is the span before the closing quotation mark, which contains a single non-breaking space character.

The CSS

CSS:
  1. blockquote {
  2.     position: relative;
  3.     text-indent: 2em;
  4. }
  5.  
  6. .bqstart,
  7. .bqend { font-size: 300%; }
  8.  
  9. .bqstart {
  10.     text-indent: 0;
  11.     position: absolute;
  12.     top: -0.2em;
  13.     left: 0;
  14. }
  15.  
  16. .bqend {
  17.     position: absolute;
  18.     margin-top: -0.2em;
  19.     right: 0;
  20.     text-indent: 0;
  21. }

What this does is:

  • For all browsers we are positioning the quotation mark span elements absolutely to the relatively positioned blockquote.
  • For the opening quotation mark we fiddle with the top positioning value to ensure the quotation mark appears where we want.
  • For the closing quotation mark we apply a negative top margin to make it appear in line with the text, note that this has the same value as the top positioning applied to the opening quotation mark.
  • To ensure that the quotation marks don't appear over the text itself a text indent is applied, which is removed from the quotation marks themselves. This is the reason for the extra span, to create the space for the final quotation mark.

The only values that need tweaking, to account for the size of the quotes for your given font family or the chosen scale of the quotes themselves, are the text-indent, top positioning and negative margin (remember these two have the same value).

This is enough for all browsers except IE to which we have to apply some extra rules. These additions mean we end up with the following as our final CSS:

CSS:
  1. blockquote {
  2.     position: relative;
  3.     text-indent: 2em;
  4. }
  5.  
  6. .bqstart,
  7. .bqend { font-size: 300%; }
  8.  
  9. /* apply IE specific rules first */
  10. .bqstart {
  11.     text-indent: 0;
  12.     margin: -0.6em 0 -2em 0;
  13.     float: left;
  14. }
  15.  
  16. blockquote> .bqstart {
  17.     /* add extra non-IE rules */
  18.     position: absolute;
  19.     top: -0.2em;
  20.     left: 0;
  21.     /* remove IE specific rules */
  22.     float: none;
  23.     margin: 0;
  24. }
  25.  
  26. .bqend {
  27.     position: absolute;
  28.     margin-top: -0.6em;
  29.     right: 0;
  30.     text-indent: 0;
  31. }
  32.  
  33. blockquote> .bqend {
  34.     margin-top: -0.2em;
  35. }

The absolute positioning method was producing widely different results on the opening quote in each version of IE on the PC, it even removed the text-indent in IE 5.5 - which re-appeared when the following solution was applied.

So I returned to Simon's solution to fix this. In this case as we're only dealing with one family of browsers, and thankfully the results are the same in all three versions of IE on the PC, we only have to apply values to the top and bottom margins for IE.

These IE specific rules are then over-ridden using the child selector, so every other browser gets the original CSS in the cascade.

The closing quotation mark was, thankfully, appearing in the same place in all three versions of IE and in pretty much the same place as every other browser, so it was simply a matter of increasing the size of the negative top margin, note that this is again the same value applied to the opening quotation mark. If you're not a perfectionist you could even get away with accounting for this tiny difference without loosing any sleep.

See the demo page for the final results.

Browser Support

Tested with:
PC : Firefox 1.5, Opera 8.5, NS 7.1, IE 5, 5.5, 6
Mac : Safari 2.0, Firefox 1.5

Notes:

  • Firefox 1.5 on the Mac only the closing quotation mark overlaps the text where the last line is full width. This is because the text-indent is not been applied to the span that contains the &nbsp; and I can't seem to make it apply it.
  • In the demo when I added a background color the opening quotation mark disappeared in IE 5.5 and IE 6.0, this was solved by adding the ever useful IE CSS bug fixer known position: relative;.

I've not had chance to test it on a Mac yet, but when I do I'll post the results. Update: I've just tested on the Mac and have added the browsers above, I must also apologise to my Safari visitors as I noticed a bug with the code example areas - which I've now fixed.

Something a little weird is going on here for me, IE 5.0 is applying the rules within the child selector, I'm pretty sure that it shouldn't but can't explain why it is. Anyhow if this is a common occurrence the absolute positioning solution it ends up applying seems to work fine (go figure).

Comments

There have been 9 comments so far, join the discussion.

Pages: « 147 48 49 50 51 52 53 54 55 56 [57] Show All

2801. bupropion - 16th Jan 2017 - 1:20 am

http://bupropion.gdn/#7571 bupropion,

2802. triamterene - 16th Jan 2017 - 2:32 am

http://buytriamterene.in.net/#6152 brand name for triamterene-hctz,

2803. apoteket-sverige.se - 16th Jan 2017 - 3:09 am

http://apoteket-sverige.se/#3285 impotens behandling,

2804. bupropion hcl xl 300 mg - 16th Jan 2017 - 3:36 am

http://bupropion-hcl.us/#4520 bupropion,

2805. order fluoxetine online - 16th Jan 2017 - 3:45 am

http://fluoxetine-online.party/#5248 fluoxetine,

2806. buy tretinoin cream online - 16th Jan 2017 - 4:29 am

http://tretinoin-online.gdn/#1272 tretinoin cream,

2807. glucophage - 16th Jan 2017 - 4:38 am

http://glucophageonline.trade/#7458 buy glucophage,

2808. 10 mg fluoxetine - 16th Jan 2017 - 5:14 am

http://buy-fluoxetine.kim/#3366 10 mg fluoxetine,

2809. nolvadex-d - 16th Jan 2017 - 6:16 am

http://nolvadex-pct.science/#9455 nolvadex,

2810. amitriptyline 25mg - 16th Jan 2017 - 6:25 am

http://amitriptyline25mg.click/#6354 elavil medication,

2811. buy cafergot - 16th Jan 2017 - 7:00 am

http://buy-cafergot.us/#6884 buy cafergot,

2812. atenolol - 16th Jan 2017 - 8:29 am

http://tenormin.host/#6326 tenormin 50 mg,

2813. zofran - 16th Jan 2017 - 9:43 am

http://zofran2016.us/#6450 generic zofran cost,

2814. azithromycin 250 mg - 16th Jan 2017 - 10:28 am

http://azithromycin-250-mg.trade/#7394 azithromycin,

Pages:« 147 48 49 50 51 52 53 54 55 56 [57] Show All

Leave a comment

No HTML please, only textile. For code please use [lang]...[/lang] tags (e.g. [html]...[/html] for HTML)