Log in

View Full Version : Adding a Break in :after



GLSmyth
03-29-2011, 06:55 PM
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

coothead
03-30-2011, 10:15 AM
Hi there GLSmyth,

and a warm welcome to these forums. ;)

Here is an example that may help to get you started....


<!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