css - 背景图像在 1024px 以上消失

标签 css media-queries background-image

谁能帮帮我。我创建了一个使用背景图片的网站。几个小时前它工作正常,但它们调整大小的方式似乎没有问题。

如果你去这里http://culturesmartbooks.co.uk/regions/asia.php它工作正常。

但是,在页面上http://culturesmartbooks.co.uk/regions/australasia.php ,当浏览器高于 1024px 时,背景图像消失。

这是亚洲页面的 HTML:

<div class="asiaHero">
<div class="caption">
    <h1>Asia</h1>
    <img src="../images/logoBlue.png">
</div>

CSS:

    .asiaHero {
      background-image: url("../images/asiaHero.jpg");
      height: 1000px;
      background-position: top;
      background-repeat: no-repeat;
      background-size: cover;
      background-attachment: fixed;
    }

    .asiaHero .caption {  
        position: relative;
        left: 0;
        top: 40%;
        width: 100%;
        text-align: center;
        color: white;
        background: rgba(0,0,0,0.2);
        height: auto;
        padding: 0.5%;
    }

      .asiaHero .caption img {
        width: 200px;
        height: auto;
    }

    /* sm */
    @media (min-width: 768px) {
      .asiaHero .caption img {
            width: 300px;
        }
    }
    /* md */
    @media (min-width: 992px) {
        .asiaHero .caption img {
            width: 400px;
        }
    }
    /* lg */
    @media (min-width: 1200px) {
        .asiaHero .caption img {
            width: 500px;
        }
    }

     @media screen and (max-width: 1024px) {
    .asiaHero {
      background-attachment: scroll;
      max-height: 650px;
      background-position: top;
    }
    .asiaHero .caption {  
      top: 50%;
  }

大洋洲:

<div class="australasiaHero">
<div class="caption">
    <h1>Australasia</h1>
    <img src="../images/logoBlue.png">
</div>

CSS:

    .australasiaHero {
      background-image: url("../images/australasiaHero.jpg");
      height: 1200px;
      background-position: top;
      background-repeat: no-repeat;
      background-size: cover;
      background-attachment: fixed;
    }

    .australasiaHero .caption {  
        position: relative;
        left: 0;
        top: 40%;
        width: 100%;
        text-align: center;
        color: white;
        background: rgba(0,0,0,0.2);
        height: auto;
        padding: 0.5%;
    }

      .australasiaHero .caption img {
        width: 200px;
        height: auto;
    }

    /* sm */
    @media (min-width: 768px) {
      .australasiaHero .caption img {
            width: 300px;
        }
    }
    /* md */
    @media (min-width: 992px) {
        .australasiaHero .caption img {
            width: 400px;
        }
    }
    /* lg */
    @media (min-width: 1200px) {
        .australasiaHero .caption img {
            width: 500px;
        }
    }

     @media screen and (max-width: 1024px) {
    .australasiaHero {
      background-attachment: scroll;
      max-height: 650px;
      background-position: top;
    }
    .australasiaHero .caption {  
      top: 50%;
  }

我不明白为什么亚洲会显示而澳大拉西亚不会。请有人帮忙

最佳答案

为什么要在media里面写css? http://prntscr.com/f1ugsz

删除媒体并默认编写样式,它将正常工作。

关于css - 背景图像在 1024px 以上消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43680668/

相关文章:

html - 如何划分文本html

html - 媒体查询 : limit some css styles according to the screen size

javascript - 单个 css 文件中的多个设计

css - 使用 CSS 向链接添加图标的标准方法是什么?

css - 我可以使用 CSS 选择空文本区域吗?

html - 如何在这样的按钮中添加阴影?

html - 背景图像宽度和高度适合所有媒体 - 无法使其工作

css - Bootstrap : Resizing background image for mobile

css - iphone 不显示背景图片

css - 如何使用 vh 制作页眉背景图片?