gpt4 book ai didi

css 媒体查询不起作用

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

我想让我的博客响应式,但我的媒体查询效果不佳。 css 代码在 max-width 600px 下工作,但在更小的宽度下不起作用。这是 css 代码(最大宽度:600 像素);

@media only screen and (max-width: 600px) {
.container{
height:100%;
}

#header{
max-height:162px;
}

#header #logo{
padding-bottom: 63px;
}


.nav {
max-width:599px;
position: relative;
float:center;
padding-bottom:120px;
top:159px;
left:-60px;
min-height: 40px;
padding-top:0;
}

.nav ul {
/*width: 599px;*/
padding: 5px 0;
position: absolute;
/*top: -13px;
left: -95px;*/
border: solid 1px #2FB8C8;
background: #2FB8C8 url(../images/icon-menu.png) no-repeat 10px 11px;
}

.nav li {
display: none; /* hide all <li> items */
margin: 0;
opacity:0.8;
}

.nav .current {
display: block; /* show only current <li> item */
}

.nav a {
display: block;
padding: 5px 5px 5px 32px;
text-align: left;
width:599px;
}

.nav .current a {
background: none;
color: #666;
}

/* on nav hover */
.nav ul:hover {
opacity:1;
}

.nav ul:hover li {
display: block;
margin: 0 0 5px;
}

.nav ul:hover .current {
background: url(../images/icon-check.png) no-repeat 10px 7px;
}

/* right nav */
.nav.right ul {
left: auto;
right: 0;
}

/* center nav */
.nav.center ul {
left: 50%;
margin-left: -90px;
}

.end-post-right{
font-family:'RobotoLight' ;
display:block;
width:400px;
/*padding-left:10px;*/
font-weight:normal;
letter-spacing: 0.8px;
}

.end-post-right li{
display:block;
margin-right: 15px;
float:left;
}

.end-post-right li p{
font-size:100%;
}

.end-post-right span{
font-size:100%;
}
}

这是另一个无效媒体查询的示例。我试试 iPhone 5;

/* Iphone <5 */
@media screen and (device-aspect-ratio: 2/3) {
.end-post-right{
font-family:'RobotoLight' ;
display:block;
/*width:400px;
padding-left:10px;*/
font-weight:normal;
letter-spacing: 0.8px;
}

.end-post-right li{
display:block;
/*margin-right: 15px;*/
float:left;
}

.end-post-right li p{
font-size:100%;
}

.end-post-right span{
font-size:100%;
}
}

预先感谢您的帮助

最佳答案

head 下添加此代码部分。

<meta name="viewport" content="width=device-width, initial-scale=1.0">

关于css 媒体查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16911115/

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