chelnov63 Posted September 2, 2008 Share Posted September 2, 2008 Hi I'm looping thoguth a recordset and trying to displaying three pieces of information (date, title, and read more link) for each record on one line. However Im havign a problem with the positioning of the text elements... it seems the position of the Read More link depends upon the number of charaters of the article title. Its like the padding is added on from where the text ends. Anyone know how i can fix this i.e set it so the Read More links are all aligned.. p.s the code is as follows: <div style="width: 420px; height: 275px;color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;text-align:justify;padding-right:11px;" > <?php do { ?> <?php $link = "news.php?id=".$row_rsNews['id']; ?> <?php echo "<strong><span class='stuff'>".date("d/m/y", strtotime($row_rsNews['date_added']))."</span></strong>"; ?> <?php echo "<span class='stuff' style='padding-left:45px'>".$row_rsNews['title']."</span>"; ?> <?php echo "<span class='stuff' style='padding-left:95px'><a href='".$link."'>Read More</a><span><br>"; ?> <?php echo "<img src='bar.png' />"; ?> <?php } while ($row_rsNews = mysql_fetch_assoc($rsNews)); ?> </div> The result looks something like 02/09/08 news again man Read More 01/01/70 News item man Read More 01/01/70 Article 5 Read More 01/01/70 Artciel 4 Read More 01/01/70 Article 3 Read More 01/01/70 Article 2 Read More 01/01/70 Article 1 Read More Thanks in advance for any help Link to comment https://forums.phpfreaks.com/topic/122360-php-alignment/ Share on other sites More sharing options...
Mchl Posted September 2, 2008 Share Posted September 2, 2008 Start with making your code readable (and non-nonsensical... is 'sensible' a word for that?): <div style="width: 420px; height: 275px;color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;text-align:justify;padding-right:11px;" > <?php do { $link = "news.php?id=".$row_rsNews['id']; echo "<strong><span class='stuff'>".date("d/m/y", strtotime($row_rsNews['date_added']))."</span></strong>"; echo "<span class='stuff' style='padding-left:45px'>".$row_rsNews['title']."</span>"; echo "<span class='stuff' style='padding-left:95px'><a href='".$link."'>Read More</a><span><br>"; echo "<img src='bar.png' />"; } while ($row_rsNews = mysql_fetch_assoc($rsNews)); ?> </div> Link to comment https://forums.phpfreaks.com/topic/122360-php-alignment/#findComment-631803 Share on other sites More sharing options...
chelnov63 Posted September 2, 2008 Author Share Posted September 2, 2008 lol that was very constructive..so it had a few extra php tags in there...its 9 lines of code Link to comment https://forums.phpfreaks.com/topic/122360-php-alignment/#findComment-631809 Share on other sites More sharing options...
Mchl Posted September 2, 2008 Share Posted September 2, 2008 But makes the whole more readable. As for aligning problem, you might want to ask in HTML part of the forums, because its HTML/CSS thing Personally I'd probably use a table, but this is not the best solution I hear. Link to comment https://forums.phpfreaks.com/topic/122360-php-alignment/#findComment-631815 Share on other sites More sharing options...
chelnov63 Posted September 2, 2008 Author Share Posted September 2, 2008 yeah only thing is I need a div tag cos i will have dynamic scroll bars..not sure if i can do that in a table.. i'll head over to the html forums and see what they think.. cheers Link to comment https://forums.phpfreaks.com/topic/122360-php-alignment/#findComment-631820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.