Web前端处理响应式图片实战(Bootstrap)
2019-01-20 08:45
393 查看
版权声明:转载请附上文章地址 https://blog.csdn.net/weixin_38134491/article/details/86559050
[code]//下面是 index.html文件全部代码 <!DOCTYPE html> <html> <head> <!--Bootstrap中一行可以分为12个块--> <meta charset="utf-8"> <!-- 兼容移动端声明设置 --> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width" /> <title>Bootstrap网站前端实战</title> <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" /> <link rel="stylesheet" type="text/css" href="css/style1.css"/> <script src="Bootstrap/js/bootstrap.js"></script> <script src="bootstrap/js/jquery-1.11.3.min.js"></script> <script src="bootstrap/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script src="js/style1.js" type="text/javascript" charset="utf-8"></script> <!-- 解决H5标签兼容性 --> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <!-- pc端头部制作 --> <div class="headerbg1"> </div> <div class="headerbg2"> </div> <!-- pc端头部制作 --> <!-- wap版头部制作 --> <div class="wapheader"> <img src="images/pic1.png" width="100%" /> </div> <div class="wapheader"> <img src="images/pic2.png" width="100%" /> </div> <!-- wap版头部制作 --> </body> </html>
[code]//下面是CSS样式中style1.css文件全部代码 .headerbg1{ width: 100%; height: 274px; background: url(../images/pic1.png) no-repeat center top; } .headerbg2{ width: 100%; height: 445px; background: url(../images/pic2.png) no-repeat center top; } /* wap端在pc端大小的时候隐藏*/ .wapheader{ display: none; } @media(max-width:720px){ .headerbg1{ display: none; } .headerbg2{ display: none; } /* wap版代码 */ .wapheader{ display: block; /* 在wap的时候显示上面被隐藏的wap端内容 */ } .wapheader{ width: 100%; height: auto; text-align: center; min-height: 30px; margin-top: 0px; /*处理图片上下间隙问题*/ } /* wap版代码 */ }
PC端效果如下:
wap端效果如下:
相关文章推荐
- BootStrap智能表单实战系列(九)表单图片上传的支持
- 【读书笔记《Bootstrap 实战》】3.优化站点资源、完成响应式图片、让传送带支持手势
- [网页设计]c ss高效开发实战看完了,Bootstrap学习是关键
- bootstrap学习13--图片
- [项目实战派]csharp通过dll调用opencv函数,图片作为参数
- 利用Angularjs和Bootstrap前端开发案例实战
- 项目实战No9 不等高cell高度 相册图片
- java爬虫实战简单用Jsoup框架进行网页爬虫(如抓取网页图片)
- Android 实战 - 个人App乐逗项目 之 查看图片,查看GIF封装
- bootstrap的carousel图片轮播
- Vue2+VueRouter2+Webpack+Axios 构建项目实战(十一)打包项目图片等资源的处理
- Android 手势检测实战 打造支持缩放平移的图片预览效果(下)
- Android实战简易教程<九>(BitmapFactory.Options对资源图片进行缩放)
- Android 手势检测实战 打造支持缩放平移的图片预览效果(上)
- Python爬虫实战一之爬取百度贴吧中图片
- bootstrapTable里如何显示图片
- Android实战简易教程-第九枪(BitmapFactory.Options对资源图片进行缩放)
- bootstrap入门【媒体图片配文字】
- Android多点触控技术实战,自由地对图片进行缩放和移动
- python爬虫实战——图片自动下载器