【问题标题】:In mobile view image is not remain responsive在移动视图中图像不保持响应
【发布时间】:2017-10-09 13:27:07
【问题描述】:

这是我的桌面代码

英雄是一类旗帜,所有的东西都写在其中。

In Desktop View

.hero {
  position: relative;
  background: url('../img/banner.png') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
  text-align: center;
  color: #fff;
  padding-top: 110px;
  min-height: 500px;
  letter-spacing: 2px;
  font-family: "Montserrat", sans-serif;
}

.hero h1 {
  font-size: 50px;
  line-height: 1.3;
}
.hero h1 span {
  font-size: 25px;
  color: #e8f380;
  border-bottom: 2px solid #e8f380;
  padding-bottom: 12px;
  line-height: 3;
}

.mouse {
  display: block;
  margin: 0 auto;
  width: 26px;
  height: 46px;
  border-radius: 13px;
  border: 2px solid #e8f380;
  position: absolute;
  bottom: 40px;
  position: absolute;
  left: 50%;
  margin-left: -26px;
}
.mouse span {
  display: block;
  margin: 6px auto;
  width: 2px;
  height: 2px;
  border-radius: 4px;
  background: #e8f380;
  border: 1px solid transparent;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-name: scroll;
  animation-name: scroll;
}

@-webkit-keyframes scroll {
  0% {
    opacity: 1;
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
  }
}
@keyframes scroll {
  0% {
    opacity: 1;
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    -webkit-transform: translateY(20px);
    -ms-transform: translateY(20px);
    transform: translateY(20px);
  }
}
<div class="hero">

    <h1><span>Welcome to</span><br>Navigation</h1>

    <div class="mouse">
        <span></span>
    </div>

</div>

添加一些媒体查询后

In mobile View

@media only screen and (max-width: 412px){
  .hero{
    background: url('../img/smallbanner.png') no-repeat center center fixed;
  }
}

这是我的全部代码 使用媒体查询后,我仍然无法在移动视图中获得合适的图像。移动视图中的图像仍在下降。

我已经尝试了所有媒体查询和小横幅图片,但仍然无法正常工作。

【问题讨论】:

    标签: html twitter-bootstrap css


    【解决方案1】:
    background-size: contain; or background-size: cover;
        .hero {width: 100%;
            height: 400px;
            background-image: url('img_flowers.jpg');
            background-repeat: no-repeat;
            background-size: contain;
        }
    

    【讨论】:

      【解决方案2】:

      尝试使用background-size: contain 而不是cover

      查看this source了解更多信息。

      另外,请尝试在background 属性中混合设置,例如将其设置为bottom center 而不是center center

      【讨论】:

      • 添加后包含而不是封面封面变小了。像引导容器。
      猜你喜欢
      • 2021-03-28
      • 2020-10-24
      • 2018-11-22
      • 2021-10-14
      • 2014-03-01
      • 2013-06-04
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多