百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>CSS教程> css3响应式布局-样式表中内嵌法
分享文章到:

css3响应式布局-样式表中内嵌法

发布时间:01/15 来源: 浏览: 关键词:
下面来各位朋友介绍一个css3响应式布局的例子,希望此例子对各位学习响应式布局会带来帮助哦。

 

css3响应式布局-样式表中内嵌法
 代码如下

<!DOCTYPE html>
<html>
<head>
 <title>响应式布局-样式表中内嵌法</title>
 <meta charset="utf-8"/>
 <meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
*{margin:0;padding:0;}
body{
 font:18px/20px "Microsoft YaHei",arial,serif;
 color:#fff;
 background:#fff;
}
img{border:0;}
a{text-decoration:none;}


.header,
.container,
.footer{
 margin-left:auto;
 margin-right:auto;
 margin-top:10px;
 text-align:center;
}

.header{
 height:100px;
 background:#333;
}

.sidebarLeft,
.main,
.sidebarRight{
 background:#333;
}

.footer{
 height:100px;
 background:#333;
}


@media screen and (min-width:960px){
 .header,
 .container,
 .footer{
  width:960px;
 }

 .sidebarLeft,
 .main,
 .sidebarRight{
  float:left;
  height:400px;
 }

 .sidebarLeft,
 .sidebarRight{
  width:200px;
 }

 .main{
  margin-left:10px;
  margin-right:10px;
  width:540px;
 }

 .container{
  height:400px;
 }
}

@media screen and (min-width:600px) and (max-width:960px){
 .header,
 .container,
 .footer{
  width:600px;
 }

 .sidebarLeft,
 .main{
  float:left;
  height:400px;
 }

 .sidebarRight{
  display:none;
 }

 .sidebarLeft{
  width:160px;
 }

 .main{
  margin-left:10px;
  width:430px;
 }

 .container{
  height:400px;
 }
}

@media screen and (max-width:600px){
 .header,
 .container,
 .footer{
  width:400px;
 }

 .sidebarLeft,
 .sidebarRight{
  width:400px;
  height:100px;
 }
 .main{
  margin-top:10px;
  width:400px;
  height:200px;
 }

 .sidebarRight{
  margin-top:10px;
 }

 .container{
  height:420px;
 }
}

/*
//完整版
.header,
.container,
.footer{
 margin-left:auto;
 margin-right:auto;
 width:960px;
 margin-top:10px;
 text-align:center;
}

.header{
 height:100px;
 background:#333;
}

.sidebarLeft,
.main,
.sidebarRight{
 background:#333;
 float:left;
 height:400px;
}

.sidebarLeft,
.sidebarRight{
 width:200px;
}

.main{
 margin-left:10px;
 margin-right:10px;
 width:540px;
}

.container{
 height:400px;
}

.footer{
 height:50px;
 background:#333;
}

*/
</style>

 <!--[if lt IE 9]>
 <style>
*{margin:0;padding:0;}
body{
 font:18px/20px "Microsoft YaHei",arial,serif;
 color:#fff;
 background:#fff;
}
img{border:0;}
a{text-decoration:none;}

.header,
.container,
.footer{
 margin-left:auto;
 margin-right:auto;
 width:960px;
 margin-top:10px;
 text-align:center;
}

.header{
 height:100px;
 background:#333;
}

.sidebarLeft,
.main,
.sidebarRight{
 background:#333;
 float:left;
 height:400px;
}

.sidebarLeft,
.sidebarRight{
 width:200px;
}

.main{
 margin-left:10px;
 margin-right:10px;
 width:540px;
}

.container{
 height:400px;
}

.footer{
 height:100px;
 background:#333;
}
</style>
 <![endif]-->
</head>
<body>
 <div class="header">header</div>
 <div class="container">
  <div class="sidebarLeft">sidebarLeft</div>
  <div class="main">main</div>
  <div class="sidebarRight">sidebarRight</div>
 </div>
 <div class="footer">footer</div>
</body>
</html>

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有8人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板