简体   繁体   English

为什么我的网站在chrome和firefox中的外观与使用flexbox的Safari中的外观不同?

[英]Why does my website looks different in chrome and firefox than it does in Safari using flexbox?

I am new to HTML and CSS and have very basic knowledge of both. 我是HTML和CSS的新手,并且都具有非常基础的知识。 I am creating a test website and used a tutorial from Treehouse for part of it. 我正在创建一个测试网站,并使用了部分来自Treehouse的教程。 I wanted to use flexbox for the layout. 我想使用flexbox进行布局。 I have created the website, and it looks like I want it to on a smartphone, it's one single column, but when it moves to an iPad screen I want the columns at the bottom to become 2 columns, and on a desktop or mbpro screen I would like all 3 columns to show up. 我已经创建了网站,看起来就像我希望在智能手机上看到的那样,它是一个单独的列,但是当它移至iPad屏幕时,我希望底部的列变成2列,而在台式机或mbpro屏幕上我希望所有3列都显示出来。

In chrome and firefox, my website looks exactly how I want it to. 在chrome和firefox中,我的网站完全符合我的期望。 However in Safari the website does not look right. 但是,在Safari中,该网站看起来不正确。 The banner in blue is offset to the left on a desktop, and the columns at the bottom are in 3, but are way disproportionate. 蓝色的横幅在桌面上向左偏移,底部的列在3中,但不成比例。 The first column is huge, and the last two are very slim. 第一列很大,最后两列很细。

I was hoping someone would be able to help me look in the right direction. 我希望有人能够帮助我朝正确的方向看。 I have been learning HTML and CSS for a couple of weeks and am not close to proficient. 我学习HTML和CSS已有两周了,而且还不太熟练。 I just learned about flexbox for first time this past weekend. 上个周末,我才刚刚第一次了解flexbox。 I would like the final page to be a single column on smartphones. 我希望最后一页在智能手机上成为一栏。 then on iPad, I would like the menu at the top to be in a single column row and the company name and hours etc in the blue ribbon to be centered. 然后在iPad上,我希望顶部的菜单在单列中,而公司名称和营业时间等应在蓝带中居中。 And then the bottom column is split into 2, and 1 on the bottom. 然后将底部的列分为2,底部分为1。 Then on an iPad Pro, or desktop screen I would like the same as iPad, except the final column splits into 3 equal spaces. 然后在iPad Pro或台式机屏幕上,我希望与iPad一样,除了最后一列分为3个相等的空格。

As I have stated, at this time my chrome and firefox is doing exactly what I want, only Safari is not working right. 正如我已经说过的,这时我的chrome和firefox完全可以实现我想要的功能,只有Safari无法正常工作。

Correct page 正确的页面

Incorrect page using Safari 使用Safari的页面不正确

Below is the HTML 以下是HTML

    <!DOCTYPE html>
    <html>
      <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">                  <title>Name of Company</title>
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>

<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/oilChangeStyles.css">

<div id="fb-root">
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
          fjs.parentNode.insertBefore(js, fjs);
          }(document, 'script', 'facebook-jssdk'));
        </script>
</div>

</head>
   <body>


<header class="main-header">
    <h1 class="name"><a href="#">Name of business</a></h1>
        <ul class="main-nav">
            <li><a href="#">Oil changes</a></li>
            <li><a href="#">Trans flush</a></li>
            <li><a href="#">Trans tune ups</a></li>
            <li><a href="#">Coolant Services</a></li>
            <li><a href="#">4x4 services</a></li>
            <li><a href="#">Air filters</a></li>
        </ul><!-- .main-nav -->


</header><!-- .main-header -->   

<div class="banner">
    <div class="left-side col">
        <a href="tel:800-800-8000">(800) 800-8000</a><br />
        <a href="https://google.com"  target="_blank">1000 West Columbia Blvd<br />
                                                                            Ste 100<br />
                                                                Dearborn<br /> MI 45885</a>
    </div><!-- .left-side -->   
        <div class="center col">
            <h1 class="headline">Company name</h1>
            <span class="tagline">"Your one stop shop for all your auto needs."</span><br />
        </div><!-- center col -->
    <div class="right-side col">            
            Mon 8:30 am - 6:30 pm<br /> 
            Tue 8:30 am - 6:30 pm<br />     
            Wed 8:30 am - 6:30 pm<br />     
            Thu 8:30 am - 6:30 pm<br />     
            Fri 8:30 am - 6:30 pm<br />     
            Sat 8:30 am - 5:00 pm<br />     
            Sun Closed<br />    
    </div><!-- right-side col -->
</div><!--/.banner-->

<div class="pictures">
    <img class="item-1" src="img/frontOfBusiness.png" alt="Front of Business">
    <img class="item-2" src="img/logo.png" alt="Logo">
    <!-- <img class="item-3" src="img/interiorBay.png" alt="The interior bay">   -->
</div><!-- .pictures -->


<div class="row">   



    <div class="primary col">
        <h2>Welcome!</h2>


        <p>At Company name we pride ourselves in customer service and are always willing to go the extra mile to make our customers happy. Drop-ins are always welcome for our wide variety of auto care services. Stop in anytime and talk to our friendly techs about the top notch servicing we provide at a great price. Here at the 1 stop, EVERY SINGLE customer is valued and important to us.

.

</div><!--/.primary col-->
           <div class="secondary col">


  <h3>We offer:</h3>
            <ul>
                <li>10 Minute Oil Changes</li>
                <li>Transmission Services</li>
                <li>Coolant Services</li>
                <li>4x4 Servicing</li>
                <li>Power Steering Servicing</li>
                <li>Replacement of Air Filters, Wiper Blades & Light Bulbs</li>
                <li>Additive Services</li>
            </ul>   
    </div><!-- end .secondary col -->
    <div class="third col">
            <h3>Our specials include:</h3>
            <ul>
                <li>Everyday $19.95 oil change (up to 5qts, 5-30 and 10-30 weight only, standard canister oil filters only internals have fees)</li>
                <li>$69.95-$89.95 Transmission Service - beats any competitors price! </li>
                <li>$5 off any Valvoline Maxlife change</li>
                <li>$10 off any Valvoline Syn power change</li>
                <li>Multi-Service layered discounts, so the more services you combine, the more you save!</li>
            </ul>   
        </div><!-- end .third col-->
</div><!-- end .row -->

<footer class="main-footer">

<div class="fb-like" data-href="https://www.facebook.com/pages/Company name" data-width="50px" data-layout="button_count" data-action="like" data-show-faces="true" data-s  hare="true"></div>

    <div class="footer-inner">
        <span>&copy;2016 Oil Change.</span>
    </div>
</footer>

Here is the CSS 这是CSS

/* ================================= 
  Base Element Styles
==================================== */

* {
    box-sizing: border-box;
}
body {
    font-family: 'Varela Round', sans-serif;
    line-height: 1.6;
    color: #3a3a3a;
    margin: 0;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
p {
    font-size: .95em;
}
h2,
h3,
a {
    color: #093a58;
}
h1,
h2,
h3 {
    margin-top: 0;
}
a {
    text-decoration: none;
}
img {
    max-width: 100%;
}

/* ================================= 
  Base Layout Styles
==================================== */

/* ---- Navigation ---- */

.name {
    font-size: 1.35em;
    margin: 0;
}
.main-nav {
    margin-top: 5px;
}
.name a,
.main-nav a {
    text-align: center;
    display: block;
    padding: 10px 15px;
}
.main-nav a {
    font-size: .95em;
    color: #243432;
    text-transform: uppercase;
}
.main-nav a:hover {
    color: #91aab6;
}

/* ---- Layout Containers ---- */

.main-header {
    padding-top: .35em;
    padding-bottom: .35em;
}

.banner,
.main-footer {
    text-align: center;
}

.banner {
    color: #fff;
    background: #130897;
    padding: 1em 0;
    margin-bottom: 24px;
}

.col {
    padding-right: 1em;
    padding-left: 1em;
}

.main-footer {
    background: #130897;
    padding: 2em 0;
    margin-top: 30px;
}




/* ---- Page Elements ---- */

.item-1,
.item-2,
.item-3 {
    width: auto;
    margin-top: 8px;
    margin-left: 20px;
    box-shadow: 10px 10px 5px #000;
}
.headline {
    margin-bottom: 0;
}
.feat-img {
    border-radius: 5px;
}

.footer-inner {
    color: #fff;
}

.col h2 {
    margin-top: 20px;
}

.col h3 {
    color: white;
}

.tagline {
    margin-top: 10px;
    font-style: italic;
}


.left-side a {
    color: white;
}

.left-side a:hover {
    color: red;
}


.map {
    float: left;
    margin-left: 150px;
}


.secondary h3,
.third h3 {
    color: black;
}

.secondary ul,
.third ul {
    list-style: disc;
    margin-left: 20px;
    padding-left: 20px;
}

.row {
    padding-top: 30px;
}


.fb-like {
    padding-bottom: 20px;
}

/* ================================= 
  Media Queries
==================================== */

@media (min-width: 769px) {

      body {
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      }

    .main-header,
    .row,
    .footer-inner{
        width: 80%;
        margin: 0 auto;
        max-width: 1150px;
    }

    .tagline {
        font-size: 1.4em;
    }


.pictures {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
    width: auto;

    }

.row {
  display: flex;
  }

    .main-header,
    .main-nav,
    .banner {
        display: flex;
    }
/*

    .main-header {
        flex-direction: column;
        align-items: center;
    }

    /*
.banner {
        flex-direction: column;
        align-items: center;
        flex-wrap: wrap;
        flex-grow: 1;
    }
*/


    /*
.col {
        flex: 1 100%;
        justify-content: space-between;
    }
*/



}

@media (min-width: 880px) {

    .row {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }


    .col {
        flex: 1 50%;
        justify-content: space-between;
    }

@media (min-width: 1025px) {

    .main-header {
        flex-direction: row;
        justify-content: space-between;
    }

    .col {
        flex: 1 33%;
        justify-content: space-between;
    }

}



*/

Note that flexbox is supported by all major browsers, except IE 8 & 9 . 请注意, 除了IE 8和9之外 ,所有主要浏览器都支持flexbox。

Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes . 某些最新的浏览器版本(例如Safari 8和IE10)需要供应商前缀 This appears to be what you're missing. 这似乎是您所缺少的。

For a quick way to add all the prefixes you need, post your CSS in the left panel here: Autoprefixer . 要快速添加所需的所有前缀,请在左侧面板中的以下位置发布CSS: Autoprefixer

To Safari you need to write -webkit-flex, and to IE 10 - 11 you need to write -ms-flex. 对于Safari,您需要编写-webkit-flex,对于IE 10-11,您需要编写-ms-flex。

You can read more about flex here: http://www.w3schools.com/cssref/css3_pr_flex.asp 您可以在此处阅读有关flex的更多信息: http : //www.w3schools.com/cssref/css3_pr_flex.asp

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

相关问题 为什么我的网站在mozilla firefox和chrome上看起来不同? - Why does my website looks different on mozilla firefox and chrome? IE中的字体与Firefox和Chrome中的字体不同...为什么? - Font looks different in IE than it does in Firefox and Chrome…why? 网站 UI 在 safari 中看起来不太好,但在 chrome 和 firefox 中看起来很完美 - The website UI does not look fine in safari but looks perfect in chrome and firefox 我的网站在Firefox中的浏览器与Chrome浏览器不同 - My website looks different in Firefox from Chrome 为什么我的网站可以在某些Chrome,Opera和Safari中使用,但不适用于FireFox或IE? - Why does my website work in some Chrome, Opera, and Safari but not FireFox or IE? 为什么Chrome,Firefox和IE上的文本看起来比Safari模糊? - Why does text on Chrome, Firefox, and IE look fuzzier than Safari? 为什么我的页面在Firefox中工作但在Safari或Chrome中不起作用? - Why does my page work in Firefox but not in Safari or Chrome? 在Chrome / Firefox / Safari中,高度看起来有所不同 - Height looks different in Chrome / Firefox / Safari Chrome 和 Safari 之间的网站看起来不同 - Website looks different between Chrome and Safari 网站在mozilla firefox和chrome中看起来有所不同 - website looks different in mozilla firefox and chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM