响应max-width em不起作用

时间:2017-09-21 07:36:24

标签: html css responsive

我在此模板上创建了一个着陆页。

我用的是:

@media (max-width: 43.75em)

我打开Chrome开发工具来检查移动设备,但似乎没有转到@media (max-width: 43.75em)

响应但不起作用。

我在我的localhost中测试过:

使用相同的代码,它在Codepen或JSFiddle上进行测试,它可以工作。

我不知道我的问题:

您可以在我的笔中访问,选择{local}显示的Export as .zip

https://codepen.io/vanloc/pen/zEBdJy



@charset "UTF-8";
@import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
@import url(//fonts.googleapis.com/css?family=Open+Sans:400,700,800,300);
* {
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    width: 100%;
    height: 100%;
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, sans-serif;
    font-size: 100%;
    line-height: 1.45;
    color: #141414;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

img {
    max-width: 100%;
}

.btn {
    display: inline-block;
    margin: 1rem 0;
    color: white;
    font-weight: 500;
    font-size: 1.3rem;
    background: #007ece;
    letter-spacing: .02em;
    border: none;
    border-radius: 5px;
    padding: .8rem 1rem .9rem;
    text-shadow: 0 1px rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    background: #008ee8;
    color: #fff;
}

.btn:focus,
.btn:active,
.btn:focus:active {
    background: #006eb5;
    border-color: #006eb5;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.5) inset;
}

.container {
    margin: 0 auto;
    width: 90%;
    max-width: 900px;
}

header {
    color: white;
    background: #007ece;
    padding: 10rem 0;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

header h1 {
    font-size: 3rem;
    margin: 0 0 1rem;
}

header h2 {
    font-weight: 300;
    font-size: 1.5rem;
    margin: 0 0 1rem;
}

section {
    background: #fff;
    color: #1c262b;
    padding: 3.5rem 0;
}

section.section--primary {
    background: #007ece;
    color: #fff;
}

section.section--primary--alt {
    background: #27a4f4;
    color: #fff;
}

section.section--primary--light {
    background: rgba(0, 126, 206, 0.1);
}

section.section--grey {
    background: #1c262b;
    color: #fff;
}

section.section--grey--light {
    background: #29363e;
    color: #fff;
}

section h3 {
    text-align: center;
    font-size: 2rem;
    font-weight: 300;
    margin: 0 0 1rem;
}

section li {
    font-size: 1.2rem;
    font-weight: 300;
}

section p {
    font-size: 1.2rem;
    font-weight: 300;
}

.col,
.col-7,
.col-3,
.col-5 {
    margin: 0 1.5%;
    display: inline-block;
    vertical-align: top;
}

.col-7 {
    width: 64%;
}

.col-3 {
    width: 29%;
}

.col-5 {
    width: 30%;
}

.details {
    text-align: left;
}

.details h3 {
    font-size: 2rem;
    text-align: left;
}

.features {
    text-align: center;
    padding: 1rem;
}

.features:hover {
    background: rgba(255, 255, 255, 0.1);
}

.features i {
    font-size: 4rem;
    margin: 0 0 2rem 0;
}

.features p {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

blockquote {
    position: relative;
    margin: 0;
    padding: 0;
    text-align: center;
}

blockquote:before {
    display: inline-block;
    color: #007ece;
    font-size: 2rem;
    content: '\201C';
}

blockquote p {
    margin: 0;
    display: inline;
    font-size: 1.5rem;
}

blockquote cite {
    font-size: 1rem;
    display: block;
    margin: .5rem 0 0 1.2rem;
    text-style: italic;
}

blockquote cite:before {
    content: '–';
}

footer {
    background: #2d2b2a;
    color: #fff;
    padding: 2rem 0;
    text-align: center;
    font-size: .8rem;
    color: rgba(255, 255, 255, 0.4);
}

footer ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

footer ul li {
    display: inline-block;
}

footer ul li a {
    display: block;
    padding: .4rem .7rem;
    font-size: .9rem;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
}

footer ul li a:hover {
    color: white;
}

.text--center {
    text-align: center;
}

.text--left {
    text-align: left;
}

.bg-image {
    background: #007ece;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.bg-image:before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: #333 url("http://orbotix.wpengine.netdna-cdn.com/wp-content/uploads/2013/07/Faster-4H5B55491.jpg") no-repeat top center;
    background-size: cover;
    background-attachment: fixed;
    -webkit-filter: blur(5px);
    filter: blur(5px);
    opacity: .8;
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
}

.bg-image.bg-image-2:before {
    opacity: .6;
    background-image: url("http://orbotix.wpengine.netdna-cdn.com/wp-content/uploads/2013/07/Kids3.jpg");
    background-position: center center;
}

@media (max-width: 43.75em) {
    .btn {
        padding: .5rem .7rem .6rem;
        font-size: 1rem;
    }
    header {
        padding: 2rem 0;
    }
    header h1 {
        font-size: 2rem;
    }
    header h2 {
        font-size: 1.5rem;
    }
    section {
        padding: 2rem 0;
    }
    section h3 {
        font-size: 1.5rem;
    }
    .col-7 {
        width: 100%;
        margin: 0;
    }
    .col-3 {
        width: 100%;
        margin: 0;
    }
    .col-5 {
        width: 60%;
        margin: 0;
    }
    .details-img--ball {
        height: 200px;
        width: auto;
        margin: 0 auto;
    }
    .features {
        width: 100%;
        margin: 0;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }
    .features:last-child {
        border: none;
    }
    .features i {
        font-size: 1.5rem;
        width: 2rem;
        text-align: center;
        margin: 0 0 1rem 0;
        float: left;
    }
    .features p {
        margin-left: 3rem;
    }
    blockquote p {
        font-size: 1.2rem;
    }
    blockquote cite {
        font-size: .8rem;
    }
}

<header class="bg-image">
  <div class="container">
    <h1>Awesome Product</h1>
    <h2>Dat product subline is so nice it blows your mind.</h2>
    <a href="#" class="btn btn-transparent">Order yours now!</a>
  </div>
</header>

<section class="">
  <div class="container">
    <div class="col-3 text--center">
      <img src="http://store.storeimages.cdn-apple.com/4044/as-images.apple.com/is/image/AppleInc/aos/published/images/H/D1/HD162/HD162?wid=800&hei=800&fmt=jpeg&qlt=95&op_sharpen=0&resMode=bicub&op_usm=0.5,0.5,0,0&iccEmbed=0&layer=comp&.v=1400749861094" alt="" class="details-img--ball"/>
    </div>
    <div class="col-7 details">
      <h3>Product is so awesome.</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere temporibus omnis illum, officia. Architecto voluptatibus commodi voluptatem perspiciatis eos possimus, eius at molestias quaerat magnam? Odio qui quos ipsam natus.</p>
    </div>
  </div>
</section>

<section class="section--primary">
  <div class="container">
    <div class="col-3 features">
      <i class="fa fa-bolt"></i>
      <p>
        Product so awesome. Makes you awesome - go buy!
      </p>
    </div>
    <div class="col-3 features">
      <i class="fa fa-bank"></i>
      <p>
        Product so great. Makes you even greater - go buy now. Super cheap deal!
      </p>
    </div>
    <div class="col-3 features">
      <i class="fa fa-heart"></i>
      <p>
        Feel lonely? Go buy product and have a friend! 
      </p>
    </div>
  </div>
</section>

<section class="section--primary--alt">
  <div class="container">
    <h3>Take Product with you everywhere you go.</h3>
    <p>Product is all you need. Anywhere - ever. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita sapiente hic voluptatum quo sunt totam accusamus distinctio minus aliquid quis!</p>
  </div>
</section>

<section class="section--primary--light">
  <div class="container">
    <blockquote class="testimonial">
      <p>Love product. So nice! So good! Could not live without!</p>
      <cite>
        Satisfied Customer
      </cite>
    </blockquote>
  </div>
</section>


<section class="section--primary--alt bg-image bg-image-2">
  <div class="container text--center">
    <h3>Reasons to buy this product:</h3>
    <div class="col-5 text--left">
      <ul>
        <li>Its the best</li>
        <li>Its awesome</li>
        <li>It makes you happy</li>
        <li>It brings world peace</li>
        <li>Its free!</li>
      </ul>
    </div>
    <div class="col-5 text--left">
      <ul>
        <li>Its the best</li>
        <li>Its awesome</li>
        <li>It makes you happy</li>
        <li>It brings world peace</li>
        <li>Its free!</li>
      </ul>
    </div>
  </div>
</section>

<section class="text--center">
  <div class="container">
    <h3>Why you still reading?</h3>
    <a href="#" class="btn">Order yours now!</a>
  </div>
</section>

<footer>
  <div class="container">
    <ul>
      <li><a href="#">Impressum</a></li>
      <li><a href="#">Contact</a></li>
      <li><a href="#">Mainpage</a></li>
    </ul>
    <p>&copy; 2014 dat Company. All rights reserved.</p>
  </div>
</footer>
&#13;
&#13;
&#13;

0 个答案:

没有答案