css 背景的各种参数
1,593 Views
五月 27th, 2008 by peterzsk
css design web WordPress 制作 教程 模版利用 CSS ,你可以设置各种背景颜色或背景图片,下面的例子将告诉您如何设置这些参数:
1 . CSS 背景颜色参数:
css 代码:
- h4 { background-color: white; }
- p { background-color: #1078E1; }
- ul { background-color: rgb( 149, 206, 145); }
- <h4>This is a < h4 > with a white background</h4>
- <p>This is a < p > with a background using the hexadecimal value of #1078E1</p>
- <ul>
- This is an unordered list
- with an RGB value of 149, 206, 145
- </ul>
2 . CSS 背景图片参数:
用下面这张图片作为背景图片:
源文件下载:smallpic.jpg
css 代码:
- p { background-image: url(smallPic.jpg); }
- h4{ background-image: url(http://zsk.akaka.com.cn/smallPic.jpg); }
网页内容:
- <p>This < p > has a background image using a local path to the picture.</p>
- <h4>This < h4 > has a background image using the complete url path.</h4>
3 . CSS 背景图片重复参数:
css 代码:
- p {
- background-image: url(smallPic.jpg);
- background-repeat: repeat; }
- h4 {
- background-image: url(smallPic.jpg);
- background-repeat: repeat-y;}
- ol {
- background-image: url(smallPic.jpg);
- background-repeat: repeat-x;}
- ul {
- background-image: url(smallPic.jpg);
- background-repeat: no-repeat;}
网页内容:
- <p>This < p > has a background image repeating in both directions (default repeat). If you use this option, make sure that your image was designed to be repeated.</p>
- <h4>This < h4 > has a background image repeating vertically (y). You could this to add a style to the side of your element.</h4>
- <ol>
- This is an ordered list
- With a background that repeats
- Horizontally (x)
- </ol>
- <ul>
- This is an unordered list
- With a background that repeats
- in neither direction.
- </ul>
4 . CSS 定位背景图像参数:
css 代码:
- p {
- background-image: url(smallPic.jpg);
- background-position: 20px 10px;
- }
- h4 {
- background-image: url(smallPic.jpg);
- background-position: 30% 30%;
- }
- ol {
- background-image: url(smallPic.jpg);
- background-position: top center;
- }
网页内容:
- <p>This < p > has a background image positioned with pixel values.</p>
- <h4>This < h4 > has a background image positioned with percentages.</h4>
- <ol>
- This is an ordered list
- With a background that was positioned
- using keywords.
- </ol>
5 . CSS 渐变背景图片参数:
css 代码:
- p {
- background-image: url(http://www.example.com/gradient.gif);
- background-repeat: repeat-x;
- }
网页内容:
- <p>This paragraph has a gradient background. The gradient background was first made in a painting program and then repeated horizontally across the paragraph element. It makes for a neat effect that also loads quickly! Because the image is very skinny, the file size is also very small. You could also create a gradient that changes color left to right and repeat it in the vertical direction to have a gradient on the side of your web page.</p>
作者:peterzsk
本文永久链接:http://zsk.akaka.com.cn/2008/05/css-background/
采用CC创作共用协议,转载需保留以上信息并<署名、非商业和保持一致>。












顶,很全面!
[回复]
让爱车充满蓝牙气息 fanslife车载套件 (1) - 搜易得IT数码商城
[回复]