html5手机页面背景图片自适应大小问题
1个回答
展开全部
首先需要div布局,HTML布局:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"><title>背景图片自适应</title><style type="text/css">html,body {padding: 0;margin: 0;}div {width: 100%;height: 300px;background: url('images/slide_01_640x340.jpg') no-repeat;background-size: 100% 100%;}</style></head><body><div></div></body></html>
2.HTML代码的截图效果:
3.自适应最重要的样式如下:
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
width: 100%;
background-size: 100% 100%;
4.最终的效果是这样:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"><title>背景图片自适应</title><style type="text/css">html,body {padding: 0;margin: 0;}div {width: 100%;height: 300px;background: url('images/slide_01_640x340.jpg') no-repeat;background-size: 100% 100%;}</style></head><body><div></div></body></html>
2.HTML代码的截图效果:
3.自适应最重要的样式如下:
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
width: 100%;
background-size: 100% 100%;
4.最终的效果是这样:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询