zoukankan      html  css  js  c++  java
  • html响应式布局,css响应式布局,响应式布局入门

    html响应式布局,css响应式布局,响应式布局入门

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    蕃薯耀 2016年7月25日 15:31:51 星期一

    http://fanshuyao.iteye.com/

    一、效果如下:

    1、当屏幕宽度大于或等于960px时,显示为:



     

    2、当屏幕宽度小于960px且大于640px时,显示为:




    3、当屏幕宽度小于640px时,显示为:



     

    二、代码:

    1、Html页面代码:

    需要注意的是引入的link:

    里面使用了Media属性:

    media="screen and (min-641px) and (max- 959px)"

     

    完整代码:

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>responsive 学习</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/responsive/index.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-960px)" href="${pageContext.request.contextPath}/css/responsive/index-960.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-641px) and (max- 959px)" href="${pageContext.request.contextPath}/css/responsive/index-641-959.css">
    <link rel="stylesheet" type="text/css" media="screen and (max-640px)" href="${pageContext.request.contextPath}/css/responsive/index-640.css">
    </head>
    <body>
    
    	<div class="container">
    		<div class="myheader">myheader</div>
    		<div class="mybody">
    			<div class="left">left</div>
    			<div class="middle">middle</div>
    			<div class="right">right</div>
    		</div>
    		<div class="myfooter">footer</div>
    	</div>
    
    </body>
    </html>

    2、Css代码:

    index.css

    默认样式。

    @CHARSET "UTF-8";
    body{
    	margin: 0;
    	padding: 0;
    }
    .container{
    	 960px;
    	font-size: 14px;
    	color: #fff;
    	margin: 5px auto;
    }
    .myheader{
    	background-color: gray;
    	height: 50px;
    }
    .left,.middle,.right{
    	height: 400px;
    }
    .left{
    	 100px;
    	background-color: green;
    	float: left;
    	margin-right: 10px;
    }
    .middle{
    	 640px;
    	background-color: #bbb;
    	float: left;
    }
    .right{
    	 200px;
    	background-color: maroon;
    	float: right;
    }
    .myfooter{
    	background-color: black;
    	height: 30px;
    	clear: both;
    }
    
    

    index-960.css

    表示大于等于960px显示的样式。

    这个和默认的css样式是一样的,没有区别,因为默认就是用浏览器查看,宽度大于大于等于960px,这样index-960.css可以省略。

    @CHARSET "UTF-8";
    body{
    	margin: 0;
    	padding: 0;
    }
    .container{
    	 960px;
    	font-size: 14px;
    	color: #fff;
    	margin: 5px auto;
    }
    .myheader{
    	background-color: gray;
    	height: 50px;
    }
    .left,.middle,.right{
    	height: 400px;
    }
    .left{
    	 100px;
    	background-color: green;
    	float: left;
    	margin-right: 10px;
    }
    .middle{
    	 640px;
    	background-color: #bbb;
    	float: left;
    }
    .right{
    	 200px;
    	background-color: maroon;
    	float: right;
    }
    .myfooter{
    	background-color: black;
    	height: 30px;
    	clear: both;
    }
    
    

    index-641-959.css

    表示大于640px且小于960px显示的样式。

    @CHARSET "UTF-8";
    .right{
    	display: none;
    }
    .middle{
    	 850px;
    }
    

    index-640.css

    表示小于或等于640px显示的样式。

    @CHARSET "UTF-8";
    .left,.right{
    	display: none;
    }
    .middle{
    	 100%;
    }
    
    

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    蕃薯耀 2016年7月25日 15:31:51 星期一

    http://fanshuyao.iteye.com/

  • 相关阅读:
    vue笔记-inheritAttrs及$attr表示含义(一)
    Springboot项目使用junit-test(@Test)报错原因汇总
    @Configuration的使用
    Spring-RabbitMQ实现商品的同步(后台系统)
    RabbitMQ持久化和非持久化
    spring-AMQP-RabbitMQ
    RabbitMQ的5种模式
    RabbitMQ消息队列+安装+工具介绍
    Mina整体体系结构分析
    Mina入门级客户端程序实现telnet程序
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/6227109.html
Copyright © 2011-2022 走看看