본문 바로가기

Computer/HTML, CSS, Javascript

[HTML]과제: 반응형 이미지

https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Mozilla_splash_page

 

Mozilla splash page - Learn web development | MDN

In this assessment, we'll test your knowledge of some of the techniques discussed in this module's articles, getting you to add some images and video to a funky splash page all about Mozilla!

developer.mozilla.org

 

폴더 구조

 

index.html

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Mozilla splash page</title>
    <link
      href="https://fonts.googleapis.com/css?family=Open+Sans:400,700"
      rel="stylesheet"
      type="text/css"
    />
    <style>
      /* header and body setup */

      html {
        font-family: "Open Sans", sans-serif;
        background: url(pattern.png);
      }

      body {
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
        background-color: white;
        position: relative;
      }

      /* Header styling */

      header {
        height: 150px;
      }

      header img {
        width: 100px;
        position: absolute;
        right: 32.5px;
        top: 32.5px;
      }

      h1 {
        font-size: 50px;
        line-height: 140px;
        margin: 0 0 0 32.5px;
      }

      /* main section and video styling */

      main {
        background: #ccc;
      }

      article {
        padding: 20px;
      }

      h2 {
        margin-top: 0;
      }

      p {
        line-height: 2;
      }

      iframe {
        float: left;
        margin: 0 20px 20px 0;
        max-width: 100%;
      }

      /* further info links */

      .further-info {
        clear: left;
        padding: 40px 0;
        background: #c13832;
        box-shadow: inset 0 3px 2px rgba(0, 0, 0, 0.5),
          inset 0 -3px 2px rgba(0, 0, 0, 0.5);
      }

      .further-info a {
        width: 25%;
        display: block;
        float: left;
      }

      .further-info img {
        max-width: 100%;
      }

      .clearfix {
        clear: both;
      }

      /* Red panda image */

      .red-panda img {
        display: block;
        max-width: 100%;
      }
    </style>
  </head>
  <body>
    <header>
      <h1>Mozilla</h1>
      <img
        srcset="
          originals/firefox_logo-only_RGB120.png 120px,
          originals/firefox_logo-only_RGB400.png 400px
        "
        sizes="(max-width: 500px) 120px, 400px"
        src="originals/firefox_logo-only_RGB400.png"
        alt="Firefox logo"
      />
      <!-- insert <img> element, link to the small
          version of the Firefox logo -->
    </header>

    <main>
      <article>
        <iframe
          width="400"
          height="270"
          src="https://www.youtube.com/embed/ojcNcvb1olg?si=Ii845bMpex3iQ_5n"
          title="YouTube video player"
          frameborder="0"
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
          referrerpolicy="strict-origin-when-cross-origin"
          allowfullscreen
        ></iframe>
        <!-- insert iframe from youtube -->

        <h2>Rocking the free web</h2>

        <p>
          Mozilla are a global community of technologists, thinkers, and
          builders, working together to keep the Internet alive and accessible,
          so people worldwide can be informed contributors and creators of the
          Web. We believe this act of human collaboration across an open
          platform is essential to individual growth and our collective future.
        </p>

        <p>
          Click on the images below to find more information about the cool
          stuff Mozilla does.
          <a href="https://www.flickr.com/photos/mathiasappel/21675551065/"
            >Red panda picture</a
          >
          by Mathias Appel.
        </p>
      </article>

      <div class="further-info">
        <!-- insert images with srcsets and sizes -->
        <a href="https://www.mozilla.org/en-US/firefox/new/">
          <img
            srcset="
              originals/firefox_logo-only_RGB120.png 120px,
              originals/firefox_logo-only_RGB400.png 400px
            "
            sizes="(max-width: 500px) 120px, 400px"
            src="originals/firefox_logo-only_RGB400.png"
            alt="Firefox logo"
          />
        </a>
        <a href="https://www.mozilla.org/">
          <img
            srcset="
              originals/mozilla-dinosaur-head120.png 120px,
              originals/mozilla-dinosaur-head400.png 400px
            "
            sizes="(max-width: 500px) 120px, 400px"
            src="originals/mozilla-dinosaur-head400.png"
            alt="Mozilla dinosaur head"
          />
        </a>
        <a href="https://addons.mozilla.org/">
          <img
            srcset="
              originals/firefox-addons120.png 120px,
              originals/firefox-addons.jpg    400px
            "
            sizes="(max-width: 500px) 120px, 400px"
            src="originals/firefox-addons.jpg"
            alt="Firefox addons"
          />
        </a>
        <a href="https://developer.mozilla.org/en-US/">
          <img src="originals/mdn.svg" alt="mdn" />
        </a>
        <div class="clearfix"></div>
      </div>

      <div class="red-panda">
        <picture>
          <source
            media="(max-width: 600px)"
            srcset="originals/red-panda600.png" />
          <source
            media="(min-width: 601px)"
            srcset="originals/red-panda1200.png" />
          <img src="originals/red-panda.jpg" alt="Red panda"
        /></picture>
        <!-- insert picture element -->
      </div>
    </main>
  </body>
</html>

 

오류 있으면 댓글 남겨 주세요. 감사합니다!

728x90