在php返回和html之间中断

时间:2016-02-03 19:20:15

标签: html css

我无法理解为什么" Hello 1"和"退出"。谁能明白为什么?

enter image description here

<h4 class="hello">Hello, <em><?php echo $_SESSION['username'];?>!</em></h4>
            <a href="logout.php" style="font-size:18px">Logout?</a>
            <a href="test.php">test</a>
        <div id="container">
            <div class="topbar">
                <p id="headline">Test</p>
                <p id="headline_1">Page</p>

            </div>
        </div>

2 个答案:

答案 0 :(得分:5)

标题(包括h4元素)默认为display: block,因此它们会在自己之前和之后生成换行符。

您可以通过以下方式更改:

  • 不使用标题元素(文本看起来不像是子子标题,所以这可能是最好的方法)。
  • 修改display
  • 浮动元素
  • 使用Flexbox
  • 使用CSS网格

答案 1 :(得分:0)

有些人如上所述描述了原因。一种解决方案可以是这样的:

<div>
    <span class="hello">
      Hello, <em><?php echo $_SESSION['username'];?>!</em>
    </span>
    <a href="logout.php" style="font-size:18px">Logout?</a>
</div>