【问题标题】:Website div not displaying properly in Firefox网站 div 在 Firefox 中无法正确显示
【发布时间】:2017-08-28 10:33:34
【问题描述】:

我正在开发一个网站(网站here)。分类为 .index_container 的 div 及其所有内容都无法在 Firefox 中正确显示。它们在那里,但不可见。我试过设置display: table;,这使得内容应该占据的空间可见,但内容本身仍然没有正确显示。我也尝试过使用overflow,但无济于事。

此外,我已确认它适用于 OS X 上的 Safari 和 Chrome、Android 上的 Chrome、iOS 上的 Chrome 和 Safari,以及 Windows 上的 Internet Explorer。然而,在 Windows 上,Microsoft Edge 与 Firefox 存在相同的显示问题。

    .index_header {
      overflow-x: auto;
      max-width: 100%;
      -webkit-overflow-scrolling: touch;
      -ms-overflow-stype: -ms-autohiding-scrollbar;
      position: relative; }
      @media screen and (max-width: 39.9375em) {
        .index_header {
          background-image: url("../img/header/banner_small.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 100%;
          background-attachment: scroll;
          background-position: left; } }
      @media screen and (min-width: 40em) and (max-width: 63.9375em) {
        .index_header {
          background-image: url("../img/header/banner_medium.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 42.93333%;
          background-attachment: scroll;
          background-position: left; } }
      @media print, screen and (min-width: 64em) {
        .index_header {
          background-image: url("../img/header/banner_large.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 34.00204%;
          background-attachment: scroll;
          background-position: left; } }
      .index_header .index_headshot {
        z-index: 2;
        border-radius: 100%; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_headshot {
            position: absolute;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
                -ms-transform: translate(-50%, -50%);
                    transform: translate(-50%, -50%); } }
        @media print, screen and (min-width: 40em) {
          .index_header .index_headshot {
            position: absolute;
            top: 50%;
            -webkit-transform: translateY(-50%);
                -ms-transform: translateY(-50%);
                    transform: translateY(-50%); } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_headshot {
            margin-left: 6.2%; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_headshot {
            margin-left: 4.89629%; } }
        .index_header .index_headshot img {
          position: absolute;
          top: 50%;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
              -ms-transform: translate(-50%, -50%);
                  transform: translate(-50%, -50%);
          z-index: 2; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_headshot {
            height: 78.125%;
            width: 78.125%; }
            .index_header .index_headshot img {
              height: 79.375%; } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_headshot {
            height: 77.63975%;
            width: 33.33333%; }
            .index_header .index_headshot img {
              height: 77.63975%; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_headshot {
            height: 77.8%;
            width: 26.45359%; }
            .index_header .index_headshot img {
              height: 77.8%; } }
      @media screen and (max-width: 39.9375em) {
        .index_header:before {
          background-color: rgba(36, 47, 49, 0.4);
          position: absolute !important;
          top: 0rem !important;
          right: 0rem !important;
          bottom: 0rem !important;
          left: 0rem !important;
          content: '';
          width: auto;
          height: 100%; } }
      @media print, screen and (min-width: 40em) {
        .index_header:before {
          background: linear-gradient(to right, rgba(36, 47, 49, 0.4) 15%, rgba(36, 47, 49, 0));
          position: absolute !important;
          top: 0rem !important;
          right: 0rem !important;
          bottom: 0rem !important;
          left: 0rem !important;
          content: '';
          width: auto;
          height: 100%; } }
      .index_header .index_header_content {
        position: relative; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_header_content {
            margin-top: -100%; } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_header_content {
            margin-top: -42.93333%; }
            .index_header .index_header_content h1 {
              margin-top: 5%;
              font-size: 56px;
              color: #111617;
              opacity: .7; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_header_content {
            margin-top: -34.00204%; }
            .index_header .index_header_content h1 {
              margin-top: 3%;
              font-size: 72px;
              color: #111617;
              opacity: .7; } }
        .index_header .index_header_content .index_name {
          text-align: center;
          width: 100%;
          background-color: rgba(71, 106, 105, 0.9);
          position: absolute;
          top: 50%;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
              -ms-transform: translate(-50%, -50%);
                  transform: translate(-50%, -50%);
          -webkit-flex: 0 0 auto;
              -ms-flex: 0 0 auto;
                  flex: 0 0 auto;
          min-height: 0px;
          min-width: 0px;
          width: calc(100% - 1.875rem);
          margin-right: 0.9375rem;
          margin-left: 0.9375rem;
          z-index: 1; }
          .index_header .index_header_content .index_name:after {
            position: absolute !important;
            top: 0rem !important;
            right: 0rem !important;
            bottom: 0rem !important;
            left: 0rem !important;
            content: '';
            width: auto;
            height: 100%;
            background: url(../img/header/nav2.png);
            background-repeat: repeat-x;
            margin-left: -12%;
            z-index: -1;
            opacity: .3; }
          @media screen and (max-width: 39.9375em) {
            .index_header .index_header_content .index_name {
              display: none; } }
          @media screen and (min-width: 40em) and (max-width: 63.9375em) {
            .index_header .index_header_content .index_name {
              margin-top: 21.46667%;
              padding-left: 35%; } }
          @media print, screen and (min-width: 64em) {
            .index_header .index_header_content .index_name {
              margin-top: 17.00102%;
              padding-left: 20%; } }
<!doctype html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Josh Guberman</title>
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicon/favicon-16x16.png">
    <link rel="manifest" href="assets/img/favicon/manifest.json">
    <link rel="mask-icon" href="assets/img/favicon/safari-pinned-tab.svg" color="#5bbad5">
    <link rel="shortcut icon" href=".assetsimg/favicon/favicon.ico">
    <meta name="msapplication-config" content="assets/img/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

  </head>
  <body>

    <div class="top-bar" id="big">
    	<div class="top-bar-left">
    	<!--
    		<ul class="menu">
    			<li class="menu-text">Josh Guberman</li>
    		</ul>
    	-->
    	</div>
    	<div class="top-bar-right">
    		<ul class="menu">
    			<li><a href="#">About Me</a></li>
    			<li><a href="#">CV</a></li>
    			<li><a href="#">Projects</a></li>
    			<li><a href="#">Artwork</a></li>
    			<li><a href="#">Blog</a></li>
    		</ul>
    	</div>
    </div><div class="top-bar" id="small">
    	<div class="menu">
    		<div class="menu-text">Josh Guberman</div>
    	</div>
    </div>
    <div class="index_header">
    	<div class="index_headshot">
    		<img src="assets/img/header/headshot.svg" alt="headshot of Josh Guberman">
    	</div><!-- index_headshot -->
    	<div class="index_header_content">
    		<div class="index_name">
    		<h1>Josh Guberman</h1>
    		</div><!-- index_name -->
    	</div> <!-- index_header_content -->
    </div> <!-- index_header_container --><div class="about-me">
    	<div class="spacer"></div>
    	<div class="top-heading"><h2>About Me</h2></div>
    	<div class="spacer"></div>
    	<div class="about-content">
    		<p>Some words are written here</p>
    	</div>
    </div>

    <div class="footer-container">
    	<div class="footer-wrapper">
    		<div class="footer">
    			<p>&copy;Josh Guberman 2017</p>
    		</div>
    	</div>
    </div>

    <script src="assets/js/app.js"></script>
    <script>$(window).on('changed.zf.mediaquery', function(event, newSize, oldSize) {
  // newSize is the name of the now-current breakpoint, oldSize is the previous breakpoint
});</script>
  </body>
</html>

【问题讨论】:

    标签: html css firefox sass


    【解决方案1】:

    所以我本来就很不正常。我认为问题在于Firefox默认为您的标题提供0px的高度。在控制台上进行一些更改,您可以看到我可以通过对标题的 CSS 进行小的调整来看到它。 Here是imgur链接。

    【讨论】:

    • 但它适用于 Chrome。那么他为什么要改变他所拥有的东西,这将如何解决他的问题并回答问题呢? stackoverflow.com/help/how-to-answer
    • 我使用 Foundation (foundation.zurb.com) 建立了网站。这些最小宽度是各种屏幕尺寸的断点,它基本上决定了有效的“网格”尺寸。断点工作得很好(注意 Firefox 上显示的元素如何对移动/小型、中型和大型视口大小做出不同的响应)。更改这些最小宽度只会更改网格大小更改的视口宽度。不过谢谢!
    • 好的,谢谢!这似乎可以解决问题 - 明确说明高度使丢失的内容可见。不幸的是,这引入了一个新问题。在任何给定的视口大小下,.index_header div 的高度需要等于背景图像的高度(否则,图像和内容会被拉伸)。有没有办法做到这一点?我宁愿不使用 HTML 而不是 CSS 添加背景图片,但我想如果绝对必要的话,它会起作用。
    • this 是您遇到的问题类型吗?
    • 更像this。不幸的是,这两种解决方案都不适用于 Firefox。如果没有明确声明.index_header 的高度,它是不可见的。
    【解决方案2】:

    .index_header {
      overflow-x: auto;
      max-width: 100%;
      -webkit-overflow-scrolling: touch;
      -ms-overflow-stype: -ms-autohiding-scrollbar;
      position: relative; }
      @media screen and (max-width: 39.9375em) {
        .index_header {
          background-image: url("../img/header/banner_small.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 100%;
          background-attachment: scroll;
          background-position: left; } }
      @media screen and (min-width: 40em) and (max-width: 63.9375em) {
        .index_header {
          background-image: url("../img/header/banner_medium.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 42.93333%;
          background-attachment: scroll;
          background-position: left; } }
      @media print, screen and (min-width: 64em) {
        .index_header {
          background-image: url("../img/header/banner_large.jpg");
          background-size: 100% 100%;
          height: 100%;
          padding-top: 34.00204%;
          background-attachment: scroll;
          background-position: left; } }
      .index_header .index_headshot {
        z-index: 2;
        border-radius: 100%; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_headshot {
            position: absolute;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
                -ms-transform: translate(-50%, -50%);
                    transform: translate(-50%, -50%); } }
        @media print, screen and (min-width: 40em) {
          .index_header .index_headshot {
            position: absolute;
            top: 50%;
            -webkit-transform: translateY(-50%);
                -ms-transform: translateY(-50%);
                    transform: translateY(-50%); } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_headshot {
            margin-left: 6.2%; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_headshot {
            margin-left: 4.89629%; } }
        .index_header .index_headshot img {
          position: absolute;
          top: 50%;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
              -ms-transform: translate(-50%, -50%);
                  transform: translate(-50%, -50%);
          z-index: 2; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_headshot {
            height: 78.125%;
            width: 78.125%; }
            .index_header .index_headshot img {
              height: 79.375%; } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_headshot {
            height: 77.63975%;
            width: 33.33333%; }
            .index_header .index_headshot img {
              height: 77.63975%; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_headshot {
            height: 77.8%;
            width: 26.45359%; }
            .index_header .index_headshot img {
              height: 77.8%; } }
      @media screen and (max-width: 39.9375em) {
        .index_header:before {
          background-color: rgba(36, 47, 49, 0.4);
          position: absolute !important;
          top: 0rem !important;
          right: 0rem !important;
          bottom: 0rem !important;
          left: 0rem !important;
          content: '';
          width: auto;
          height: 100%; } }
      @media print, screen and (min-width: 40em) {
        .index_header:before {
          background: linear-gradient(to right, rgba(36, 47, 49, 0.4) 15%, rgba(36, 47, 49, 0));
          position: absolute !important;
          top: 0rem !important;
          right: 0rem !important;
          bottom: 0rem !important;
          left: 0rem !important;
          content: '';
          width: auto;
          height: 100%; } }
      .index_header .index_header_content {
        position: relative; }
        @media screen and (max-width: 39.9375em) {
          .index_header .index_header_content {
            margin-top: -100%; } }
        @media screen and (min-width: 40em) and (max-width: 63.9375em) {
          .index_header .index_header_content {
            margin-top: -42.93333%; }
            .index_header .index_header_content h1 {
              margin-top: 5%;
              font-size: 56px;
              color: #111617;
              opacity: .7; } }
        @media print, screen and (min-width: 64em) {
          .index_header .index_header_content {
            margin-top: -34.00204%; }
            .index_header .index_header_content h1 {
              margin-top: 3%;
              font-size: 72px;
              color: #111617;
              opacity: .7; } }
        .index_header .index_header_content .index_name {
          text-align: center;
          width: 100%;
          background-color: rgba(71, 106, 105, 0.9);
          position: absolute;
          top: 50%;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
              -ms-transform: translate(-50%, -50%);
                  transform: translate(-50%, -50%);
          -webkit-flex: 0 0 auto;
              -ms-flex: 0 0 auto;
                  flex: 0 0 auto;
          min-height: 0px;
          min-width: 0px;
          width: calc(100% - 1.875rem);
          margin-right: 0.9375rem;
          margin-left: 0.9375rem;
          z-index: 1; }
          .index_header .index_header_content .index_name:after {
            position: absolute !important;
            top: 0rem !important;
            right: 0rem !important;
            bottom: 0rem !important;
            left: 0rem !important;
            content: '';
            width: auto;
            height: 100%;
            background: url(../img/header/nav2.png);
            background-repeat: repeat-x;
            margin-left: -12%;
            z-index: -1;
            opacity: .3; }
          @media screen and (max-width: 39.9375em) {
            .index_header .index_header_content .index_name {
              display: none; } }
          @media screen and (min-width: 40em) and (max-width: 63.9375em) {
            .index_header .index_header_content .index_name {
              margin-top: 21.46667%;
              padding-left: 35%; } }
          @media print, screen and (min-width: 64em) {
            .index_header .index_header_content .index_name {
              margin-top: 17.00102%;
              padding-left: 20%; } }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!doctype html>
    <html class="no-js" lang="en">
      <head>
        <meta charset="utf-8" />
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Josh Guberman</title>
        <link rel="stylesheet" href="assets/css/app.css">
        <link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicon/apple-touch-icon.png">
        <link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicon/favicon-16x16.png">
        <link rel="manifest" href="assets/img/favicon/manifest.json">
        <link rel="mask-icon" href="assets/img/favicon/safari-pinned-tab.svg" color="#5bbad5">
        <link rel="shortcut icon" href=".assetsimg/favicon/favicon.ico">
        <meta name="msapplication-config" content="assets/img/favicon/browserconfig.xml">
    <meta name="theme-color" content="#ffffff">
    
      </head>
      <body>
    
        <div class="top-bar" id="big">
        	<div class="top-bar-left">
        	<!--
        		<ul class="menu">
        			<li class="menu-text">Josh Guberman</li>
        		</ul>
        	-->
        	</div>
        	<div class="top-bar-right">
        		<ul class="menu">
        			<li><a href="#">About Me</a></li>
        			<li><a href="#">CV</a></li>
        			<li><a href="#">Projects</a></li>
        			<li><a href="#">Artwork</a></li>
        			<li><a href="#">Blog</a></li>
        		</ul>
        	</div>
        </div><div class="top-bar" id="small">
        	<div class="menu">
        		<div class="menu-text">Josh Guberman</div>
        	</div>
        </div>
        <div class="index_header">
        	<div class="index_headshot">
        		<img src="assets/img/header/headshot.svg" alt="headshot of Josh Guberman">
        	</div><!-- index_headshot -->
        	<div class="index_header_content">
        		<div class="index_name">
        		<h1>Josh Guberman</h1>
        		</div><!-- index_name -->
        	</div> <!-- index_header_content -->
        </div> <!-- index_header_container --><div class="about-me">
        	<div class="spacer"></div>
        	<div class="top-heading"><h2>About Me</h2></div>
        	<div class="spacer"></div>
        	<div class="about-content">
        		<p>Some words are written here</p>
        	</div>
        </div>
    
        <div class="footer-container">
        	<div class="footer-wrapper">
        		<div class="footer">
        			<p>&copy;Josh Guberman 2017</p>
        		</div>
        	</div>
        </div>
    
        <script src="assets/js/app.js"></script>
        <script>$(window).on('changed.zf.mediaquery', function(event, newSize, oldSize) {
      // newSize is the name of the now-current breakpoint, oldSize is the previous breakpoint
    });</script>
      </body>
    </html>

    【讨论】:

    • 这是做什么的?它如何解决他的问题?解释你在做什么! stackoverflow.com/help/how-to-answer
    • 我看不出你的 CSS 和我的有什么不同。代替我的 CSS,问题仍然存在于您提供的代码上。不过谢谢。您介意提供更多有关帖子的信息吗?
    • 我认为需要 jquery 链接。尝试连接 jquery 链接。
    • @SawZinMinTun,例如,你想让我(例如)将&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt; 粘贴到我的 html 文件的某个位置吗?如果您要求我为该站点编写的 jquery 或 JS,则没有 - 我正在使用 Foundation 框架中包含的预构建 JS 库。
    猜你喜欢
    • 2013-10-26
    • 2018-06-13
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多