gpt4 book ai didi

css - 响应式媒体未显示预期结果

转载 作者:行者123 更新时间:2023-11-28 06:31:41 25 4
gpt4 key购买 nike

我正在响应式屏幕上工作。结果在某些时候没有显示。以下示例将有助于理解我的应用程序的机制。请建议我应该应用什么确切的媒体查询来获得所有设备结果。

我的代码是

html, body{margin:0; padding:0; height:100%;}

.container{height:100%; width:64em; margin:0 auto}
.container header{height:12%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:88%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position:relative; float:left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position:relative; float:left; width:92%}


@media only screen and (min-device-width : 1201px) {
body{background:yellow}
.container{width:100%; height:100%;}
.container header{height:12%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:88%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position: relative; float: left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position: relative; float:left; width:92%}
}

@media only screen and (max-device-width : 1200px) {
body{background:purple}
.container{width:100%; height:100%;}
.container header{height:8%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:92%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position: relative; float: left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position: relative; float:left; width:92%}
}

@media only screen and (max-device-width : 800px) {
body{background:orange}
.container{width:100%; height:100%;}
.container header{height:10%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:90%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position:relative; float: left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position: relative; float:left; width:92%}
}


@media only screen and (max-device-width : 640px) {
body{background:pink}
.container{width:100%; height:100%;}
.container header{height:14%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:86%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position:relative; float: left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position: relative; float:left; width:92%}
}

@media only screen and (max-device-width : 480px) {
body{background:green}
.container{ width:100%; height:100%}
.container header{height:14%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:86%;}
.container .wrapper nav{height:100%; background:#a1DFB9; position: relative; float: left; width:8%}
.container .wrapper article{height:100%; background:#FBF6CA; position:relative; float:left; width:92%}
}

@media only screen and (max-device-width : 320px) {
body{background:blue}
.container{ width:100%; height:100%}
.container header{height:14%; background:#D9DCA2; display: block; width:100%}
.container .wrapper{background:#EFF9B7; width:100%; height:86%;}
.container .wrapper nav{height:12%; background:#a1DFB9; position: relative; float: none; width:100%}
.container .wrapper article{height:88%; background:#FBF6CA; position:relative; float:none; width:100%}
}

</style>
</head>

<body>
<div class="container" id="container">
<header>header</header>
<div class="wrapper">
<nav>navigation</nav>
<article>article</article>
</div>
</div>

请指教。提前致谢。请记住,它适用于 ie、firefox、chrome 和 safari。

最佳答案

尝试一下,希望对您有所帮助。

    <style>
.container {
float: left;
width: 100%;
}
header {
background: #ddd none repeat scroll 0 0;
float: left;
padding: 10px;
text-align: center;
width: 100%;
}
.wrapper {
float: left;
width: 100%;
}
nav {
background: #D9DCA2 none repeat scroll 0 0;
float: left;
min-height: 150px;
padding: 2%;
text-align: center;
width: 46%;
}
article {
background: #EFF9B7 none repeat scroll 0 0;
float: right;
min-height: 150px;
padding: 2%;
text-align: center;
width: 46%;
}
footer {
background: #ddd none repeat scroll 0 0;
float: left;
padding: 10px;
text-align: center;
width: 100%;
}
@media only screen and (max-width: 480px)
{
nav {

padding: 2%;
width: 100%;
}
article {

padding: 2%;
width: 100%;
}
}
</style>

<div class="container" id="container">
<header>Header</header>
<div class="wrapper">
<nav>Navigation</nav>
<article>Article</article>
</div>
<footer>Footer</footer>
</div>

关于css - 响应式媒体未显示预期结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34925107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com