HTML多端适应 响应式布局案例

简介: HTML多端适应 响应式布局案例

HTML布局:


<div id="one">
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
  <div class="aa"></div>
</div>


CSS代码:


设置视口:


<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />


PC端:


/* pc */
@media only screen and (min-width: 600px)  {
  .aa{
    width: calc(94%/4);
    margin-left: 2%;
    height: 200px;
    margin-top: 10px;
  }
  .aa:nth-child(4n+1){
    margin-left: 0;
  }
}


iPad端:


/*ipad*/
@media only screen and (min-width: 300px) and (max-width: 600px) {
  .aa{
    width: calc(98%/2);
    margin-left: 2%;
    height: 200px;
    margin-top: 10px;
  }
  .aa:nth-child(2n+1){
    margin-left: 0;
  }
}


手机端:


/*phone*/
@media only screen and (min-width: 0px) and (max-width: 300px) {
  .aa{
    width: 100%;
    margin-left: 0;
    height: 200px;
    margin-top: 10px;
  }
}


PC端效果(呈4排显示):


80.png


iPad端效果(双排显示):


81.png

Android端效果(单排显示):


81.png



相关文章
|
前端开发 Python
HTML笔记+案例(上)
HTML笔记+案例
234 0
|
容器
layui框架实战案例(23):在layui-tab-content中layui-progress-bar在html拼接中不显示lay-percent的解决方案
layui框架实战案例(23):在layui-tab-content中layui-progress-bar在html拼接中不显示lay-percent的解决方案
698 0
杨老师课堂之网页制作HTML的学习入门-含有案例1
杨老师课堂之网页制作HTML的学习入门-含有案例
320 3
|
JavaScript
jQuery选择器案例之——index.html
jQuery选择器案例之——index.html
|
移动开发 HTML5
杨校老师课堂之HTML5动画特效的风车案例
杨校老师课堂之HTML5动画特效的风车案例
226 0
|
数据安全/隐私保护
杨老师课堂之网页制作HTML的学习入门-含有案例2
杨老师课堂之网页制作HTML的学习入门-含有案例
193 0
|
搜索推荐 前端开发 UED
html页面实现自动适应手机浏览器(一行代码搞定)
html页面实现自动适应手机浏览器(一行代码搞定)
1429 0
|
移动开发 HTML5
HTML5表格简单应用案例之[招聘需求表]
HTML5表格简单应用案例之[招聘需求表]
|
JavaScript 计算机视觉
纯js实现人脸识别眨眨眼张张嘴案例——index.html
纯js实现人脸识别眨眨眼张张嘴案例——index.html

热门文章

最新文章