媒体查询不适用于其他屏幕

我写了1200px的媒体查询。这对于1200px正常工作,但是由于我将其更改为1250px,因此无法正常工作。所有元素都会受到干扰。

@media only screen and (min-width: 1200px)
.sticky1 {
    position: absolute;
    margin-left: 58%;
    margin-top: 47%;
    width: 30%;
}
.growthp1 p {
    position: absolute;
    margin-left: -25%;
    font-size: 23px;
    margin-top: 45%;
}
}
<div class="row">
				<div class="col-md-6 col-sm-6 growthp1">
				  <p>The legal entity was incorporated.</p>
					<img src="images/growth/8.png" class="sticky1 img-fluid">
					<img src="images/growth/3.png" class="growthp1img img-fluid">
				</div>
					<div class="col-md-6 col-sm-6 col-xs-6">				
							</div>
</div>

媒体查询不适用于其他屏幕

媒体查询不适用于其他屏幕

yu8023fei 回答:媒体查询不适用于其他屏幕

您错过了{

CSS

@media only screen and (min-width: 1200px){
.sticky1 {
    position: absolute;
    margin-left: 58%;
    margin-top: 47%;
    width: 30%;
}
.growthp1 p {
    position: absolute;
    margin-left: -25%;
    font-size: 23px;
    margin-top: 45%;
}
}
,
for Laptop

/* ----------- Non-Retina Screens ----------- */
@media screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 1) { 
.sticky1 {
    position: absolute;
    margin-left: 58%;
    margin-top: 47%;
    width: 30%;
}
.growthp1 p {
    position: absolute;
    margin-left: -25%;
    font-size: 23px;
    margin-top: 45%;
}
}

/* ----------- Retina Screens ----------- */
@media screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 2)
  and (min-resolution: 192dpi) { 
.sticky1 {
    position: absolute;
    margin-left: 58%;
    margin-top: 47%;
    width: 30%;
}
.growthp1 p {
    position: absolute;
    margin-left: -25%;
    font-size: 23px;
    margin-top: 45%;
}
}
,

首先,我想通知您,您错过了{,请先完成此操作,然后根据需要遵循以下代码。您不需要使用:

@media screen and (min-device-width: 1200px) and (max-device-width: 1600px)

此代码仅在1200px - 1599px之间应用css,这对您而言不是一个好方法,因为这将需要更多的媒体查询才能应用于您的代码。

因此您可以使用以下方法将媒体查询应用于您的页面。

使用@media(min-width: value){}

// First Priority
@media (min-width: 1200px){
    //your css code
}
// Second Priority
@media (min-width: 1250px){
    //your css code
}

此媒体查询适用于屏幕尺寸1200及大于1200的屏幕。

使用@media(max-width: value){}

// First Priority
@media (max-width: 1249px){
    //your css code
}
// Second Priority
@media (max-width: 1199px){
    //your css code
}

此媒体查询适用于屏幕尺寸小于1200的屏幕。

尝试理解上述逻辑,如果您有任何疑问可以通过评论此答案问我,我将重播您的疑问。

谢谢...

,

如果您使用的是VBox,则top,left,right,bottom不能在margin-top,margin-left,margin-right,margin-right上使用。  请使用top,left,right,bottom然后工作

position : absolute

enter image description here

检查1250px的屏幕尺寸在我的设备上是否可用。

本文链接:https://www.f2er.com/3083160.html

大家都在问