欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

前端一HTML:十七:背景

发布时间:2025/6/15 HTML 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 前端一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:十七:背景的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。