Css菜单浏览器问题

时间:2015-09-22 04:56:51

标签: css

/* Main Nav */
  /* Positioning */
#banner nav {
	margin-top: 14.2em;
	margin-bottom: 0;;
	margin-left: 0;
}
 
#cssmenu,
#cssmenu ul,
#cssmenu li,
#cssmenu a {
  border: none;
  line-height: 1;
  margin: 0 ;
  padding: 0;
}

#cssmenu {
  margin:auto;
  border-top:1px solid #000;
  height: 37px;
  display: block;
  width: auto;
  margin: 0;
  padding: 0;
}

#cssmenu > ul {
  list-style: inside none;
  margin: auto;
  padding: 0;
}

#cssmenu > ul > li {
  list-style: inside none;
  float: left;
  display: inline-block;
  position: relative;
  margin: 0;
  padding: 0;
}

#cssmenu.align-center > ul {
  text-align: center;
}

#cssmenu.align-center > ul > li {
  float: none;
}

#cssmenu.align-center ul ul {
  text-align: left;
}

#cssmenu > ul > li > a {
  outline: none;
  display: block;
  position: relative;
  text-align: center;
  text-decoration: none;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
  font-weight: 700;
  font-size: 13px;
  font-family: Arial, Helvetica, sans-serif;
  border-color:transparent;
  border-left:1px solid #000;
  border-bottom:1px solid #000;
  border-right:1px solid #000;
  margin-bottom:4px;
  color: #FFFFFF;
  padding: 12px 34px;
  border-bottom-left-radius:10px;
  border-bottom-right-radius:10px;
  -moz-outline-radius-bottomleft:10px;
  -moz-border-radius-bottomright:10px;
  -webkit-border-bottom-left-radius:10px;
  -webkit-border-bottom-right-radius:10px;
  background: -moz-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #007df8), color-stop(100%, #07275d));
  background: -webkit-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -o-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -ms-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: linear-gradient(top, #007df8 0%, #07275d 100%);
}

#cssmenu > ul > li.last > a{
	width:64px;
}

#cssmenu > ul > li > a:after {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  right: -2px;
  z-index: 102;
  border-color: #000000;
}

#cssmenu > ul > li.last > a:after {
  border-right:none
}

#cssmenu ul li.has-sub:hover > a:after {
  top: 0;
  bottom: 0;
}

#cssmenu > ul > li.has-sub > a:before {
  content: "";
  position: absolute;
  top: 18px;
  right: 10px;
  border: 5px solid transparent;
  border-top: 5px solid #000;
}

#cssmenu > ul > li.has-sub:hover > a:before {
  top: 19px;
}

#cssmenu > ul > li.has-sub:hover > a {
  padding-bottom: 12px;
  z-index: 999;
  border-color: transparent;
  background:#07275d;
  
}

#cssmenu ul li.has-sub:hover > ul,
#cssmenu ul li.has-sub:hover > div {
  display: block;
}

#cssmenu > ul > li.has-sub > a:hover
#cssmenu > ul > li.has-sub:hover > a {
  border-color: #000;
}

#cssmenu ul li > ul,
#cssmenu ul li > div {
  display: none;
  width: auto;
  position: absolute;
  top: 40px;
  background: #07275d;
  z-index: 999;
  padding: 10px 0;
  border-bottom-left-radius:10px;
  border-bottom-right-radius:10px;
  -moz-outline-radius-bottomleft:10px;
  -moz-border-radius-bottomright:10px;
  -webkit-border-bottom-left-radius:10px;
  -webkit-border-bottom-right-radius:10px;
}

#cssmenu ul li > ul {
  width: 200px;
}

#cssmenu ul ul ul {
  position: absolute;
}

#cssmenu ul ul li:hover > ul {
  left: 100%;
  top: -10px;
}

#cssmenu ul li > ul li {
  display: block;
  list-style: inside none;
  position: relative;
  margin: 0;
  padding: 0;
}

#cssmenu ul li > ul li a {
  outline: none;
  display: block;
  position: relative;
  font: 10pt Arial, Helvetica, sans-serif;
  color: #FFFFFF;
  text-decoration: none;
  text-align:center;
  margin: 0;
  padding: 8px 0px;
  border-radius:10px;
  -moz-border-radius:10px;
  -webkit-border-radius:10px;
}

#cssmenu ul ul li a:hover {
  background: -moz-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #007df8), color-stop(100%, #07275d));
  background: -webkit-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -o-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -ms-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: linear-gradient(top, #007df8 0%, #07275d 100%);
}

#cssmenu > ul > li > a:hover {
  background: #07275d;
  color: #FFFFFF;
}

#cssmenu > ul > li.has-sub > a:hover:before {
  border-top: 5px solid #FFFFFF;
}

/* Featured */
#featured {
	margin-top:0.3em;
	margin-bottom: 2em;background: -moz-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #007df8), color-stop(100%, #07275d));
  background: -webkit-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -o-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: -ms-linear-gradient(top, #007df8 0%, #07275d 100%);
  background: linear-gradient(top, #007df8 0%, #07275d 100%);
	overflow: hidden;
	padding: 20px;
	padding-bottom:0;
	width: 760px;
	border-radius: 10px;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
}

您好我已经制作了一个css菜单,它完美地运行了我的想法但是我在Microsoft Edge& amp; Mozilla Firefox在Microsoft Edge右侧有一个小差距,无法找到为什么有人可以帮助我请Live Preview这里还附上了我的菜单的css代码

提前致谢

3 个答案:

答案 0 :(得分:1)

请使用此代码并在此css中申请您的颜色样式

#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
}
#cssmenu #menu-button {
  display: none;
}
#cssmenu {
  font-family: Montserrat, sans-serif;
  background: #333333;
}
#cssmenu > ul > li {
  float: left;
}
#cssmenu.align-center > ul {
  font-size: 0;
  text-align: center;
}
#cssmenu.align-center > ul > li {
  display: inline-block;
  float: none;
}
#cssmenu.align-center ul ul {
  text-align: left;
}
#cssmenu.align-right > ul > li {
  float: right;
}
#cssmenu > ul > li > a {
  padding: 17px;
  font-size: 12px;
  letter-spacing: 1px;
  text-decoration: none;
  color: #dddddd;
  font-weight: 700;
  text-transform: uppercase;
}
#cssmenu > ul > li:hover > a {
  color: #ffffff;
}
#cssmenu > ul > li.has-sub > a {
  padding-right: 30px;
}
#cssmenu > ul > li.has-sub > a:after {
  position: absolute;
  top: 22px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #dddddd;
  content: '';
}
#cssmenu > ul > li.has-sub > a:before {
  position: absolute;
  top: 19px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #dddddd;
  content: '';
  -webkit-transition: all .25s ease;
  -moz-transition: all .25s ease;
  -ms-transition: all .25s ease;
  -o-transition: all .25s ease;
  transition: all .25s ease;
}
#cssmenu > ul > li.has-sub:hover > a:before {
  top: 23px;
  height: 0;
}
#cssmenu ul ul {
  position: absolute;
  left: -9999px;
}
#cssmenu.align-right ul ul {
  text-align: right;
}
#cssmenu ul ul li {
  height: 0;
  -webkit-transition: all .25s ease;
  -moz-transition: all .25s ease;
  -ms-transition: all .25s ease;
  -o-transition: all .25s ease;
  transition: all .25s ease;
}
#cssmenu li:hover > ul {
  left: auto;
}
#cssmenu.align-right li:hover > ul {
  left: auto;
  right: 0;
}
#cssmenu li:hover > ul > li {
  height: 35px;
}
#cssmenu ul ul ul {
  margin-left: 100%;
  top: 0;
}
#cssmenu.align-right ul ul ul {
  margin-left: 0;
  margin-right: 100%;
}
#cssmenu ul ul li a {
  border-bottom: 1px solid rgba(150, 150, 150, 0.15);
  padding: 11px 15px;
  width: 170px;
  font-size: 12px;
  text-decoration: none;
  color: #dddddd;
  font-weight: 400;
  background: #333333;
}
#cssmenu ul ul li:last-child > a,
#cssmenu ul ul li.last-item > a {
  border-bottom: 0;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
  color: #ffffff;
}
#cssmenu ul ul li.has-sub > a:after {
  position: absolute;
  top: 16px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #dddddd;
  content: '';
}
#cssmenu.align-right ul ul li.has-sub > a:after {
  right: auto;
  left: 11px;
}
#cssmenu ul ul li.has-sub > a:before {
  position: absolute;
  top: 13px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #dddddd;
  content: '';
  -webkit-transition: all .25s ease;
  -moz-transition: all .25s ease;
  -ms-transition: all .25s ease;
  -o-transition: all .25s ease;
  transition: all .25s ease;
}
#cssmenu.align-right ul ul li.has-sub > a:before {
  right: auto;
  left: 14px;
}
#cssmenu ul ul > li.has-sub:hover > a:before {
  top: 17px;
  height: 0;
}
#cssmenu.small-screen {
  width: 100%;
}
#cssmenu.small-screen ul {
  width: 100%;
  display: none;
}
#cssmenu.small-screen.align-center > ul {
  text-align: left;
}
#cssmenu.small-screen ul li {
  width: 100%;
  border-top: 1px solid rgba(120, 120, 120, 0.2);
}
#cssmenu.small-screen ul ul li,
#cssmenu.small-screen li:hover > ul > li {
  height: auto;
}
#cssmenu.small-screen ul li a,
#cssmenu.small-screen ul ul li a {
  width: 100%;
  border-bottom: 0;
}
#cssmenu.small-screen > ul > li {
  float: none;
}
#cssmenu.small-screen ul ul li a {
  padding-left: 25px;
}
#cssmenu.small-screen ul ul ul li a {
  padding-left: 35px;
}
#cssmenu.small-screen ul ul li a {
  color: #dddddd;
  background: none;
}
#cssmenu.small-screen ul ul li:hover > a,
#cssmenu.small-screen ul ul li.active > a {
  color: #ffffff;
}
#cssmenu.small-screen ul ul,
#cssmenu.small-screen ul ul ul,
#cssmenu.small-screen.align-right ul ul {
  position: relative;
  left: 0;
  width: 100%;
  margin: 0;
  text-align: left;
}
#cssmenu.small-screen > ul > li.has-sub > a:after,
#cssmenu.small-screen > ul > li.has-sub > a:before,
#cssmenu.small-screen ul ul > li.has-sub > a:after,
#cssmenu.small-screen ul ul > li.has-sub > a:before {
  display: none;
}
#cssmenu.small-screen #menu-button {
  display: block;
  padding: 17px;
  color: #dddddd;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}
#cssmenu.small-screen #menu-button:after {
  position: absolute;
  top: 22px;
  right: 17px;
  display: block;
  height: 4px;
  width: 20px;
  border-top: 2px solid #dddddd;
  border-bottom: 2px solid #dddddd;
  content: '';
}
#cssmenu.small-screen #menu-button:before {
  position: absolute;
  top: 16px;
  right: 17px;
  display: block;
  height: 2px;
  width: 20px;
  background: #dddddd;
  content: '';
}
#cssmenu.small-screen #menu-button.menu-opened:after {
  top: 23px;
  border: 0;
  height: 2px;
  width: 15px;
  background: #ffffff;
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
}
#cssmenu.small-screen #menu-button.menu-opened:before {
  top: 23px;
  background: #ffffff;
  width: 15px;
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
}
#cssmenu.small-screen .submenu-button {
  position: absolute;
  z-index: 99;
  right: 0;
  top: 0;
  display: block;
  border-left: 1px solid rgba(120, 120, 120, 0.2);
  height: 46px;
  width: 46px;
  cursor: pointer;
}
#cssmenu.small-screen .submenu-button.submenu-opened {
  background: #262626;
}
#cssmenu.small-screen ul ul .submenu-button {
  height: 34px;
  width: 34px;
}
#cssmenu.small-screen .submenu-button:after {
  position: absolute;
  top: 22px;
  right: 19px;
  width: 8px;
  height: 2px;
  display: block;
  background: #dddddd;
  content: '';
}
#cssmenu.small-screen ul ul .submenu-button:after {
  top: 15px;
  right: 13px;
}
#cssmenu.small-screen .submenu-button.submenu-opened:after {
  background: #ffffff;
}
#cssmenu.small-screen .submenu-button:before {
  position: absolute;
  top: 19px;
  right: 22px;
  display: block;
  width: 2px;
  height: 8px;
  background: #dddddd;
  content: '';
}
#cssmenu.small-screen ul ul .submenu-button:before {
  top: 12px;
  right: 16px;
}
#cssmenu.small-screen .submenu-button.submenu-opened:before {
  display: none;
}
#cssmenu.small-screen.select-list {
  padding: 5px;
}

答案 1 :(得分:0)

更好的方法是使用flexbox确保您的菜单可以填充页面的宽度。

  

Flexbox布局(灵活盒子)模块(目前是W3C最后调用工作草案)旨在提供一种更有效的方式来布置,对齐和分配容器中的项目之间的空间,即使它们的大小未知和/或动态的(因此单词" flex")。

有关flexbox的详细参考,请参阅:https://css-tricks.com/snippets/css/a-guide-to-flexbox/

对于修复此问题的CSS,请参阅:http://jsfiddle.net/haveapk/berthtsv/

我首先将包含ul显示模式设置为flex(参见下面的代码)

display:-webkit-flex;
display:flex;

然后给孩子元素这些样式,所以他们都将是相同的大小

-webkit-flex:1;
flex:1;

如果你想要一个项目比其他项目更大,你可以改变它的flex样式。

答案 2 :(得分:0)

请尝试下面的代码,我已经创建了cssmenu。这对你很有帮助。

HTML代码

 <div>
        <ul class="cssmenu">
            <li><a href="#">link 01</a></li>
            <li><a href="#">link 02</a></li>
            <li><a href="#">link 03</a></li>
            <li><a href="#">link 04</a></li>
            <li><a href="#">link 05</a></li>
        </ul>
    </div>

CSS代码

.cssmenu{
    padding:0;
    margin:0;
    display:inherit;
}

.cssmenu li{
    -webkit-flex:1;
    display:inherit;
    text-align:center;
    line-height:50px;
    background:#07275d;
    color:#ffffff;
    border:1px solid #000;
    -webkit-border-radius: 0 0 8px 8px;
    border-radius: 0 0 8px 8px;
}
.cssmenu li a{color:#fff; text-decoration:none}

@media (min-width: 767px){
    .cssmenu{display:flex;}
    .cssmenu li{display:inline-block;}

}