【问题标题】:Trouble with navbar brand css in FirefoxFirefox中导航栏品牌css的问题
【发布时间】:2015-08-11 12:31:03
【问题描述】:

我最近意识到我的导航栏品牌形象在常用的网络浏览器 Mozilla Firefox 中无法正常显示。

css 在 Chrome 和 Internet Explorer (wat) 中运行良好。

我尝试过使用 css,但我永远无法让它在 Firefox 中工作。我检查了一下,似乎填充和引导程序在 Firefox 中无法正常工作存在一些问题。无论如何,这是我的代码:

<html>
<head>   
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">   
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">   
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>   
</head>
<body>  
  <nav class="navbar navbar-default navbar-fixed-top" id = "navbarprincipal">
        <div class="container" id="containernav">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand">
          <img src="http://placehold.it/784x306" class = "brand" id="imagenavbar" alt="Logo">
        </a>          
          </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">                      
              <li class="dropdown">
                <a class="dropdown-toggle" id="dropdownMenuViewMode" data-toggle="dropdown" role="button" aria-expanded="false" ><span class="glyphicon glyphicon-eye-open pull-left"></span>Day<span class="caret"></span></a>
                <ul class="dropdown-menu" id="dropdownViewModeSelect"  role="menu">
                  <li viewmode = "jour" viewmodesecondary = "classic"><a id="linkJour">Day<i class='dropdownFiltreImage glyphicon glyphicon-ok'></i></a></li>                  
            </ul>
          </div><!--/.nav-collapse -->
        </div>
  </nav>
</body>
</html>

html, body {
    margin: 0px;
    padding: 0px;
    height: 100%;
    padding-top: 25px;
}

@media (max-width: 768px) {
  .btncarousel {
    padding:2px 4px;
    font-size:80%;
    line-height: 1;
    border-radius:3px;
  }

  #containernav{
    width: 100%;
  }

  .carousel-caption h3{
    font-size:85%;
  }

  .carousel-caption p{
    font-size:80%;
  }
}

@media (min-width: 769px) and (max-width: 992px) {
  .btncarousel {
    padding:4px 9px;
    font-size:90%;
    line-height: 1.2;
  }

  .carousel-caption h3{
    font-size:95%;
  }

  .carousel-caption p{
    font-size:90%;
  }
}

.btncarousel{
    margin-bottom: 2px;
    margin-top: -4px;
}

video{
max-width: 100%; height: auto;
}

a:link {
    text-decoration: none;
    color : #767676;
}
.navbar {
    background: #fcd404;
    color: #292929;
    margin: 0px;

}

.navbar-brand img {
    margin-top: -7.7%;
    height: 160%;
}

.navbar a {
    -webkit-user-select: none;
}

#scheduler_here {
    width: 100%;
    height: 100%;
}

.navbar a {
    cursor: pointer;
}

.dhx_cal_navline {
    display: none;
}

#custom_form {
    -webkit-box-shadow: 6px 6px 5px 0px rgba(50, 50, 50, 0.75);
    -moz-box-shadow: 6px 6px 5px 0px rgba(50, 50, 50, 0.75);
    box-shadow: 6px 6px 5px 0px rgba(50, 50, 50, 0.75);
    padding: 20px;
    z-index: 10001;
    display: none;
    background-color: white;
    font-family: Tahoma;
    font-size: 10pt;
    border-radius: 5px;
    left: 25%;
    width: 85%;
    top: 25%;
    position: absolute;
    text-align: center;
}

#custom_form input {
    text-align: center;
}
.tab-content {
    margin-top: 10px;
}
#dropdownFiltre {
    margin-right: 20px;
}
.btnnavbarright {
    margin-top: 7px;
}
#txtDescription {
    height: 209px;
    width: 364px;
}
.sectionFilter {
    margin-left: 20px;
}
.dropdownFiltreImage {
    margin-left: 5px;
}
.carousel-inner > .item > img {
    margin: 0 auto;
}

#carouselHelp {
    -webkit-box-shadow: 0px 5px 5px 0px rgba(50, 50, 50, 0.75);
    -moz-box-shadow: 0px 5px 5px 0px rgba(50, 50, 50, 0.75);
    box-shadow: 0px 5px 5px 0px rgba(50, 50, 50, 0.75);
    border-top: 1px solid black;
}
.carousel-caption {
    background: rgba(0,0,0,0.5);
color: white;
}
.glyphicon-filter {
    margin-top: 1.9px;
    margin-right: 2px;
}
.glyphicon-eye-open {
    margin-top: 1.9px;
    margin-right: 2px;
}
canvas {
    position: absolute;
    z-index: 999;
    top: 40%;
    left: 40%;
}
.marginBottom-0 {
    margin-bottom: 0;
}
.dropdown-submenu {
    position: relative;
}
.dropdown-submenu>.dropdown-menu {
    top: 0;
    left : 100%;
    margin-top: -6px;
    margin-left: -1px;
    -webkit-border-radius: 0 6px 6px 6px;
    -moz-border-radius: 0 6px 6px 6px;
    border-radius: 0 6px 6px 6px;
    height: auto;
    max-height: 250px;
    overflow-x: hidden;
}
.dropdown-submenu>a:after {
    display: block;
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #cccccc;
    margin-top: 5px;
    margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
    border-left-color: #555;
}
.dropdown-submenu.pull-left {
    float: none;
}

.dropdown-submenu.pull-left>.dropdown-menu {
    left: -100%;
    margin-left: 10px;
    -webkit-border-radius: 6px 0 6px 6px;
    -moz-border-radius: 6px 0 6px 6px;
    border-radius: 6px 0 6px 6px;
}
.navbar-right .dropdown-menu {
    right: inherit;
}

.menu-half {
    display: inline-block !important;
}

span.twitter-typeahead .tt-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  float: left;
  min-width: 160px;
  padding: 5px 0;
  margin: 2px 0 0;
  list-style: none;
  font-size: 14px;
  text-align: left;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  background-clip: padding-box;
}
span.twitter-typeahead .tt-suggestion > p {
  display: block;
  padding: 3px 20px;
  margin-bottom: 0px;
  clear: both;
  font-weight: normal;
  line-height: 1.42857143;
  color: #333333;
  white-space: nowrap;
}
span.twitter-typeahead .tt-suggestion > p:hover,
span.twitter-typeahead .tt-suggestion > p:focus {
  color: #ffffff;
  text-decoration: none;
  outline: 0;
  background-color: #428bca;
}
span.twitter-typeahead .tt-suggestion.tt-cursor {
  color: #ffffff;
  background-color: #428bca;
}
span.twitter-typeahead {
  width: 100%;
}
.input-group span.twitter-typeahead {
  display: block !important;
}
.input-group span.twitter-typeahead .tt-dropdown-menu {
  top: 32px !important;
}
.input-group.input-group-lg span.twitter-typeahead .tt-dropdown-menu {
  top: 44px !important;
}
.input-group.input-group-sm span.twitter-typeahead .tt-dropdown-menu {
  top: 28px !important;
}

.typeahead, .tt-query, .tt-hint {
  padding: 8px 12px;
  line-height: 30px;
  border: 2px solid #ccc;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  border-radius: 8px;
  outline: none;
}

.modal-backdrop.in {
  opacity: 0;
}

我将我的代码放在 CodePen 中,因为这是一个视觉问题,所以很容易获得:

http://codepen.io/anon/pen/YXNwqw

您可以在 Firefox 中看到图像不像在 Chrome 或 IE 中那样显示。

感谢您的帮助。

【问题讨论】:

    标签: html css twitter-bootstrap firefox


    【解决方案1】:

    这是因为.navbar-brand 的填充,如引导文档中所述

    由于 .navbar-brand 有自己的内边距和高度,您可能需要根据您的图片覆盖一些 CSS。

    此外,您的以下 css 声明似乎导致了 Firefox 中的问题:

    .navbar-brand img {
        margin-top: -7.7%;
        height: 160%;
    }
    

    例如将其替换为:

    .navbar-brand img {
        height: 30px; 
        margin-top: -5px;
    }
    

    它应该可以跨浏览器工作。

    Working Example

    Updated codePen

    【讨论】:

    • 负百分比在 FF 中正常工作,但它基于父级的宽度。在这种情况下,差异源于div.navbar-header,它在 FF 和 chrome 中以不同的宽度呈现。 (是的,基于垂直百分比的边距使用父宽度作为基础,这是它自己的咆哮)
    • @recursive 啊,是的,我记得前段时间读过一些关于基于垂直百分比的边距和父宽度的内容。所以是的,负百分比有效,但也导致了问题。 ;) 感谢您的注释。我希望它可以帮助 Paperback Writer 理解问题。
    猜你喜欢
    • 2019-01-26
    • 2017-05-30
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    • 1970-01-01
    • 2015-09-15
    相关资源
    最近更新 更多