日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

html中响应式查询,css 响应式(媒介查询)

發布時間:2025/4/16 HTML 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html中响应式查询,css 响应式(媒介查询) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.CSS 來實現響應式

CSS實現響應式網站的布局要用到的就是CSS中的媒體查詢接下來來簡單介紹一下:

@media 類型 and (條件1) and (條件二){css樣式}

我們只需用到width衍生出的max-width這個屬性,定義輸出設備中的頁面可見區域寬度來控制該改變的樣式即可。

html代碼如下:

響應式

頭部

左部中部右部底部

demo01.css樣式如下:

body{

margin:0;

text-align:center;

}

.header{

height:100px;

background-color:red;

}

.container{

height:400px;

background-color:pink;

}

.clearfix:after{

display:block;

content:"";

visibility:hidden;

height:0;

clear:both;

}

.footer{

height:100px;

background-color:blue;

}

.left{

width:20%;

background-color:orange;

float:left;

height:300px;

}

.center{

width:55%;

background-color:gray;

float:left;

height:300px;

margin:0 2.5%;

}

.right{

width:20%;

background-color:yellow;

float:left;

height:300px;

}

demo02的樣式如下:

body{

margin:0;

text-align:center;

}

.header{

height:100px;

background-color:red;

}

.container{

height:400px;

background-color:pink;

}

.clearfix:after{

display:block;

content:"";

visibility:hidden;

height:0;

clear:both;

}

.footer{

height:100px;

background-color:blue;

}

.left{

width:30%;

background-color:orange;

float:left;

height:300px;

}

.center{

width:70%;

background-color:gray;

float:left;

height:300px;

}

.right{

width:100%;

background-color:yellow;

height:300px;

}

demo03的樣式:

body{

margin:0;

text-align:center;

}

.header{

height:100px;

background-color:red;

}

.container{

background-color:pink;

}

.clearfix:after{

display:block;

content:"";

visibility:hidden;

height:0;

clear:both;

}

.footer{

height:100px;

background-color:blue;

}

.left{

width:100%;

background-color:orange;

height:300px;

}

.center{

width:100%;

background-color:gray;

height:300px;

}

.right{

width:100%;

background-color:yellow;

height:300px;

}

效果圖:

窗口大于1024px時顯示的樣子

當大于640小于980時,右側欄在底部

當小于480時,導航欄折疊,body三部分豎直排列顯示,若窗口持續縮小,不在發生變化,區域被壓縮

效果總圖:

持續更新,歡迎大家!

總結

以上是生活随笔為你收集整理的html中响应式查询,css 响应式(媒介查询)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。