较小屏幕的HTML / CSS代码问题

时间:2017-10-03 01:39:23

标签: html css

当我为小屏幕设置显示器时,我的代码出现问题。我需要放在一边但黄色背景仍然显示。徽标buttom(汉堡菜单)也应浮动到右上角,而不是抬起头。

这是我的第一篇文章,谢谢你提前。

这是HTML代码。

    <!DOCTYPE html>
<html lang="en">
   <head>
      <title>Eating Well in Season</title>

      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <script src="modernizr.custom.40753.js"></script>
      <link href='http://fonts.googleapis.com/css?family=Alegreya+Sans' rel='stylesheet' type='text/css'>
      <link rel="stylesheet" href="styles.css">
      <script src="respond.min.js"></script>
      <link rel="shortcut icon" href="images/favicon.ico">
      <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
      <link rel="icon" sizes="192x192" href="images/android.png">
   </head>
   <body>
       <div class="header-nav-container">
         <p class="skipnavigation"><a href="contentstart">Skip navigation</a></p>
         <header>
            <h1>Eating Well in Season</h1>
             <div>
               <img src="images/logo.png" width="216" height="146" alt="">
            </div>
         </header>
         <nav class="sitenavigation">
            <div><img src="images/menu.png" width="63" height="57" alt="Show Navigation">
                <ul>
                    <li><a href="index.html">Home</a></li>
                    <li><a href="sources.html">Sources</a></li>
                    <li><a href="menus.html">Sample Menus</a></li>
                    <li><a href="pricing.html">Pricing</a></li>
                    <li><a href="signup.html">Sign Up</a></li>
                </ul>
            </div>
         </nav>
           </div>
      <div class="article-aside-outer-container">
         <div class="article-aside-inner-container">
            <article id="contentstart">
               <figure>
                  <img src="images/meal.jpg" width="450" height="299" alt="a dish containing fusilli pasta topped with chunks of grilled chicken and grilled squash,  green peas, shredded asiago cheese, and sprigs of mint">
                  <figcaption>Healthy meals.</figcaption>
               </figure>
               <figure>
                  <img src="images/veggies.jpg" width="450" height="298" alt="a woven basket containing beets, a bunch of radishes with greens, cucumbers, a bunch of green onions, and parsley">
                  <figcaption>Local sources.</figcaption>
               </figure>
               <figure>
                  <img src="images/delivery.jpg" width="450" height="299" alt="a box truck driving down a highway with buildings in the background">
                  <figcaption>Your schedule.</figcaption>
               </figure>
            </article>
            <aside>
               <h2>What&rsquo;s In Season</h2>
               <p>Baby Carrots</p>
               <p>Cardoons</p>
               <p>Chard</p>
               <p>Fiddleheads</p>
               <p>Mint</p>
               <p>Morels</p>
               <p>New Potatoes</p>
               <p>Ramps</p>
            </aside>
         </div>
      </div>
      <footer>
         <p>Eating Well in Season &bull; Glover, VT &bull; (802) 555-3947</p>
      </footer>
      <script src="script.js"></script>
   </body>
</html>

当我为小屏幕设置显示器时,我的代码出现问题。我需要放在一边但黄色背景仍然显示。徽标buttom(汉堡菜单)也应浮动到右上方而不是抬起头。

这是我的第一篇文章,谢谢你提前。

这是CSS代码。

/* reset styles */

html {
    font-size: 20px;
}
a,
article,
body,
div,
figcaption,
figure,
footer,
header,
h1,
h2,
h3,
img,
li,
nav,
p,
section,
ul {
    border: 0;
    padding: 0;
    margin: 0;
}
img {
    max-width: 100%;
    height: auto;
    width: auto;
}
ul {
    list-style-type: none;
}
/* body and page container */

body {
    font-family: "Alegreya Sans", Arial, Helvetica, sans-serif;
}
.header-nav-container {
    width: 100%;
    background-color: #a17f43;
    position: relative;
    overflow: auto;
}
.article-aside-outer-container {
    background-color: #aabd7e;
}
.article-aside-inner-container {
    margin: 0 auto;
    overflow: auto;
    background-color: rgb(246, 224, 65);
}
p {
    font-family: Verdana, Geneva, sans-serif;
}
/* skip navigation link */

p.skipnavigation a {
    position: absolute;
    left: -10000px;
}
p.skipnavigation a:focus {
    border: 2px solid black;
    left: auto;
    right: 1em;
    top: 1em;
    background-color: white;
    color: black;
    z-index: 2;
}
/* header section */

header {
    width: 50%;
    text-align: center;
    background-color: #a17f43;
    overflow: auto;
    float: left;
}
header h1 {
    margin: 1.2em 3% 0 3%;
    color: rgb(246, 224, 65);
    font-weight: normal;
    font-size: 2.9em;
    line-height: 0.8em;
    float: right;
}
header div {
    float: right;
    margin: 2% 0 1%;
    width: 26%;
}
/* site navigation */

nav.sitenavigation {
    max-width: 800px;
    margin-top: 3.4em;
    background-color: #a17f43;
    text-align: center;
    float: left;
}
.navigation-menu-button {
    display: none;
}
nav.sitenavigation li {
    margin: 0.5em;
    border: 4px solid black;
    border-radius: .8em;
    display: inline-block;
    background-color: black;
    font-family: Verdana, Geneva, sans-serif;
}
nav.sitenavigation a {
    padding: 0.2em 0.8em;
    display: inline-block;
    border-radius: .6em;
}
nav.sitenavigation a:link {
    color: rgb(246, 224, 65);
    text-decoration: none;
}
nav.sitenavigation a:visited {
    color: #eee;
}
nav.sitenavigation a:hover,
nav.sitenavigation a:focus {
    color: black;
    background-color: rgb(246, 224, 65);
}
nav.sitenavigation a:active {
    position: relative;
    top: 1px;
    left: 1px;
}
/* main content */

article {
    width: 80%;
    float: left;
    background-color: floralwhite;
}
article h2 {
    margin: 0.4em 0.4em 0;
    font-size: 1.8em;
    font-weight: normal;
}
article h3 {
    margin: 0.4em 0.4em 0;
    color: black;
    font-size: 1.4em;
    font-weight: normal;
}
article div p {
    text-align: center;
    margin-top: 1em;
}
article p {
    margin: 0 1em 0.4em 1.4em;
}
figure {
    width: 33.3333%;
    height: 700px;
    position: relative;
    float: left;
    background-size: cover;
    background-position: center;
}
figure:first-of-type {
    background-image: url("images/meal.jpg");
}
figure:nth-of-type(2n) {
    background-image: url("images/veggies.jpg");
}
figure:last-of-type {
    background-image: url("images/delivery.jpg");
}
figure img {
    width: 100%;
    display: none;
}
figcaption {
    width: 100%;
    padding: 0.25em 0;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    background-color: white;
    background-color: rgba(255, 255, 255, 0.7);
    position: absolute;
    top: 50%;
}
/* sidebar */

aside {
    width: 15%;
    padding: 2%;
    float: right;
}
aside h2 {
    padding: 0.4em;
    font-size: 1.8em;
    line-height: 0.8em;
    font-weight: normal;
}
aside p {
    padding-left: 1.4em;
}
/* footer section */

footer {
    padding: 0.6em;
    background-color: black;
    color: floralwhite;
    text-align: center;
    clear: both;
}
footer p {
    margin: 0.4em;
}
/*standard screen styles */

@media screen and (max-width: 1500px),
print {
    header {
        width: auto;
        max-width: 800px;
        margin: 0 auto;
        float: none;
    }
    header h1 {
        margin: 2% 4% 1%;
        float: left;
    }
    nav.sitenavigation {
        margin: 0 auto;
        float: none;
    }
}
/* small screen/tablet styles */

@media screen and (max-width: 1100px),
print {
    article {
        width: 62%;
    }
    figure {
        width: 100%;
        height: auto;
        margin-bottom: 1em;
        background-image: none;
        float: none;
    }
    figure img {
        display: block;
    }
    aside {
        width: 33.5%;
    }
}
/* handheld styles */

@media screen and (max-width: 800px) {
    header {
        margin: 0 95px 0 0;
        float: left;
    }
    header h1 {
        width: auto;
        margin: .4em 2%;
        float: left;
    }
    header div {
        display: none;
    }
    nav.sitenavigation {
        margin: 16px;
        position: absolute;
        right: 0;
        top: 0;
    }
    .navigation-menu-button {
        display: block;
        float: right;
    }
    nav.sitenavigation ul {
        display: none;
        position: fixed;
        top: 73px;
        right: 6px;
        z-index: 2;
    }
    nav.sitenavigation li {
        margin: 0;
        border: none;
        display: block;
        text-align: left;
        border-radius: 0;
    }
    nav.sitenavigation {
        width: 83%;
        border-radius: 0;
    }
    aside {
        display: none;
    }
}
/* print styles */

@media print {
    article,
    article h2,
    aside,
    body,
    .container,
    footer,
    header,
    header h1,
    header p {
        color: rgb(0, 0, 0);
        background-color: rgb(255, 255, 255);
    }
    header {
        margin: 0 0 1em;
    }
    header div {
        margin-top: 0;
    }
    header h1 {
        margin: 0 auto;
    }
    nav {
        display: none;
    }
    figure {
        border: 3px solid #000;
    }
}
@page {
    margin: 0.5in;
}

0 个答案:

没有答案