前端一HTML:十七:背景
生活随笔
收集整理的这篇文章主要介绍了
前端一HTML:十七:背景
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
background-color: 背景颜色
background-image: 背景图片(默认是平铺图片)
background-repeat: 是否平铺
background-position: 背景图片的位置
1. 取值--方位名词: top上, bottom下, left左, right右, center中 background-position: right bottom
2. 设置像素. background-position: 300px, 50px;
<!doctype html> <html lang="en"> <head><meta charset="UTF-8"><title>Document</title><style>div{height: 600px;width: 800px;background-color: pink;background-image: url(html/google.jpg);background-repeat: no-repeat;background-position: right bottom; /*方位名词设置位置*//*background: url(html/google.jpg);*/}</style> </head> <body><!-- div 默认的宽度是占一整行 --><div> </div> </body> </html>
背景属性的连写方式
<!doctype html> <html lang="en"> <head><meta charset="UTF-8"><title>Document</title><style>div{height: 600px;width: 800px;/*背景属性的连写方式,按照如下顺序 background-color, background-image, background-repeat, background-position */background: pink url(html/google.jpg) no-repeat 200px 200px;}</style> </head> <body><!-- div 默认的宽度是占一整行 --><div> </div> </body> </html>
总结
以上是生活随笔为你收集整理的前端一HTML:十七:背景的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: springmvc一:编写简单的Hell
- 下一篇: 前端一HTML:十八:元素的显示方式