简体   繁体   English

Div会在刷新时更改位置,但在键入URL时不会更改

[英]Div changes position on refresh but not when typing URL

I have a bit of an issue on my website. 我的网站上有一个问题。 On my website's pages, there is a section that changes position for no reason when the page is refreshed. 在我的网站页面上,有一个部分在刷新页面时无故更改位置。 It doesn't move when I simply click on the URL from the menu, or just type it again in the address bar of my browser. 当我只是从菜单中单击URL或只是在浏览器的地址栏中再次键入URL时,它就不会移动。

I tried using overflow-y on the html and body tag, but it didn't help with the issue. 我尝试在html和body标签上使用overflow-y,但此问题无济于事。 Here's what it usually looks like: 通常是这样的: 正常工作时(键入URL或从菜单访问页面)

And here's what it looks like when the page is refreshed: 这是刷新页面时的样子: 当它不能很好地工作时...

As you can see, on page refresh, this section gets lower and is hidden behind the content of the page. 如您所见,在页面刷新时,该部分的位置变低,并被隐藏在页面内容的后面。

Here's the code of this section : 这是本节的代码:

HTML/PHP HTML / PHP

<div id="topBar">
    <h4>Cegep Network : <?php echo $_SESSION['school']; ?></h4>
    <a href="disconnect.php"><div id="topBarDisconnect"></div></a>
    <div id="topBarUser">
        <h5><?php echo $_SESSION['firstName'] . " " . $_SESSION['lastName']; ?></h5><br />
        <p><?php echo "Le " . $day . " " . date('j') . " " . $month . date(' Y'); ?></p>
    </div>
</div>
<div id="topBarSpace"></div>

CSS CSS

#topBar
{
    height: 43px;
    padding-left: 13px;
    width: 100%;
    position: absolute;
    left: 4px;
    top: 0;
    background-image: url("images/topBar.jpg");
    color: white;
}

#topBar h4
{
    display: inline-block;
    margin-top: 13px;
}

#topBar h5
{
    display: inline-block;
    margin-top: 6px;
    margin-bottom: 0px;
    font-size: 11pt;
}

#topBar p
{
    font-size: 8pt;
    display: inline-block;
    margin-top: -5px;
}

#topBarDisconnect
{
    width: 80px;
    height: 38px;
    background-image: url("images/dcButton.png");
    float: right;
    margin-top: 2px;
    margin-right: 44px;
    margin-left: 9px;
}

#topBarDisconnect:hover
{
    background-image: url("images/dcButtonHover.png");
}


#topBarUser
{
    float: right;
    text-align: right;
}

#topBarSpace
{
    height: 43px;
    width: 100%;
}

Hopefully one of you brilliant people knows a solution to this problem! 希望你们中的一个聪明人知道这个问题的解决方案! I've looked around, only to find unanswered questions! 我环顾四周,却发现未解决的问题! Thanks in advance! 提前致谢!

Looks to me like it might be related to you the $_SESSION variable. 在我看来,它可能与$ _SESSION变量有关。 It's the only reason I can think of that a refresh would differ from loading the page via URL. 这是我能想到的刷新与通过URL加载页面不同的唯一原因。 You are setting the 'h5' as an inline-block, so surely there should be no need for the 'br' after the 'h5'? 您将'h5'设置为嵌入式块,因此确定'h5'之后是否不需要'br'吗? Can you see not see a difference in the code when using 'view source' on both pages, as that might give a good indication of where exactly in the code it's going wrong? 在两个页面上都使用“查看源代码”时,您是否看不到代码的差异,因为这可以很好地表明代码在哪里出了问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM