php 对齐名称<p align="left">

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4812841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 14:28:38  来源:igfitidea点击:

aligning the name<p align="left">

phphtmlalignment

提问by Ivan Reuben Ramos Muit

i wanted to align my Welcome note to the right by using <p align="right">but it doesnt seem to work..is it because Session/PHP doesnt work with p align?

我想通过使用将我的欢迎说明向右对齐,<p align="right">但它似乎不起作用..是因为 Session/PHP 不能与 p 对齐吗?

<?php

    session_start();
 if($_SESSION['SESS_admin'] == 0)
  require("do_menu.php");
 else
  require("do_menu3.php");
 require("auth.php");
    require("do_html_header.php");
 do_html_header();
 print"<p align=\"RIGHT\"><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p>";
 do_menu();

?>

thanks in advance!

提前致谢!

回答by Arty

Try this

尝试这个

 echo "<div style='text-align:right'><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></div>";

回答by Kautiontape

It is probably because your <h1>tag is not set to align right and is instead set to align center. You need to override this with CSS. Try this instead: echo "<h1 style="text-align: right;">Welcome ".$_SESSION['SESS_FIRST_NAME']."</h1>"

这可能是因为您的<h1>标签没有设置为右对齐,而是设置为居中对齐。您需要使用 CSS 覆盖它。试试这个:echo "<h1 style="text-align: right;">Welcome ".$_SESSION['SESS_FIRST_NAME']."</h1>"

回答by Andrew

 print"<p align=\"RIGHT\"><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p>";

You're allowed to use single qoutes, too. It might help you here.

您也可以使用单引号。这可能对你有帮助。

echo '<p align="right"><h1>Welcome '. $_SESSION['SESS_FIRST_NAME'] .'!</h1></p>';

Also, print should have a space after it, or you should be wrapping what's being printed in parenthesis.

此外,print 后面应该有一个空格,或者您应该将正在打印的内容括在括号中。

Edit: I used echoout of habit, sorry. You can use either, but I [think] I read somewhere that echois a better choice than print- not 100% sure, though, but they do the same thing. I'll go look it up, though. (Of course, if anyone reading this knows if one is better than the other, let me know!)

编辑:我echo习惯了,对不起。你可以使用任何一种,但我 [认为] 我读过echoprint- 虽然不是 100% 肯定的更好的选择,但它们做同样的事情。不过我去查查 (当然,如果有人读过这篇文章知道一个比另一个好,请告诉我!)

回答by Olhovsky

The use of ALIGN is deprecated, and fails in many situations. In your case, you're probably writing something in the html_header.php which causes ALIGN to fail.

不推荐使用 ALIGN,并在许多情况下失败。在您的情况下,您可能在 html_header.php 中编写了一些导致 ALIGN 失败的内容。

Try doing:

尝试做:

print "<div style=\"float:right\"><p><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p></div>";

回答by Prabhat

<div align =right>
<?php
..
..
.. // code you want to align to the right
..
?>
</div>

This way you can align a particular segment of code to the right. If later you want to align some other segment of code in the center. Then you can use

通过这种方式,您可以将特定的代码段向右对齐。如果稍后您想在中心对齐其他一些代码段。然后你可以使用

This way you can align the different segments differently.

通过这种方式,您可以以不同的方式对齐不同的段。