Results 1 to 2 of 2

Thread: Adding a Break in :after

  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding a Break in :after

    I am wondering if it is possible to include a line break within the content area of the :after pseudo element. I would like to create a class that adds text following an image, i.e.

    .click_for_larger:after {
    font-size: 0.8em;
    content:"<br />- Click for larger version -";
    }

    Of course, in this example the "<br />" would be printed. Is there any way to indicate that there should be a line break before the text is displayed?

    Cheers -

    george

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there GLSmyth,

    and a warm welcome to these forums.

    Here is an example that may help to get you started....
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <base href="http://www.coothead.co.uk/images/">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title>The CSS "after" method</title>
    
    <style type="text/css">
    body {
        background-color:#f0f0f0;
     }
    .click_for_larger {
        width:220px;
        padding:10px 0;
        border:3px double #630;
        margin:5px auto;
        background-color:#fc9;
     }
    .click_for_larger img {
        display:block;
        border:2px solid #c96;
        margin:auto;
     }
    .click_for_larger:after {
        content:'- Click for larger version -';
        display:block;
        padding-top:10px;
        font-size:0.8em;
        text-align:center;
     }
    </style>
    
    </head>
    <body>
    
    <div class="click_for_larger">
     <img src="buddha_thumb.jpg" alt="">
    </div>
    
    <div class="click_for_larger">
     <img src="blood_thumb.jpg" alt="">
    </div>
    
    <div class="click_for_larger">
     <img src="girl_thumb.jpg" alt="">
    </div>
    
    </body>
    </html>
    
    coothead

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •