国产探花免费观看_亚洲丰满少妇自慰呻吟_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;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宿松县| 万山特区| 朝阳县| 新巴尔虎左旗| 清河县| 玉门市| 崇州市| 扎赉特旗| 西青区| 辽宁省| 聂拉木县| 丹阳市| 绥中县| 岱山县| 岳阳县| 南雄市| 昌图县| 北碚区| 佳木斯市| 黔南| 邹平县| 清河县| 社会| 泽库县| 贵港市| 南部县| 武穴市| 溆浦县| 铜鼓县| 吴川市| 石泉县| 伊通| 馆陶县| 宜州市| 诸城市| 崇文区| 上栗县| 章丘市| 城市| 库伦旗| 福鼎市|