位置:首頁(yè) > 軟件操作教程 > 編程開(kāi)發(fā) > CSS > 問(wèn)題詳情

CSS3 簡(jiǎn)單的多媒體查詢

提問(wèn)人:劉團(tuán)圓發(fā)布時(shí)間:2020-11-19

下面通過(guò)實(shí)例來(lái)理解多媒體查詢的用法。

【例題】使用多媒體查詢

代碼如下:

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

.d1{

background: pink;

}

.d2{

background: lightblue;

}

.d3{

background: yellowgreen;

}

.d4{

background: yellow;

}

@media screen and (min-width: 800px){

.content{

width: 800px;

margin:20px auto;

}

.box{

width: 200px;

height: 200px;

float:left;

}

}

@media screen and (min-width: 500px) and (max-width: 800px){

.content{

width: 100%;

column-count: 1;

}

.box{

width: 50%;

height: 150px;

float:left;

}

}

@media screen and (max-width: 500px){

.content{

width: 100%;

column-count: 1;

}

.box{

width: 100%;

height: 100px;

}

}

</style>

</head>

<body>

<div>

<div class="box d1"></div>

<div class="box d2"></div>

<div class="box d3"></div>

<div class="box d4"></div>

</div>

</body>

</html>

image.png

繼續(xù)查找其他問(wèn)題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部