京东6.18大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

HTML5 body设置全屏背景图片的示例代码

2024-11-2 22:21| 发布者: 76a9| 查看: 49| 评论: 0

摘要: 用什么代码实现?不允许有白色底色产生,因为手机高度不一样 计划图要尺度(750)确认是背景图(通屏底图)应用场景:移动端宣传页面或者活动页面 错误的写法:加到div中结合图片设置min-height,但是页面不会回弹

用什么代码实现?不允许有白色底色产生,因为手机高度不一样

计划图要尺度(750)确认是背景图(通屏底图)应用场景:移动端宣传页面或者活动页面

错误的写法:加到div中结合图片设置min-height,但是页面不会回弹

终极方案

[code] html,body{ width:100%; height:100% }[/code] [code] body{ font-family: "华文细黑"; background:url("../img/Flyer-bg.png") no-repeat; background-size: 100%; }[/code]

一个hack方案办理垂直剧中问题

[code] <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,minimum-scale=1.0"> <title>缓存</title> <script src="js/jquery-1.8.2.min.js"></script> <script src="js/store.min.js"></script> <style> .parent{ width:200px; height: 200px; /* 以下属性垂直居中 */ position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; background-color: #aaa; } </style> </head> <body> <div class="parent">111</div> </body>[/code]

其他方案

[code] <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="Layer1" style="position:fixed; left:0px; top:0px; width:100%; height:100%"> <img src="https://www.qianbuxian.com/uploads/banners/20171214085954_shouye5.jpg" width="100%" height="100%"/> </body> </html>[/code]

扫除浮动

[code] .float-left { float: left; } .float-right { float: right; } .clear-fix:after { display: table; content: ''; clear: both; }[/code]

到此这篇关于HTML5 body设置全屏背景图片的示例代码的文章就先容到这了,更多相关html5 body背景图片自适应屏内容请搜索脚本之家以前的文章或继承欣赏下面的相关文章,希望各人以后多多支持脚本之家!


来源:https://www.jb51.net/html5/755579.html
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )|网站地图

GMT+8, 2025-7-2 03:02 , Processed in 0.030989 second(s), 19 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.

返回顶部