标签:
在给网页加背景图时会遇到:图片过大,只能显示出部分,不能完整的显示出来,实现不了设计的效果,怎么办?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> body{ background:url(images/hi-wifi-bg.jpg) no-repeat center center; background-size:100% 100%; } </style> </head> <body> <p style=" width:100px; height:1000px;background:#000; opacity:0.5;"> </p> </html> </body> </html>
background:url(images/hi-wifi-bg.jpg) no-repeat center center; background-size:100% 100%;
背景图片的定位background-position设为center center(x,y)
background-size规定背景图像的尺寸,默认值是auto,
background-size: length|percentage|cover|contain;
在这些属性中多试几次
标签:
原文地址:http://www.cnblogs.com/morning0529/p/4569373.html