Log in

View Full Version : PHP Text Wrapping In CSS



SChaput
05-24-2009, 09:17 PM
Hey,
if i use this code,


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">

body {
background: white;
font-size: 0.84em;
width: 75%;
margin: 0 auto;
padding: 0 1em;
border-left: 1px solid black;
border-right: 1px solid black;
}

html {
background: #c0c0c0;
}

.rounded:before {
background: transparent url(top-right.png) scroll no-repeat top right;
margin-bottom: -20px;
height: 30px;
display: block;
border: none;
content: url(top-left.png);
padding: 0;
line-height: 0.1;
font-size: 1px;
}

.rounded:after {
display: block;
line-height: 0.1;
font-size: 1px;
content: url(bottom-left.png);
margin: 2px 0 0 0;
height: 30px;
background: transparent url(bottom-right.png) scroll no-repeat bottom right;
padding: 0;
}

.rounded * {
padding-left: 16px;
padding-right: 16px;

}

.rounded {
margin: 1em;
padding: 0;
}

p {
font-family: Arial, Tahoma , sans-serif;
font-size: 1em;
padding-top: 0;
margin: 1em 0;
line-height: 1.5;
}

blockquote {
background: #666666;
color: white;
margin-right: -1px;
}


p.quotee {
text-align: right;
margin: -1px 0;;
font-weight: bold;
color: #eee;
}



#corners img {
margin: 1em;
border: 1px solid black;
padding: 0;
background: #a0a0a0;
}

pre.rounded {
background: #ffeed0;
}


</style>

</head>
<body>
<h1>&nbsp;</h1>

<blockquote class="rounded">
<p>The first images, from ten thousand kilometers away, brought to a halt the activities of all mankind. On a billion television screens, there appeared a tiny featureless cylinder, growing rapidly second by second. By the time it had doubled it’s size, no one could pretend any longer that Rama was a natural object.</p>
<p class="quotee">— Arthur C. Clarke, “Rendezvous with Rama”</p></blockquote>

</body>
</html>

The text is wrapped just fine. However, if i change the bolded part of the above code too,


<?php echo $entryText ?>

the text just continues in a solid line off the page. Any advice on how i can get the PHP text to wrap?
thanks

Schmoopy
05-24-2009, 11:33 PM
I just tested it out with the following code and it seemed to work for me, you're probably pulling it off a text file / database put shouldn't make too much of a difference:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<?php $text = "The first images, from ten thousand kilometers away, brought to a halt the activities of all mankind. On a billion television screens, there appeared a tiny featureless cylinder, growing rapidly second by second. By the time it had doubled it’s size, no one could pretend any longer that Rama was a natural object."; ?>
<head>
<style type="text/css">

body {
background: white;
font-size: 0.84em;
width: 75%;
margin: 0 auto;
padding: 0 1em;
border-left: 1px solid black;
border-right: 1px solid black;
}

html {
background: #c0c0c0;
}

.rounded:before {
background: transparent url(top-right.png) scroll no-repeat top right;
margin-bottom: -20px;
height: 30px;
display: block;
border: none;
content: url(top-left.png);
padding: 0;
line-height: 0.1;
font-size: 1px;
}

.rounded:after {
display: block;
line-height: 0.1;
font-size: 1px;
content: url(bottom-left.png);
margin: 2px 0 0 0;
height: 30px;
background: transparent url(bottom-right.png) scroll no-repeat bottom right;
padding: 0;
}

.rounded * {
padding-left: 16px;
padding-right: 16px;

}

.rounded {
margin: 1em;
padding: 0;
}

p {
font-family: Arial, Tahoma , sans-serif;
font-size: 1em;
padding-top: 0;
margin: 1em 0;
line-height: 1.5;
}

blockquote {
background: #666666;
color: white;
margin-right: -1px;
}


p.quotee {
text-align: right;
margin: -1px 0;;
font-weight: bold;
color: #eee;
}



#corners img {
margin: 1em;
border: 1px solid black;
padding: 0;
background: #a0a0a0;
}

pre.rounded {
background: #ffeed0;
}


</style>

</head>
<body>
<h1>&nbsp;</h1>

<blockquote class="rounded">
<p><?php echo $text; ?></p>
<p class="quotee">— Arthur C. Clarke, “Rendezvous with Rama”</p></blockquote>

</body>
</html>