Background 背景 设置背景颜色
<html> <head> <style type=”text/css”> body {background-color: yellow} h1 {background-color: #00ff00} h2 {background-color: transparent} p {background-color: rgb(250,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
设置一张图片做为背景
<html> <head> <style type=”text/css”> body { background-image: url(‘http://www.blueidea.com/articleimg/2006/07/3744/bgdesert.jpg’) } </style> </head> <body> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
垂直重复背景图片
<html> <head> <style type=”text/css”> body { background-image: url(‘http://www.blueidea.com/articleimg/2006/07/3744/bgdesert.jpg’); background-repeat: repeat } </style> </head> <body> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
水平重复背景图片
<html> <head> <style type=”text/css”> body { background-image: url(‘http://www.blueidea.com/articleimg/2006/07/3744/bgdesert.jpg’); background-repeat: repeat-x } </style> </head> <body> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
怎样放置背景图片(位置摆放)
<html> <head> <style type=”text/css”> body { background-image: url(‘http://www.blueidea.com/articleimg/2006/07/3744/bgdesert.jpg’); background-repeat: no-repeat; background-position: center; } </style> </head> <body> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
背景不滚动
<html> <head> <style type=”text/css”> body { background-image: url(‘http://www.blueidea.com/articleimg/2006/07/3744/smiley.gif’); background-repeat: no-repeat; background-attachment: fixed } </style> </head> <body> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> <p>The image will not scroll with the rest of the page</p> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
背景属性一行解决(用一行文字定义背景属性)
<html> <head> <style type=”text/css”> body { background: #00ff00 url(‘http://www.blueidea.com/articleimg/2006/07/3744/smiley.gif’) no-repeat fixed center; } </style> </head> <body> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> <p>This is some text</p> </body> </html>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
免责声明:
1、本网站所有发布的源码、软件和资料均为收集各大资源网站整理而来;仅限用于学习和研究目的,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
不得使用于非法商业用途,不得违反国家法律。否则后果自负!
2、本站信息来自网络,版权争议与本站无关。一切关于该资源商业行为与www.niceym.com无关。
如果您喜欢该程序,请支持正版源码、软件,购买注册,得到更好的正版服务。
如有侵犯你版权的,请邮件与我们联系处理(邮箱:skknet@qq.com),本站将立即改正。
NICE源码网 CSS/HTML CSS 实用实例(推荐) https://www.niceym.com/13339.html
猜你喜欢
- CSS的使用技巧 2023-02-17
- CSS: 如何让img图片自适应父元素 2022-08-05
- DIV+CSS经常用到的属性、参数及说明 2022-04-15
- BS项目中的CSS架构_仅加载自己需要的CSS 2022-04-15
- 左侧固定宽度,右侧自适应宽度的CSS布局 2022-04-15
- 门户网站构建CSS框架的规则 2022-04-15
- 指定网页的doctype解决CSS Hacking方法总结 2022-04-15
- css网页布局中注意的几个问题小结 2022-04-15
- css import与link的区别 2022-04-15
- css图片切换效果代码[不用js] 2022-04-15