简体   繁体   English

为什么我的网站菜单仅在Internet Explorer中移动?

[英]Why does my website menu move around in Internet Explorer only?

I programmed a website with a fixed menu on the top, but in the Internet Explorer 11 it moves around for half a second or something like that when I click a button in the menu. 我编写了一个顶部固定菜单的网站,但是在Internet Explorer 11中,当我单击菜单中的按钮时,它会移动约半秒钟或类似的时间。 In other browsers it works fine. 在其他浏览器中,它可以正常工作。 What can I change to remove the bug, I think it has to do with my CSS code. 我可以更改些什么来消除该错误,我认为这与我的CSS代码有关。

Here is a link to my website, take a look at it with IE and click the buttons on the top for seeing what the problem is :) http://www.ivan.ilic.hg-gf.de/index.html 这是指向我的网站的链接,使用IE进行查看,然后单击顶部的按钮以查看问题所在:) http://www.ivan.ilic.hg-gf.de/index.html

It would be very nice if someone could help me. 如果有人可以帮助我,那将是非常好的。 I want the buttons to be the same in IE and Mozilla, Chrome. 我希望按钮在IE和Mozilla,Chrome中都相同。 I think that the IE is always a bit different to the other browsers. 我认为IE总是与其他浏览器有所不同。

Here is my CSS code for the Navigation menu: 这是我的“导航”菜单的CSS代码:

    /* CSS Menu Navigation Bar */

    #cssmenu

    {   
       position: relative;  
       margin: 0 auto;
       clear: both; 
    }

    #cssmenu a 
    {       
       list-style: none;
       margin: 0;
       padding: 0;
       border: 0;
       line-height: 1.5; 
    }

    #cssmenu li 
    {   
       border: 1px solid transparent;
       padding-top: 7px;
       display: block; 
       float: right; 
       margin: 0 10px;
    }

    #cssmenu ul
    {
        margin: 0 auto;
        padding: 0;
        text-align: center;
        padding-right: 20px;
        margin-bottom: -70px;
        max-height: 80px;
    }

    #cssmenu li a 
    {  
        padding-top: 10px;
        padding-right: 20px;
        padding-left: 20px;
        padding-bottom: 10px;   
        width: 70px;

        border: 1px solid #dfdfdf;
        text-decoration: none;  
        display: block;

        border-radius: 2px;
        -moz-border-radius: 2px;
        -webkit-border-radius: 2px;
        -khtml-border-radius: 2px;      

        font-size: 17px;
        font-family: Verdana, Tahoma;
        color: #292F33;
   }

   #cssmenu li:hover a 
   {  
        border-bottom: 3px solid #30B0FF;   
        display: block;
        color: #30B0FF;
        clear: both;

        font-size: 17px;
        font-family: Verdana, Tahoma;

        transition-duration: 0.05s;
        transition-delay: 0.03s;
   }

  /* screen smaller than 1325px */

  @media only screen and (max-width : 1325px),
  only screen and (max-device-width : 1325px)
  {
       #menu
       {
          min-width: 1020px;
       }

       #cssmenu li a 
       {        
          padding-top: 10px;
          padding-right: 0px;
          padding-left: 0px;
          padding-bottom: 10px; 

          width: 60px;      
          font-size: 15px;
          border: 1px solid transparent;

       }

       #cssmenu li:hover a 
       {        
          font-size: 15px;  
       }
  }

And here is the important HTML code: 这是重要的HTML代码:

<!-- Menu -->       

    <div id="menu">     

        <li style="list-style: none;"> <img id="image" src="images/head.png"/><br><i>&nbsp;{by Ivan Ilic}</i></li>

        <div id='cssmenu'>      

            <ul>                                        

                <li><a href='lazarus.html'>Lazarus</a></li> 
                <li><a href='scratch.html'>Scratch</a></li>
                <li><a href='html.html'>HTML</a></li>
                <li><a href='c-sharp.html'>C#</a></li>
                <li><a href='c++.html'>C++</a></li>
                <li><a href='index.html'>Home</a></li>                  

            </ul>       

        </div>

    </div>      

The "flash" you're seeing is the default active background color. 您看到的“闪光灯”是默认的active背景色。 When you click, it flashes gray, which gives the appearance of movement. 单击时,它会闪烁灰色,从而使外观看起来很运动。 You need to have a CSS Style Reset to override the default background color in IE. 您需要重置CSS样式以覆盖IE中的默认背景色。 Alternatively, you can simply change the active style itself. 或者,您可以简单地更改活动样式本身。

Example: 例:

:active { background:transparent; }

The style reset will prevent most cross-browser styling differences by overriding all the different default styles that browsers tack on. 样式重置将覆盖浏览器添加的所有不同默认样式,从而防止大多数跨浏览器样式差异。 I tested this with F12 Developer Tools and it eliminated the flash. 我使用F12开发人员工具对此进行了测试,并且消除了闪存。

Edit: 编辑:

The use of document.write() to add the style sheet is slowing down in IE. 在IE中,使用document.write()添加样式表的速度正在减慢。 Essentially the content is being painted, and then "fixed" once the styles are loaded. 本质上,内容要先绘制,然后在加载样式后“修复”。 Link the style sheet without JS and the flash will disappear. 链接没有JS的样式表,闪光灯将消失。

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

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