需要完整的图像作为背景Cover Scroll,当前Cover看起来已放大。我希望以较小的缩放而不是完整的缩放显示实际图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了需要完整的图像作为背景Cover Scroll,当前Cover看起来已放大。我希望以较小的缩放而不是完整的缩放显示实际图像相关的知识,希望对你有一定的参考价值。

需要完整的图像作为背景,移动设备的封面滚动条,当前封面看起来是放大的。我希望以较小的变焦而不是全变焦显示实际图像。

html

<div class="container">
 <h1>Lorem Ipsum</h1>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
  <p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<div class="article">
  <div class="article-img">

</div>
  </div>

<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
  <p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>

CSS

@media screen and (max-width: 600px) {
  .container{
    width: 100%;
    box-sizing: border-box;
    padding-left: 50px;
    padding-right: 10px;
  }

.article-img{
  background:url("https://picsum.photos/536/354");
  background-repeat:no-repeat;
  width:100%;
  height:200px;
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
}
}

附加屏幕截图

enter image description here

答案

尝试更改背景图像以包含它

.article-img{
   background-size: contain;
}

.article-img{
   background-size: 100% 200px;
}

以上是关于需要完整的图像作为背景Cover Scroll,当前Cover看起来已放大。我希望以较小的缩放而不是完整的缩放显示实际图像的主要内容,如果未能解决你的问题,请参考以下文章

css背景颜色的问题,其中cover啥意思。知道是覆盖的意思,但我怎么没看到相关的知识点。还有cover前的/

背景图像全尺寸

如何裁剪图像边缘

如何使背景图像适合所有屏幕尺寸?

css中如何调整插入背景图片的大小

如何在 Bootstrap 4 轮播中制作全角背景图像?