测试响应时导航栏无法正确显示

时间:2017-11-26 11:14:09

标签: html css html5 css3 responsive-design

所以我有一个带导航栏的页面,在导航栏上,左边有一个img标志,右边有3个链接。当我在Chrome上测试设备的响应性时,导航栏会调整大小并向左移动,在其上留下一个空白区域。这是图片Nav bar not displaying fully

这是我的所有代码:



console.log('Coverage: ', __karma__.config.codeCoverage);
console.log('Test suite: ', __karma__.config.testSuite);

    @font-face {
        font-family: coyote;
        src: url(font/coyote.ttf);
    }
    html {
        width: 100%;
        height: 100%;
    }
    * {
        margin: 0;
        padding: 0;
    }
    body {
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    nav {
        background: #efefef;
        overflow: hidden;
        box-shadow: -2px -7px 47px 9px rgba(0, 0, 0, 0.35);
        -moz-box-shadow: -2px -7px 47px 9px rgba(0, 0, 0, 0.35);
        -webkit-box-shadow: -2px -7px 47px 9px rgba(0, 0, 0, 0.35);
        z-index: 999;
        margin: 0;
        padding: 0;
    }
    .logo-section {
        float: left;
        padding: 25px;
        font-family: serif;
    }
    .logo-left {
        width: 12%;
        float: left;
        overflow: none;
        display: block;
        margin: auto;
        transform: translateY(20%);
    }
    .hb-button {
        float: right;
        background-color: rgba(0, 0, 255, 0);
        color: black;
        border: none;
        font-size: 18px;
        padding: 9px 10px;
        border-radius: 3px;
        cursor: pointer;
        display: none;
        outline: none;
    }
    nav a {
        text-decoration: none;
        color: #282828;
        font-size: 16px;
    }
    nav ul {
        overflow: hidden;
        color: #fff;
        margin: 0;
        height: 68px;
        text-align: center;
        transition: max-height 0.5s;
        -webkit-transition: max-height 0.5s;
        -moz-transition: max-height 0.5s;
        -ms-transition: max-height 0.5s;
        -o-transition: max-height 0.5s;
    }
    nav ul li {
        float: right;
        display: inline-block;
        font-family: coyote;
    }
    li > a {
        color: #000;
        text-decoration: none;
        transition-timing-function: ease-in-out;
    }
    li > a:hover {
        color: #CF2034;
        transition: color .7s cubic-bezier(0.11, 0.7, 0, 1);
        -o-transition: color .7s cubic-bezier(0.11, 0.7, 0, 1);
        -moz-transition: color .7s cubic-bezier(0.11, 0.7, 0, 1);
        -webkit-transition: color .7s cubic-bezier(0.11, 0.7, 0, 1);
        transition-timing-function: ease-in-out;
    }
    li > a:after {
        position: absolute;
        bottom: 0;
        left: 0;
        display: block;
        width: 100%;
        height: 2px;
        background-color: #CF2034;
        content: "";
        transform: scale(0);
        -o-transition: transform 1s cubic-bezier(0.11, 0.7, 0, 1);
        -moz-transition: transform 1s cubic-bezier(0.11, 0.7, 0, 1);
        -webkit-transition: transform 1s cubic-bezier(0.11, 0.7, 0, 1);
        transition: transform 1s cubic-bezier(0.11, 0.7, 0, 1);
        transition-timing-function: ease-in-out;
    }
    li > a:hover:after {
        transform: scale(1);
    }
    .image-cont {
        position: absolute;
        min-width: 45%;
        min-height: 45%;
        top: 55%;
        left: 50%;
        overflow: visible;
    }
    .image {
        animation: load_up 2s forwards;
        -webkit-animation: load_up 2s forwards;
        -moz-animation: load_up 2s forwards;
        -o-animation: load_up 2s forwards;
        margin-top: -50%;
        margin-left: -50%;
        position: relative;
    }
    .image-cont2 {
        position: absolute;
        top: 35%;
        left: 50%;
        overflow: visible;
    }
    .image2 {
        display: none;
        animation: load_up 2s forwards;
        -webkit-animation: load_up 2s forwards;
        -moz-animation: load_up 2s forwards;
        -o-animation: load_up 2s forwards;
    }
    @media screen and (max-device-width: 1603px) and (min-device-width: 1081px) {
        * {
            margin: 0;
            padding: 0;
        }
        header {
            padding: 0;
            margin: 0;
        }
        nav {
            margin: 0;
            padding: 0;
            width: 100%;
        }
        nav ul {
            margin: 0;
            padding: 0;
            z-index: 99999;
        }
        nav ul li {
            margin 0;
        }
    }
    @media screen and (max-device-width: 1080px) {
        .logo-section {
            float: none;
        }
        nav ul {
            background: #ffffff;
            max-height: 0px;
            height: 0;
        }
        nav ul.show {
            max-width: 100%;
            max-height: 100%;
            z-index: 9999;
            height: 100%;
            width: 100%;
        }
        nav ul li {
            box-sizing: border-box;
            width: 100%;
            height: 100%;
            padding: 15px;
            padding-left: 25%;
            text-align: center;
        }
        nav a {
            display: block;
        }
        .hb-button {
            display: inline;
        }
        .image {
            display: none;
        }
        .image2 {
            display: block;
            margin-top: -35%;
            margin-left: -50%;
        }
        .logo-left {
            transform: translateY(-65%);
            padding-left: 15px;
            width: 10%;
        }
    }
    @keyframes load_up {
        0% {
            opacity: 0;
            transform: translateY(11%);
        }
        100% {
            opacity: 1;
            transform: translateY(0px);
        }
    }
    @-webkit-keyframes load_up {
        0% {
            opacity: 0;
            transform: translateY(11%);
        }
        100% {
            opacity: 1;
            transform: translateY(0px);
        }
    }
    @-moz-keyframes load_up {
        0% {
            opacity: 0;
            transform: translateY(11%);
        }
        100% {
            opacity: 1;
            transform: translateY(0px);
        }
    }
    @-o-keyframes load_up {
        0% {
            opacity: 0;
            transform: translateY(11%);
        }
        100% {
            opacity: 1;
            transform: translateY(0px);
        }
    }




谢谢你看看。 Fyi,我是新手。

1 个答案:

答案 0 :(得分:0)

你可以从两件事开始。

您需要在结束$link = mysqli_connect("localhost", "root", "", "tutorial"); $result=mysqli_query($link,"SELECT * FROM keluarga"); $nomor=9; /*diganti menjadi dua karena baris pertama dipakai untuk header*/ while($row=mysqli_fetch_array($result)){ $nomor++; $sheet ->setCellValue ( "D".$nomor, $row["nama"] ); $sheet ->setCellValue ( "E".$nomor, $row["alamat"] ); $sheet ->setCellValue ( "F".$nomor, $row["ayah"] ); $sheet ->setCellValue ( "G".$nomor, $row["ibu"] ); $sheet ->setCellValue ( "H".$nomor, $row["hobi"] ); } 标记后立即打开<body>标记,因此您可能需要考虑使用其他div来包含网页上的主要内容

</head>

其次,在HTML的第19行,您有

<html>
 <head> ... </head>
 <body>
  <header> ... </header>
   <div class="main-content"> ... </div>
 </body>
</html>

如果视口小于1920px,那么对这样的元素的宽度进行硬编码会给你带来困难。您可能希望删除此内联CSS,并将其替换为类。然后,您可以使用CSS media queries轻松操纵div的宽度,例如

HTML

<div style="min-width: 1920px; margin: 0 auto;">  

CSS

<div class="logo-wrap"> ... </div>   

修改

尝试将您的视口元标记更改为

.logo-wrap{
 ...
}  

@media (min-width: 1920px) {  
 min-width: 1920px; 
 margin: 0 auto;
}
祝你好运!