background-attachment属性
通过对background-attachment属性的学习,辨析每个属性值之间的区别。
1.fixed与scroll的区别
background-attachment:fixed;当滚动页面滚动条时背景图片位置保持不变。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
width: 400px;
height: 500px;
/*overflow: scroll;*/
/*background-color: #ccc;*/
background-image: url("images/1.jpg");
/*background-repeat: round;*/
/*background-repeat: space;*/
background-attachment: fixed;
/*background-attachment: scroll;*/
/*background-attachment: local;*/
}
</style>
</head>
<body>
<div class="dv"></div>
<p style="height:1800px"></p>
</body>
</html>
background-attachment:scroll;当滚动页面滚动条时背景图片随着页面一起滚动(将之前代码的fixed改为scroll即可看到二者区别)。
2.scroll与local的区别(这个区别是相对于当前容器而非整个页面)
background-attachment:scroll;当滚动当前容器滚动条时背景图片位置保持不变
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
width: 400px;
height: 500px;
overflow: scroll;
/*background-color: #ccc;*/
background-image: url("images/1.jpg");
/*background-repeat: round;*/
/*background-repeat: space;*/
/*background-attachment: fixed;*/
background-attachment: scroll;
/*background-attachment: local;*/
}
</style>
</head>
<body>
<div class="dv"><span style="height:800px;display:block"></span></div>
<p style="height:1800px"></p>
</body>
</html>
注意:让容器有滚动条效果需加上overflow:scroll;
background-attachment:local;当滚动当前容器滚动条时背景图片随内容滚动(将之前代码的scroll改为local即可看到二者区别)。
background-attachment属性的更多相关文章
- css中background背景属性概
css中background背景属性概 background:url(背景图片路径) no-repeat;/*不重复默认在左上方*/background:url(背景图片路径) no-repeat ...
- background复合属性详解(上):background-image
background复合属性是个很复杂的属性,花样非常多,比较神奇的是css3 中支持多图片背景了,这篇文章先讲讲background-image属性,其他背景属性会在后续的文章综合总结. 一.最基本 ...
- background系列属性
1.background-color背景颜色属性 ①颜色表示方法 英语单词:red blue purple skyblue. rgb:r代表红色 g代表绿色 b代表蓝色 也 ...
- 前端CSS-font属性,超链接的美化,css精灵,background综合属性
前端CSS-font属性,超链接的美化,css精灵,background综合属性 1. font属性 使用font属性,能够将字号.行高.字体,能够一起设置. font:14px/24px " ...
- CSS探案之 background背景属性剖析
首先,我们先来看看两个css属性:background和background-color,对!就是这两位,相信大家在平时应该没少 麻烦人家把,反正我是这样,几乎也少会用到背景图,原因很简单:就是有点害 ...
- background的属性和背景图片定位的实例
本文内容: 1.背景图片定位示例 2.background常用的属性值 3.background-repeat新增的round.space属性 4.background-size的属性值(着重介绍co ...
- background相关属性
background-origin: 规定 background-position 属性相对于容器的哪一部分来定位. padding-box 背景图像相对于内边距框来定位:(默认) border-bo ...
- background——背景属性
一.背景属性 1.1.背景颜色background-color <style> /*浮动,横向排列*/ div{float: left;} /*background-color属性值支持三 ...
- css3的Background新属性
前言 CSS3中出现了几种关于背景图片的新属性:background-origin.background-clip.background-position等.之前大致了解了下,但是background ...
- css详解background八大属性及其含义
background(背景) 以前笔者在css盒模型以及如何计算盒子的宽度一文中提到过盒模型可以看成由 元素外边距(margin).元素边框(border).元素内边距(padding)和元素内容(c ...
随机推荐
- Linux - 系统信息相关命令
系统信息相关命令 本节内容主要是为了方便通过远程终端维护服务器时,查看服务器上当前 系统日期和时间 / 磁盘空间占用情况 / 程序执行情况 本小结学习的终端命令基本都是查询命令,通过这些命令对系统资源 ...
- 手游开发之lua的class函数详解
众所周知,lua没有类这个概念但其通过table实现了面向对象的“类”.在cocos2dx引擎下提供了class(className, ...)函数方法名,因为在脚本开发中这个接口基本都会用来创建一个 ...
- 网络赛 I题 Max answer 单调栈+线段树
题目链接:https://nanti.jisuanke.com/t/38228 题意:在给出的序列里面找一个区间,使区间最小值乘以区间和得到的值最大,输出这个最大值. 思路:我们枚举每一个数字,假设是 ...
- C++ map 使用erase在windows下崩溃,在linux下没有问题的原因
注意:此程序在win环境下会出现上述描述的问题:在mac环境下第一种方式是正常运行的.Map.erase有3个重载函数: void erase(iterator position); size_typ ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- CSDN网站阅读更多:实现原理
一 设计案例 现在很多网站都增加了阅读更多功能.以CSDN为例,分析其实现原理. 二 设计原理 1 内容区的初始高度是固定的. 2 背景渐变的操作区,遮盖在内容区上面 3 点击按钮时,解除内容区的高度 ...
- byte -> int
传送门 传送门2 以下copy: int i = 0; i += ((b[0] & 0xff) << 24); i += ((b[1] & 0xff) <&l ...
- java 基础 ----- Arrays 工具类
----- Arrays 工具类是一个比较方便的类 常用的方法 也可以通过jdk文档进行查看 右侧有偶 对一些比较常用的方法进行演示 直接放在main方法中进行测试 ---- equ ...
- 设计模式之装饰者模式-java实例
设计模式之装饰者模式 需求场景 我们有了别人提供的产品,但是别人提供的产品对我们来说还不够完善,我们需要对这个产品的功能进行补强,此时可以考虑使用装饰者模式. 我们已经有了产品,而且这个产品的功能非常 ...
- Heartbeat详解
转自:http://blog.sina.com.cn/s/blog_7b6fc4c901012om0.html 配置主节点的Heartbeat Heartbeat的主要配置文件有ha.cf.hares ...