English 中文(简体)
如何使媒体成为媒体 问 题
原标题:How to make media Queries work css3

I have the CSSfile where i want to make @media work. The media should do the following: - In the mobile version, it should be only one column of information. - In tablet version (500-1024) it shall be two columns - In 1024-1240 width it should be three columns - In screen with widths and over 1240 there will be four columns.

我还要补充一句脚步,但继续站在上。

CSS

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

@charset "utf-8"; 
/*--playTime adobe colour--*/ 

body {
    margin: 5px; 
    background-color: rgb(247, 168, 84); 
}

/*-----978GS--------*/ 

.col {
    margin-left: 25px; 
    margin-right: 17px; 
    margin-bottom: 20px; 
    margin-top: 3px; 

}
.col-4 {
    width: 305px; 
    float: left;    
}
.col-6 {
    width: 474px; 
}

.col-12 {
    width: 978px; 
}
/*---end 978GS---*/ 

.img-responsive {
    width: 100%; 
}
.btn {
    border: 1px solid white;
    padding: 6px 10px;
    border-radius: 5px;
}

.btn-buy{    
    background-color: rgb(87, 218, 247);
    border-color: none; 
    font-family:  Fjalla One , sans-serif;
}
.product-box{
    background-color: rgb(145, 210, 84);
    padding: 5px;
    box-sizing: content-box;   
}
.product-box h3{
    color: peachpuff;
    font-family:  Fjalla One , sans-serif;
    font-size: 1.5em;
    margin-bottom: 0.5em;
    text-align: center;    
}
.product-box p{
    color: peachpuff;
    font-family:  Poppins , sans-serif;
    margin-top: 3px;    
}

#text-container-header{
    text-align: left bottom; 
}

.clearfix {
    clear: both;
}


/*--end main --*/

/*----*/

#mainPageBanner {
    height: 200px;
    background-color: ;
    background-size: 1050px;
    background-image: url(../Bilder/barcelona.jpg); 
    align-content: center; 
}

/*--end mainbanner--*/

/*---Start banner-*/

#mainPageHeader {
    height: 10em;
    background-color: rgb(242, 73, 7);
    text-align: left; 
    margin-bottom: 15px;     
}

#logo{
    color: peachpuff; 
    text-decoration: none; 
    font-size: 3em;
    font-family:  Fjalla One , sans-serif;
    display: inline-block;
    margin-top: 0.1em;
    margin-left: 0.10em;
    text-align: ; 
}

#mainPageNav{
    width: 978px; 
    margin: auto; 
    background-color: none;
}

#mainPageNav::after{
    content: ""; 
    display: block; 
    clear: both: 
}

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

li{
    float: left; 
    width: 80px; 
    position: relative; 
}

 a{
   background-color:
   color: rgb(255, 255, 0);
   font-family:  Fjalla One , sans-serif;
   text-align: left;
   padding-bottom: 10px;
   padding-top: 10px;
}   

/*--banner end--*/


/*--- Start Footer--*/ 

.mainPageFooter{
    text-align: center; 
    text-decoration-line: underline; 
}

/*--- ends footer --*/ 

/*---Start media Queries---*/

@media screen (min-width: 500px) and (max-width: 2040) {

    .col-4{
        width: 100%; 
    }
}

HTML

 <header id="mainPageHeader" class="col">
  <a id="logo" href="#ng">Zen</a>

  <nav id="mainPageNav" class="col-12">
    <ul>
      <li><a href="#ng">Home</a></li>
      <li><a href="#ng">Destinations</a></li>
      <li><a href="#ng">Travel</a></li>
      <li><a href="#ng">My Account</a></li>
      <li><a href="#ng">Contact</a></li>
    </ul>
  </nav>
  <!--end navi menu-->
</header>

<div id="mainPageBanner" class="col col-12">
  <div id="text-container-header">

    <p>Banner text</p>
  </div>
</div>

<!--End banner-->

<div id="mainContent">

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Las Vegas</h3>
      <img class="img-responsive" src="Bilder/lasvegas.jpg" alt="Las vegas">
      <p>A quem concursionibus ubi excepteur te officia. Ab ita sempiternum. Quae ingeniis ita aute cillum, legam tempor hic proident. Minim admodum iis laborum. O aute appellat aut multos imitarentur arbitror lorem incurreret. Varias aut admodum de malis,
        de doctrina cohaerescant.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Kyoto</h3>
      <img class="img-responsive" src="Bilder/kyoto.jpg" alt="Kyoto">
      <p>Commodo anim varias appellat illum se pariatur quorum quid in varias ad illum a aut quem laborum, malis nescius fidelissimae. Multos mentitum ne sint aute, est eu tractavissent. Doctrina quo commodo ea in labore si tamen. Se vidisse arbitrantur,
        vidisse instituendarum ut deserunt, voluptate o quamquam ea et fugiat relinqueret. Ab ea velit consequat, tempor malis summis aut quid quo admodum ea vidisse se mandaremus nulla admodum officia. </p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Tenerife</h3>
      <img class="img-responsive" src="Bilder/tenerife.jpg" alt="Tenerife">
      <p>Ab legam ullamco commodo. Offendit culpa ipsum senserit labore et quid officia cernantur se magna probant ne arbitrantur quo irure singulis quo consequat. Proident lorem labore singulis ipsum, sed tamen concursionibus. O nescius ex aliquip aut duis
        cernantur se lorem legam, magna litteris e voluptatibus, ad mentitum comprehenderit. Pariatur relinqueret quo cupidatat. Et duis sed lorem.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Paris</h3>
      <img class="img-responsive" src="Bilder/louvre.jpg" alt="Paris">
      <p>Laboris est quis, illum cernantur do praetermissum, quo ipsum cupidatat domesticarum si quamquam quorum varias ut esse ne do elit consequat efflorescere, hic si amet voluptate quo culpa est fabulas, incurreret sed quid commodo. Ubi lorem consequat
        an</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <div class="clearfix"></div>


  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Barcelona</h3>
      <img class="img-responsive" src="Bilder/barcelona.jpg" alt="Barcelona">
      <p>Ubi incurreret voluptatibus. Aut multos nulla ita pariatur et appellat amet aliqua consequat summis a cernantur eram aut aliquip eruditionem, vidisse noster ullamco incurreret. Expetendis dolore esse an tamen, an irure sempiternum. Ab a amet probant
        ubi quibusdam qui laboris, e nam fidelissimae ne possumus eu irure. Iis a aute legam amet te labore mandaremus ne quem fugiat. Deserunt arbitrantur est vidisse iis senserit id esse ne id excepteur quo laboris, voluptate quae dolore sed esse. Aut
        nulla elit velit tempor.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>London</h3>
      <img class="img-responsive" src="Bilder/london.jpg" alt="London">
      <p>Consequat quem consequat ex quibusdam ut fore, sed laboris ab laboris se a legam laborum. Legam arbitror ita officia, qui eu sunt possumus. Vidisse praesentibus id laboris, illum non mentitum ab e quorum malis fugiat tempor, ut eram legam sed proident.
        Esse exercitation possumus tamen fabulas. Ubi aliqua dolore illum singulis, eram an consequat ubi fore. Mandaremus multos cernantur cupidatat aut sed occaecat exercitation, quamquam familiaritatem an mentitum do doctrina do varias incididunt.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Tokyo</h3>
      <img class="img-responsive" src="Bilder/tokyo.jpg" alt="Tokyo">
      <p>Qui minim offendit. Quo velit proident adipisicing an culpa fabulas ex aliqua enim. Fugiat ne ita quid iudicem. Eram cernantur ad voluptate. Ingeniis non litteris. Velit offendit concursionibus, anim possumus offendit, irure sed te multos expetendis
        ea o malis quamquam transferrem. Quae a appellat si aute.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <article class="col col-4 col-8 product-box col-7">
    <div id="product-content-box">
      <h3>Oslo</h3>
      <img class="img-responsive" src="Bilder/oslo.jpg" alt="Tokyo">
      <p>Ullamco quid veniam ad quis. Legam proident se singulis a voluptate quem in commodo voluptatibus. Varias expetendis despicationes. Eram iis e illum aliquip nam nam magna cillum irure tempor aut duis mentitum se velit nulla, appellat elit varias
        probant velit. Ut noster duis o eiusmod. Fabulas fidelissimae iis commodo si mentitum cillum appellat iis probant concursionibus ita ullamco, nisi iudicem do dolor quem, arbitror eram possumus, ullamco summis pariatur, esse quibusdam relinqueret,
        labore exquisitaque occaecat esse quamquam.</p>
      <input class="btn btn-order" type="button" value="Bestill">
    </div>
  </article>

  <footer id="mainPageFooter">
    <p>----Zen----</p>
  </footer>

</div>
</div>
</div>
最佳回答

在你的媒体问询中,你可能没有<条码>和:

e.g.

@media screen and (min-width: 500px) and (max-width: 2040) { }
问题回答

增加px,max-width,并确保:

@media screen (min-width: 500px) and (max-width: 2040px) {
  body {
    display: none;    
  }
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签