简体   繁体   English

为什么我的@media屏幕无法保存

[英]Why doesn't my @media screen save

I have been stuck with this problem or the past hour and its really annoying me. 我一直被这个问题困扰,或者在过去的一个小时里一直困扰着我。 I am making my website responsive to different screen sizes every time I write the code for it, I test it and it works. 每次我为网站编写代码,对其进行测试并都能正常工作时,我都会使网站响应不同的屏幕尺寸。 Then if I close the browser and reopen or reopen the code editor (brackets) the page loads like nothing happened. 然后,如果我关闭浏览器并重新打开或重新打开代码编辑器(括号),则页面加载将像什么都没有发生一样。 So I have re write everything again. 所以我重新写了一切。 This problem keeps recurring and I don't know why it wont just save. 这个问题不断发生,我不知道为什么它不会保存。 I can place my code since its over 2000 lines and I have just moved on to the responsive side of the site. 由于代码超过2000行,因此可以放置我的代码,而我只是移至该站点的响应端。

but I have applied this to every html file. 但是我已经将此应用于每个html文件。

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

and I have used this as my starting statement for the @media in the css 并且我已经将其用作css中@media的开始语句

@media screen and (max-width:)

CSS CSS

header img{
    margin-left: auto;
    margin-right: auto;
    display: block;
}

footer img{
    position:fixed;
    margin-left: auto;
    margin-right: auto;
    display: block;
    bottom: 5%;
    left: 40%;
    right: 40%;
}

.logo img{
    position:fixed;
    margin-left: auto;
    margin-right: auto;
    display: block;
    bottom: 2%;
    left: 40%;
    right: 40%;

}

.home img{
    position:fixed;
    margin-left: auto;
    margin-right: auto;
    display: block;
    bottom: 5%;
    left: 40%;
    right: 40%;
    width: 120px;
}


.socialmedia-twitter img {
    position:fixed;
    margin-left: auto;
    margin-right: auto;
    display: block;
    bottom: 5%;
    left: 20%;
    right: 40%;
}

.socialmedia-facebook img {
    position:fixed;
    margin-left: auto;
    margin-right: auto;
    display: block;
    bottom: 5%;
    right: 20%;
    left: 40%;
}

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

    header img{
        margin-left: auto;
        margin-right: auto;
        display: block;
    }

    footer img{
        position:fixed;
        margin-left: auto;
        margin-right: auto;
        display: block;
        bottom: 5%;
        left: 40%;
        right: 40%;
    }

    .logo img{
        position:fixed;
        margin-left: auto;
        margin-right: auto;
        display: block;
        bottom: 2%;
        left: 40%;
        right: 40%;
    }

    .home img{
        position:fixed;
        margin-left: auto;
        margin-right: auto;
        display: block;
        bottom: 5%;
        left: 40%;
        right: 40%;
        width: 120px;
    }


    .socialmedia-twitter img {
        position:fixed;
        margin-left: auto;
        margin-right: auto;
        display: block;
        bottom: 5%;
        right: 50%;

    }

    .socialmedia-facebook img {
        position:fixed;
        margin-left: auto;
        margin-right: auto;
        display: block;
        bottom: 5%;
        right: 20%;
        left: 50%;
    }

}

There are lots of reasons why this could have happen, but i think it is the obvious one. 发生这种情况的原因有很多,但我认为这是显而易见的原因。 if you reach a sertan width @media screen and (max-width: 640px) this css wil be enabled, in order to work his way back you need to define the width your working in. While working on the design, it is also recommended to turn of any cache methods. 如果达到Sertan宽度@media屏幕并且(最大宽度:640像素)将启用此CSS,则要返回原位,您需要定义工作的宽度。在设计时,还建议打开任何缓存方法。

So for this to work proberly you will prob need three @media screen properties. 因此,要使其正常工作,您可能需要三个@media屏幕属性。

Examples 例子

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

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