美文网首页
css 每天一练之background-attachment

css 每天一练之background-attachment

作者: 不要变成发抖的小喵喵喵喵喵喵 | 来源:发表于2017-06-05 17:45 被阅读0次

最近在好几个网站上面看到了一种没见过的样式,研究了一下,发现是这个属性的作用,拿出来记录一下好了。
请参考页面 萤石商品详情页

页面截图

background-attachment: 规定背景图像是否固定或者随着页面的其余部分滚动。

有三个可选值:参考 CSS background-attachment 属性
scroll : 默认值。背景图像会随着页面其余部分的滚动而移动。
fixed :当页面的其余部分滚动时,背景图像不会移动。
inherit :规定应该从父元素继承 background-attachment 属性的设置。

iOS系统和某些移动端background-attachment:fixed不兼容性,没有任何效果,但可以hack一下就可以了,代码如下:

ps:想在哪个标签加背景,可以在它class后:before.

body:before {
  content: ' ';
  position: fixed;
  z-index: -1;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: url(path/to/image) center 0 no-repeat;
  background-size: cover;
}

相关文章

  • css 每天一练之background-attachment

    最近在好几个网站上面看到了一种没见过的样式,研究了一下,发现是这个属性的作用,拿出来记录一下好了。请参考页面 ...

  • Tailwind Background

    背景滚动(background attachment) CSS提供的background-attachment属性...

  • CSS总结

    css选择器 1、标签选择器 div{font-size:28px;background-attachment:...

  • CSS:background-attachment属性

    background-attachment:scroll | fixed | inherit scroll,默认值...

  • CSS background-attachment 属性

    最近看到许多网页运用了一个效果,网页往下翻背景跟着屏幕滚轮的滚动而滚动。这让我很好奇是什么技术做出来的效果,正巧这...

  • 关于 CSS background-attachment

    最近在看css secret这本书,第34节 Scrolling hints,讲怎么优化滚动条用户体验,实现在拖动...

  • 什么是background-attachment

    background-attachment的作用是设置背景图片是随滚动轴如何滚动的css属性 background...

  • Cssday09

    一、CSS背景 background-attachment:设置背景图像是否固定或者随着页面的其余部分滚动。 ba...

  • 3.2

    CSS的背景 background-attachment设置背景图像是否固定或者随着页面的其余部分滚动。•scro...

  • background-attachment 视差动画

    CSS background-attachment 属性 实例 如何指定一个固定的背景图像: 标签定义及使用说明 ...

网友评论

      本文标题:css 每天一练之background-attachment

      本文链接:https://www.haomeiwen.com/subject/samufxtx.html