作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将一个图像固定为背景,同时在其上滚动一个半透明框。然而,当我尝试在 4:3 比例的屏幕上执行此操作时,图像只是切成两半。
这是我的 CSS:
.content {
background-color: black;
background-image:url('http://xurbia.tk/alpha/pictures/Croped%20Xurbiar%20Logo%20Mr.%20Isolation.png');
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: center;
}
这是我想做的一个例子:
http://s.codepen.io/shardros/debug/vOVWwp
任何帮助将不胜感激。
最佳答案
在 body
标签而不是 .content
上设置背景,这样就可以了。
body {
background-color: black;
background-image:url('http://xurbia.tk/alpha/pictures/Croped%20Xurbiar%20Logo%20Mr.%20Isolation.png');
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: center;
}
关于html - 如何保持图像背景图像静止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31636920/
有没有办法让天空/湖泊背景在你滚动时保持静止? Site 最佳答案 在 CSS 中: background-attachment: fixed http://www.w3schools.com/css
我正在研究 CSS 网格,我遇到了一些奇怪的事情。我想要 3 列:1 和 3 的宽度为 150px,其余为 2。我认为这应该是可能的,但这没有用: grid-template-columns: 150
我正在使用 -webkit-appearance 和 -moz-appearance 这样我就可以为我的单选按钮设置不同的样式。当我在 Chrome 中执行此操作时,我得到了我想要的: 当我为 Fir
我是一名优秀的程序员,十分优秀!