【问题标题】:CSS horizontal menu breaking when zooming Chrome / Safari缩放 Chrome / Safari 时 CSS 水平菜单中断
【发布时间】:2013-08-18 02:01:04
【问题描述】:

我阅读了许多类似的主题并尝试了这些建议,但似乎我无法让它发挥作用。 我是一个自学者,而不是专业人士,只是为我父母的公司建立一个网站,我的菜单有问题。 这在 IE 和 Firefox(至少我拥有的版本)中运行良好,但 Chrome 和 Safari 不喜欢它。最初在 Chrome 中它看起来不错,但如果你缩小它会破坏它,而在 iPhone 和 iPad 的 Safari 中它会更糟,因为我列表中的最后一个项目永远不会与其他项目内联。 我读到的是我需要有 white-space:nowrap;在我的代码中,但它没有帮助,我也在使用位置属性,但没有一个值起作用。也许关于我的菜单的一个奇怪的事情是每个 li 都有一个 id 标签,但那是因为我希望将不同的图像悬停在每个项目上,这就是我可以做到的方式。非常感谢您的帮助,谢谢

网站链接和代码如下:http://redcoral-catering.com/index_catering_redcoral.php

Safari iPhone:

HTML:

<div id="navbar">
<ul>
<li id="zero"><a href="/index_catering_redcoral.php"> за нас</a></li>

<li id="one"><a  href="/redcoral_services.php"> услуги</a></li>

<li id="two"><a  href="/redcoral_cuisine.php">нашата кухня</a></li>

<li id="three" ><a href="/redcoral_gallery.php">галерия</a></li>

<li id="four"><a  href="/redcoral_movies.php">филми</a></li>

<li id="five"><a  href="/redcoral_celebs.php">кой се е хранил при нас?</a> </li>

<li id="six"><a  href="/redcoral_contacts.php">контакти</a>  </li>

CSS:

#navbar {
width: 894px;
height: 57px;
margin: 0px auto;
padding-left:25px;
padding-top:1px;
/*clear:both;*/
white-space:nowrap;

}


#navbar ul {
  font-family: Arial, Verdana;
  font-size: 14px;
  list-style: none;
   margin: 0;
  padding: 0;
  width:100%;
}
#navbar ul li {
 /* display: block; */
  display: inline-block;
  position: relative;
  float: left;
 /* border-right: 1px solid #1A1A18;*/
}
#navbar ul li ul { display: none; }

#zero{
background-image: url(images/menu/short.png);
}
#one{
background-image: url(images/menu/short.png);
}
#two{
background-image: url(images/menu/short.png);
}
#three{
background-image: url(images/menu/short.png);
}
#four{
background-image: url(images/menu/short.png);
}
#five{
background-image: url(images/menu/short.png);
}
#six{
background-image: url(images/menu/short.png);
}
#seven{
background-image: url(images/menu/short.png);
} 


#navbar ul li a {
  display: block;
  height: 42px;
  text-decoration: none;
  text-align: center;
  text-transform: uppercase;
 font-family: Calibri, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #851212;
    border: none;
  padding: 10px 28px 5px 28px;

}
#zero a:hover { background-image: url(images/menu/22.png); }
#one a:hover { background-image: url(images/menu/22.png);}
#two a:hover { background-image: url(images/menu/24.png);}
#three a:hover { background-image: url(images/menu/22.png);}
#four a:hover { background-image: url(images/menu/22.png);}
#five a:hover { background-image: url(images/menu/23.png);}
#six a:hover { background-image: url(images/menu/26.png);}


 #navbar ul li a:hover { 
    color: #DF0101;} 

【问题讨论】:

    标签: iphone css google-chrome menu safari


    【解决方案1】:

    尝试应用以下设置:

    html, body { 
        margin:0; 
        padding:0; 
    }
    #navbar {
        width: 857px; /* updated width to center properly */
        height: 57px;
        margin: 0px auto;
        /*padding-left:25px;*/
        padding-top:1px; 
        white-space:nowrap; 
    }
    
    #navbar ul li a {
        display: block;
        height: 42px;
        text-decoration: none;
        text-align: center;
        text-transform: uppercase;
        font-family: Calibri, sans-serif;
        font-size: 13px;
        font-weight: bold;
        color: #851212;
        border: none;
        padding: 10px 26px 5px 26px; /* decreased padding very slightly */
    }
    

    还可以尝试将此元标记放在您的标题中:

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    

    如果这能解决问题,请告诉我。

    【讨论】:

    • 感谢您的快速回复,我尝试应用上述内容,但不幸的是它仍然相同。我也尝试了元标记,但遗憾的是页面被放大了,在 iphone 上打开时您实际上无法缩小,最后一项仍然不是内联的。我也在那个元标记之前尝试过,但又没有让它工作,所以我离开了它。我缺少一个设置,但仍然不确定是什么。非常感谢您的帮助
    • 更新:我将内容宽度更改为页面的实际宽度,而不是设备,现在我可以在 iphone 上缩小但菜单仍然是一个问题...
    • 是的,我能想到的唯一方法是为 iphone 添加一个特定的 css 文件,其中填充较少以使其适合,我会为 ipad 做同样的事情,因为它看起来在那里也被打破。我现在有这个标题: 但是仍然谷歌浏览器有问题.....谢谢大家
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-25
    • 2012-05-08
    • 1970-01-01
    • 2013-03-23
    相关资源
    最近更新 更多