国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

CSS網頁響應式布局實現自動適配Pc/Pad/Phone設備

2024-07-11 08:40:18
字體:
來源:轉載
供稿:網友

前言

現在的設備很多,有PC、iPad、手機、智能手表、智能電視。如果沒有響應式布局,那么電腦網頁在手機或者ipad上顯示,是體驗非常差,操作不方便,視覺疲勞的,所以我們開發網頁要做好響應式布局。

index


<!DOCTYPE html>
<html>
<head>
<title>響應式布局</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="content">
<div id="header">頭部</div>
<div id="left">左側</div>
<div id="center">中間</div>
<div id="right">右側</div>
<div id="footer">底部</div>
</div>
</body>
</html>

CSS


*{
margin: 0;
padding: 0;
}

/*適應PC端 寬度大于1000px*/
@media screen and (min-width: 1000px) {
#content{
width: 960px;
margin:0 auto;
}

#header{
width: 100%;
line-height: 100px;
float: left;
background: #333;
color: #fff;
text-align: center;
font-size: 30px;
margin-bottom: 10px;
}

#left{
width: 200px;
line-height: 400px;
text-align: center;
background: #333;
float: left;
font-size: 30px;
color: #fff;
margin-right: 10px;
}

#center{
width: 540px;
line-height: 400px;
text-align: center;
background: #333;
float: left;
font-size: 30px;
color: #fff;
}

#right{
width: 200px;
line-height: 400px;
text-align: center;
background: #333;
float: right;
font-size: 30px;
color: #fff;
}

#footer{
width: 960px;
height: 200px;
background: #333;
color: #fff;
line-height: 200px;
font-size: 30px;
text-align: center;
float: left;
margin-top: 10px;
}
}

/*適應pad端 寬度在640-1000之間*/
@media screen and (min-width: 640px) and (max-width: 1000px) {
#content{
width: 600px;
margin:0 auto;
}

#header{
width: 100%;
line-height: 100px;
float: left;
background: #333;
color: #fff;
text-align: center;
font-size: 30px;
margin-bottom: 10px;
}

#left{
width: 200px;
line-height: 400px;
text-align: center;
background: #333;
float: left;
font-size: 30px;
color: #fff;
margin-right: 10px;
}

#center{
width: 390px;
line-height: 400px;
text-align: center;
background: #333;
float: left;
font-size: 30px;
color: #fff;
}

#right{
width: 600px;
line-height: 300px;
text-align: center;
background: #333;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉安市| 瑞丽市| 蛟河市| 瑞丽市| 托克托县| 武胜县| 宽甸| 青州市| 英吉沙县| 游戏| 张家港市| 宁化县| 瑞安市| 普格县| 龙岩市| 威远县| 三原县| 远安县| 禹州市| 论坛| 金塔县| 双江| 封开县| 阿荣旗| 庐江县| 石楼县| 兴国县| 淮安市| 疏附县| 榆林市| 广南县| 吉水县| 澄城县| 兖州市| 新邵县| 宜黄县| 利川市| 诸城市| 大名县| 柳河县| 新河县|