简体   繁体   English

仅在媒体屏幕中禁用浮动

[英]Disable Float in media screen only

I have been trying to disable float:left in media screen only . 我一直试图禁用float:left仅在媒体屏幕中float:left
But its still taking the float:left . 但它仍在float:left
I have float:left on none media screen. 我有float:left没有媒体屏幕。

 @media only screen and (max-width: 600px) { .twitter_page { padding: 0 108px 0 0; margin-left: -3px; float: none; } } .twitter_page { float: left; padding: 0 218px 0 0; /* border: solid; */ margin-right: -109px; margin-left: 54px; } 
 <div class="twitter_page"> <iframe id="twitter-widget-0" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="twitter-timeline twitter-timeline-rendered" style="position: static; visibility: visible; display: inline-block; width: 350px; height: 400px; padding: 0px; border: none; max-width: 100%; min-width: 180px; margin-top: 0px; margin-bottom: 0px; min-height: 200px;" data-widget-id="profile:AZLily_official" title="Twitterタイムライン"></iframe> <script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> </div> 

Website Link 网站链接

Your CSS is parsed from top to bottom. 您的CSS从上到下进行了解析。 Put the media query at the bottom of your document and you will get what you want. 将媒体查询放在文档的底部,您将得到您想要的内容。

 .twitter_page { float: left; padding: 0 218px 0 0; /* border: solid; */ margin-right: -109px; margin-left: 54px; } @media only screen and (max-width: 600px) { .twitter_page { padding: 0 108px 0 0; margin-left: -3px; float: none; } } 
 <div class="twitter_page"> <iframe id="twitter-widget-0" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="twitter-timeline twitter-timeline-rendered" style="position: static; visibility: visible; display: inline-block; width: 350px; height: 400px; padding: 0px; border: none; max-width: 100%; min-width: 180px; margin-top: 0px; margin-bottom: 0px; min-height: 200px;" data-widget-id="profile:AZLily_official" title="Twitterタイムライン"></iframe> <script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> </div> 

There is nothing wrong with your css but positioning problem. 你的css没有任何问题,但定位问题。 you wrote media css first then normal css, so in this case media css will override by normal css. 你先编写媒体css然后写普通的css,所以在这种情况下媒体css会被普通的css覆盖。

Try this 尝试这个

.twitter_page {
    float: left;
    padding: 0 218px 0 0;
    margin-right: -109px;
    margin-left: 54px;
}
@media only screen and (max-width: 600px){
    .twitter_page{
        padding: 0 108px 0 0;
        margin-left: -3px;
        float: none;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM