样式使用户无论用户 ID 是什么,都能看到完全相同的样式

Styling so a user sees the same exact style no matter what their user id is

在我的代码中,我有一个中心标签并设置了中心标签的样式,使其看起来像我想要的样子。目前看起来像这样:

每当我进入我的管理员帐户(一个与普通用户具有不同用户 ID 的帐户)时,它看起来与普通用户看到的大不相同。它看起来像这样:

我想知道是否有任何解决方法,使它看起来就像普通人在管理员帐户上看到的一样。

我试过在它周围放置一个 div 标签并使用相同的样式功能,但这没有用。我试过将中心标记放在代码的不同部分周围,但由于它是一个 "if" 语句,它看起来会有所不同。

代码如下:

   <style>
    center{
    border-left: .17em dashed;
    border-top: .17em solid;
    border-right: .17em dashed;
        border-bottom: .17em solid;
        padding-left:25px;
        padding-bottom: 20px;
        width: 1000px;
        background-color: #E1A0A0;
        border-color: black;
        margin: auto;
        text-align: left;
    }
    </style>
    <?php
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> | ';
        if($_SESSION['user_id'] == 3) {
            echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a></center>';

        }
    }
    ?>

我知道我不能在

周围放置另一个中心标签
"echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> |';"

部分代码和

"echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a></center>';"

部分代码,因为它看起来像这样:

此外,如果我将中心标记放在所有内容周围,它将如下所示:

我只想让它看起来无论谁看都一样。

不确定我是否完全理解要求的内容,但如果您只想让所有内容看起来像您发布的最后一张图片,请在 css:

中删除它

padding-left:25px;

if(){} 关闭后,您需要 echo '</center>' 并将其从 if(){} 中删除。您设置了一个循环,其中有时 center 未关闭

echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> | ';
        if($_SESSION['user_id'] == 3) {
            echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a>';
        }
echo '</center>';