我的网络在iPad,iPhone,iPod上

时间:2016-02-10 19:10:14

标签: ios css iphone html5 ipad

我正在创建我的第一个网站,它变得很棒,看起来很棒,而且工作正常。我的问题是,我刚刚将文件上传到网络托管,看看它是如何在不同的设备上查看,在我的智能电视,我的Android手机,MacBook上看起来很棒,但在iPhone和iPad上看起来一切都很好看坏。

滑块不再溢出,widht不工作,甚至菜单按钮都消失了,导航器总是显示,请我需要一些帮助,是否有一些代码要添加,这样可以在IOs上运行设备

我一直在寻找互联网数小时试图找到解决方案,我找到了包含此代码的内容:

-webkit-appearance: none;

但是没有任何事情发生,一切都看起来很糟糕。谢谢你。

1 个答案:

答案 0 :(得分:0)

您正在使用需要添加前缀的CSS属性才能在-webkit浏览器中使用,即使在较新版本中,例如display:flexjustify-contenttransitionflex-direction,...

实际的解决方案是编写普通(最新)CSS,然后通过一个工具运行它,该工具将添加必要的前缀以使其与大多数浏览器兼容。它被称为自动前缀,您可以阅读更多相关信息 here 。良好的自动前缀工具连接到caniuse,可以根据各种特定需求进行配置(每个浏览器的最后三个版本的前缀,或者具有超过X使用百分比的所有浏览器的前缀,或两者之间的组合)。

以下是项目CSS文件的自动加前缀版本。将assets/css/header.css替换为:

*{
    margin: 0;
    padding: 0;    
    -webkit-appearance: none;
}

header{
    z-index: 1000;
    position: fixed;
    width: 100%;
    font-family: "roboto";
    background-color: rgba(0, 0, 0, 0.7);
}

#btn-menu{
    display: none;
}

header label{
    display: none;
    height: 30px;
    width: 30px;
    padding: 10px;
}

header label:hover{
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.8);
}

.menu ul{
    margin: 0;
    list-style: none;
    padding: 0;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: end;
    -webkit-justify-content: flex-end;
        -ms-flex-pack: end;
            justify-content: flex-end;
}

.menu li:hover{
    background-color: rgba(0, 0, 0, 0.8);
}

.menu li a{
    display: block;
    padding: 20px 20px 10px 20px;
    color: #fff;
    text-decoration: none;
}

@media (max-width: 768px) {
    header label {
        height: 60px;
        width: 60px;
        padding: 10px;
        display: block;
    }

    .menu{
        position: absolute;
        background-color: rgba(0, 0, 0, 0.7);
        width: 30%;
        margin-left: -30%;
        -webkit-transition: all 0.3s;
        transition: all 0.3s;
        }

    .menu ul{
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
            -ms-flex-direction: column;
                flex-direction: column;
    }
    #btn-menu:checked ~ .menu{
        margin: 0;
    }

}

assets/css/body.css与:

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-appearance: none;
}
body{
    z-index: 500;
    position: relative;
}

#logo{
    padding-top: 50px;
    position: absolute;
    left: 50%;
    top: 50%;
    -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
    }

#logo-image{
    width: 100%;
    max-width: 650px;
}

#containerslider{
    padding-top: 59px;
    position: relative;
    margin: auto;
    width: 100%;
    max-width: 1920px;
    overflow: hidden;
    }

.slider{
    text-align: center;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    width: 400%;
}

.slider .section{
    display: block;
    height:100%;
    width: 100%;
}

.slider img{
    display: block;
    height: 100%;
    width: 100%;
}

.btn-prev, .btn-next{
    width: 50px;
    height: 50px;
    color: white;
    font-family: sans-serif; "roboto";
    background: rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 50%;
    -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
    line-height: 50px;
    font-size: 22px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
}

.btn-prev{
    left: 10px;
}

.btn-next{
    right: 10px;
}

.btn-prev:hover, .btn-next:hover{
    background: rgba(0, 0, 0, 0.9);
}

.space{
    height: 2000px;
}