2017-08-28 1 views
0

Ich baue eine responsive Website und die wichtigsten DIV CSS funktioniert, wenn in der Desktop-Größe, aber wenn ich auf mobile Größe Größe der CSS in der Haupt-DIV funktioniert nicht mehr. Vielleicht hat es etwas damit zu tun, dass der @media-Bildschirm nicht richtig funktioniert? Ich bin jetzt seit zwei Monaten fest und kann das Problem nicht finden.Haupt DIV CSS funktioniert nicht

HTML & CSS:

/* Body styling for browser */ 
 
    /* HTML position/height/width */ 
 
     html { 
 
      position:relative; 
 
      height:100%; 
 
      width:100%; 
 
     } 
 
     
 
    /* Body height/margin/width/position thing */ 
 
     body { 
 
      position:absolute; 
 
      min-width:100%; 
 
      min-height:100%; 
 
      margin: 0px; 
 
     } 
 
     
 
/* Main */ 
 
    /* Main margin */ 
 
     @media screen and (min-width: 481px) { 
 
      div#main { 
 
       margin-bottom: 147px; 
 
       margin-left: 5px; 
 
       margin-right: 5px; 
 
       position: relative; 
 
       margin-top: 4px; 
 
      } 
 
      
 
     /* Main text styling paragraph */ 
 
      div#main p { 
 
       link-decoration: underline; 
 
       color: #000000; 
 
       font-family: "verdana",geneva,sans-serif; 
 
       margin-top: 4px; 
 
       text-align: left; 
 
      } 
 
/* Main Mobile */ 
 
    @media screen and (max-width: 481) { 
 
     /* Main margin mobile */ 
 
      div#main { 
 
       margin-bottom: 147px; 
 
       margin-left: 5px; 
 
       margin-right: 5px; 
 
       margin-top: 2px; 
 
       position: relative; 
 
      } 
 
     /* Main text styling paragraph mobile */ 
 
      div#main p { 
 
       link-decoration: underline; 
 
       color: #000000; 
 
       margin-top: 4px; 
 
       text-align: left; 
 
       font-family: "verdana",geneva,sans-serif; 
 
      } 
 
    } 
 
/* Other */ 
 
    ::selection { 
 
     background: #c1c1c1; 
 
    } 
 
    
 
    ::-moz-selection { 
 
     background: #c1c1c1; 
 
    }
<!DOCTYPE html> 
 
<html lang="en-us"> 
 
<head> 
 
    <meta charset="utf-8"/> 
 
    <link rel="stylesheet" type="text/css" href="/ncore/style/style.css"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
 
    <link rel="icon" type="image/ico" href="/ncore/style/favicon.ico"> 
 
    <title> 
 
    <?php 
 
     include "./config.php"; 
 
     echo $name; 
 
    ?> 
 
    - Home 
 
    </title> 
 
</head> 
 
<body> 
 
    <?php 
 
    include 'config.php'; 
 
    ?> 
 
    <div id="page"> 
 
     <div id="mbar"> 
 
      <?php 
 
      include './bar/mbar/mbar.php'; 
 
      ?> 
 
     </div> 
 
     <div id="main"> 
 
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus bibendum maximus est, non gravida ligula pretium ut. Maecenas eget fringilla ligula. Nulla imperdiet velit sit amet egestas faucibus. Donec sodales at nibh ac imperdiet. Donec tristique mollis tempus. Morbi ac orci sed metus facilisis blandit ac ut enim. Donec sit amet blandit tortor. Nunc suscipit, lorem in tempor pulvinar, justo turpis rutrum turpis, ut aliquam nisl velit varius lorem. Nam sollicitudin, turpis in vestibulum vehicula, dui orci auctor tellus, a bibendum arcu mi consequat odio. Aliquam eget maximus mauris. Phasellus sit amet eros quis libero malesuada pulvinar. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi eu placerat turpis. Phasellus aliquet laoreet ipsum, sit amet pellentesque lectus vestibulum in. Nam euismod, lorem vitae vulputate vulputate, est lectus auctor arcu, eu varius neque tortor ac lorem. Donec semper id metus nec egestas.</p> 
 
     </div> 
 
     <div id="cbar"> 
 
      <?php 
 
      include './bar/cbar/cbar.php'; 
 
      ?> 
 
     </div> 
 
     <div id="abar"> 
 
      <?php 
 
      include './bar/abar/abar.php'; 
 
      ?> 
 
     </div> 
 
     <div id="ebar"> 
 
      <?php 
 
      include './bar/ebar/ebar.php'; 
 
      ?> 
 
     </div> 
 
    </div> 
 
</body> 
 
</html>

ich diese Frage schon einmal gefragt, aber ich war nicht klar genug.

Antwort

2
@media screen and (max-width: 481) { 

sollte

sein
@media screen and (max-width: 481px) { 

Sie Ihre Einheiten nicht vergessen!

Auch sollten Sie sicherstellen, dass Ihre Regeln nicht überschneiden ... max 481px und min 481px werden beide Regeln effektiv bei genau 481. Sie sollten Ihre max bei 1px niedriger haben ... Oder Ihre min bei 1px höher .

+0

Vielen Dank! Ich fühle mich jetzt sehr dumm, haha. Ich habe auch einen @media-Bildschirm auf 480px eingestellt. – Shmotten