当前位置: 首页 > 工具软件 > html5media > 使用案例 >

html5 media自适应基本操作

上官波鸿
2023-12-01
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>html5 media自适应基本操作</title>
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<!-- 外链方式 -->
<!-- <link rel="stylesheet" href="style.css" media="only screen and (max-width:640px)"> -->
<!-- 或者内嵌方式 -->
<style type="text/css">
*{
	margin: 0;padding: 0;
}

.header,.container,.footer{
	margin: 10px auto;
}
.container{height: 500px; background: #ababab;}
.header{
	height: 100px;
	background: #FCF
}
.footer{
	height: 80px;
	background: #000;
}
.left,.right,.main{
	float: left;
	height: 500px;
}
@media screen and (min-width: 960px){
	.header,.container,.footer{
		width: 960px;
	}
	.main{margin-left: 5px;background:#009006;width: 550px;}
	.left,.right{width: 200px}
	.right{margin-left:5px;}
}



@media screen and (min-width: 600px) and (max-width: 960px){
	.header,.container,.footer{
		width: 600px;
	}	
	.main{margin-left: 5px;background:#009006;width: 435px;}
	.left,.right{width: 160px}
	.right{display: none;}
}

@media screen and (max-width: 400px){
	.header,.container,.footer{
		width: 400px;
	}	
	.main{background:#009006;}
	.main{height: 280px;}
	.left,.right,.main{width: 400px; float: none;  margin: 5px auto;}
	.left,.right{height: 100px; background: red;}
}

</style>
</head>
<body>
	<div class="header"></div>
	<div class="container">
		<div class="left">左</div>
		<div class="main">中</div>
		<div class="right">右</div>
	</div>
	<div class="footer">
		
	</div>
</body>
</html>

 类似资料: