js和media query的响应式

$(window).resize(function(){
						if($(window).width() <= 703){
							$(".loyalty-banner-inner").css("height","185px");
						}else if($(window).width() <= 879){
							$(".loyalty-banner-inner").css("height","100%");
						}else if($(window).width() > 880){
							$(".loyalty-banner-inner").css("height","97px");
						}
					})
					$('.loyalty-banner-loyalty_visible').slideDown(1000, function() { 
						$(this).css('display', 'flex');
					});
// 窗体变化监听
window.οnresize=function(){
	if(document.body.clientWidth <= 768){
	}else if(document.body.clientWidth <= 900){
	}else if(document.body.clientWidth <= 1200){
	}
	...
	if(document.body.clientHeight <= 768){
	}
}

<meta name="viewport" content="width=device-width,initial-scale=1.0">
媒体查询
1.引用样式
<link rel="stylesheet" media="(max-width:480px)" href="mobile.css">

2.样式表中直接使用
@media(max-width:480px){...}

一个三栏布局的,在不同的尺寸下,变为两栏,再变为一栏
在这里插入图片描述

   <!DOCTYPE HTML>
   <html>
   <head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1" />
   <title>css3-media-queries-demo</title>
   <style>
   body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
       padding: 0;
       margin: 0;
   }
   .content{
       zoom:1;
   }
   .content:after{
       content: ".";
       display: block;
       height: 0;
       clear: both;
       visibility: hidden;
   }
   .leftBox, .rightBox{
       float: left;
       width: 20%;
       height: 500px;
       margin: 5px;
       background: #ffccf7;
       display: inline;
       -webkit-transition: width 1s ease;
       -moz-transition: width 1s ease;
       -o-transition: width 1s ease;
       -ms-transition: width 2s ease;
       transition: width 1s ease;
   }
   .middleBox{
       float: left;
       width: 50%;
       height: 800px;
       margin: 5px;
       background: #b1fffc;
       display: inline;
       -webkit-transition: width 1s ease;
       -moz-transition: width 1s ease;
       -o-transition: width 1s ease;
       -ms-transition: width 1s ease;
       transition: width 1s ease;
   }
   .rightBox{
       background: #fffab1;
   }
   @media only screen and (min-width: 1024px){
       .content{
               width: 1000px;
               margin: auto
           }
   }
   @media only screen and (min-width: 400px) and (max-width: 1024px){
       .rightBox{
           width: 0;
       }
       .leftBox{ width: 30%}
       .middleBox{ width: 65%}
   }
   @media only screen and (max-width: 400px){
       .leftBox, .rightBox, .middleBox{
           width: 98%;
           height: 200px;
       }
   }
   </style>
   </head>

   <body>
   <div class="content">
     <div class="leftBox"></div>
     <div class="middleBox"></div>
     <div class="rightBox"></div>
   </div>
   </body>
   </html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端段

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值