jquery – 删除媒体查询导航栏中的所有空格

我为宽度为414px且尺寸较小或iPhone 6加“肖像”的手机创建了媒体查询.我正在尝试制作一个下拉菜单,我得到了一切工作,它只是导航栏没有移动.我给了它“margin:0,padding:0”左右,以及所有上面没有任何内容.如果您在“检查元素”中打开我的网站并选择“iPhone 6plus”版本,您可以看到我的导航栏有很多空白区域,需要左对齐并清除所有白色边距和填充.有人可以告诉我如何将它带回左上角或地图集中删除我的媒体查询中的所有空白区域“
iphone 6plus”或屏幕尺寸小于414.我的html将上传到此处,其余的将是在代码笔中.

演示:
http://codepen.io/anon/pen/NpwbJp

屏幕截图
https://i.gyazo.com/605e7bb39ef78197fa24e2dcdab03427.png

HTML

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link href="https://fonts.googleapis.com/css?family=Nunito:700" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Baloo" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 

             <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>


        <link rel="stylesheet" type="text/css" href="magicstyle.css">

        </head>     
        <body>
            <!-- Section for Jobs Popup -->
            <div id="top-bar">
                  <a class="burger-nav"></a>
                    <ul id="nav-menu" class="testAgain">
                    <li id="job" class="testAgain">Job</li>
                    <li id="contact" class="testAgain">Contact</li>
                    <li id="press" class="testAgain">Press</li>
                    <li id="legal" class="testAgain">Legal</li>
                    <li id="support" class="testAgain">Support</li>


                </ul>
                    <!--<div id="nav-menu">
                    <span id="job">Jobs</span>
                    <span id="contact">Contact</span>
                    <span id="press">Press</span>
                    <span id="legal">Legal</span>
                    <span id="support">Support</span>

                    </div> -->


                </div>
                 <div id="job-popup">
            <div class="x-div1"><img class="x-icon1" id="fadeX1" src="Pictures/web%20x%20icon%20white.png" alt="Text alternative when image is not available"></div>
            <div id="job-content">

                <h1 id="jobWords"></h1>

                </div>

            </div>
            <!-- Section for Contact Popup -->
            <div id="contact-popup">
            <div class="x-div2"><img class="x-icon2" id="fadeX2" src="Pictures/web%20x%20icon%20white.png"></div>
            <div id="contact-content">

                <h1 id="contactWords"></h1>

                </div>

            </div>

            <!-- Section for Press Popu -->
             <div id="press-popup">
            <div class="x-div3"><img class="x-icon3" id="fadeX3" src="Pictures/web%20x%20icon%20white.png"></div>
            <div id="press-content">

                <h1 id="pressWords"></h1>

                </div>

            </div>

            <div id="legal-popup">
            <div class="x-div4"><img class="x-icon4" id="fadeX4" src="Pictures/web%20x%20icon%20white.png"></div>
            <div id="legal-content">

                <h1 id="legalWords"></h1>

                </div>

            </div>

            <div id="support-popup">
            <div class="x-div5"><img class="x-icon5" id="fadeX5" src="Pictures/web%20x%20icon%20white.png"></div>
            <div id="support-content">

                <h1 id="supportWords"></h1>

                </div>

            </div>




            <div id="container">


                <div id="name-div">
                <h1 id="name">Open Touch</h1>
                </div>
                <ul class="bubbles">

            <li id="firstCircle"></li>
            <li id="secondCircle"></li>
            <li id="thirdCircle"></li>
            <li id="fourthCircle"></li>
            <li id="fifthCircle"></li>
            <li id="sixthCircle"></li>



            </ul>



            </div>


        </body>





</html>

在这一点上的任何帮助非常感谢.

最佳答案 问题出在CSS布局上. @media查询的顺序很重要.

所以在这里你的

@media screen and (max-width:770px)

优先于

@media screen and (max-width: 414px)

只是因为它在代码中排在最后,在这种情况下,max-width:414也遵循max-width 770px的规则,因为414px以下的任何东西也低于770px.

所以只需更改CSS文件中代码的顺序即可.

在此之后,对于id标签上的边距#nav-menu put margin:0;

希望这可以帮助 :)

点赞