我想要对齐我的文本,以便当我发送消息时,它出现在左边,但它是回复,文本出现在右边…我不知道是使用"text- align :left",定位还是对齐。以下是我的代码
if ($row['username'] == $username)
{
$color = 'blue';
$align:left; // dont know if this is right
}
else
{
$color = 'red';
$align:right; // dont know if this is right
}
echo '<i><p style="font-family:arial;color:'.$color.';font-size:15px;"> <strong>' . $row['username']. '</strong>: ' . $mymessage.'</i></p>';
}发布于 2013-03-13 02:12:34
设置颜色的方式与设置颜色的方式完全相同。
例如:
$align='right';
echo '<i><p style="font-family:arial;color:'.$color.';text-align:'.$align.';font-size:15px;"> <strong>' . $row['username']. '</strong>: ' . $mymessage.'</i></p>';发布于 2013-06-11 22:40:30
尝尝这个,
$css = ($row['username'] == $username) ? 'color:blue;text-align:left;' : 'color:red;text-align:right;';
echo '<i><p style="font-family:arial;font-size:15px;'.$css.'"> <strong>' . $row['username']. '</strong>: ' . $mymessage.'</i></p>';发布于 2013-03-13 02:16:01
这应该是可行的:
if ($row['username'] == $username)
{
$color = 'blue';
$align = 'left';
}
else
{
$color = 'red';
$align = 'right';
}
echo '<i><p style="text-align:' . $align . ';font-family:arial;color:'.$color.';font-size:15px;"> <strong>' . $row['username']. '</strong>: ' . $mymessage.'</i></p>';https://stackoverflow.com/questions/15368883
复制相似问题