"Mozilla splash page" assessment

Hi, I have finished the assement " Mozilla splash page"
Can you check my code, please?

<!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 src="pictures/firefoxlogo120.png" alt="logo">
    </header>

    <main>
      <article>
        <iframe width="400" height="280" src="https://www.youtube.com/embed/ojcNcvb1olg" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
        

        <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">
        
        <a href="https://www.mozilla.org/en-US/firefox/new/">
        <img 
         srcset="pictures/firefoxlogo120.png 120w,
                 pictures/firefoxlogo400.png 400w"

        sizes="(max-width:480px) 120px,
              400px"
       src="pictures/firefoxlogo.png" alt="it is firefox_logo">
        
        </a>

          
        <a href="https://www.mozilla.org/">
          <img
         
          srcset="pictures/mozilladinosaur120.png 120w,
                 pictures/mozilladinosaur400.png 400w"

        sizes="(max-width:480px) 120px,
              400px"
       src="pictures/mozilladinosaur.png" alt="it is dinosaur_logo">
        

          >
        </a>
        <a href="https://addons.mozilla.org/">
          <img
         srcset="pictures/firefoxaddons120.jpg 120w,
                 pictures/firefoxaddons.jpg 400w"

        sizes="(max-width:480px) 120px,
              400px"
       src="pictures/firefoxaddons.jpg" alt="it is firefoxaddons_logo">
          >
        </a>


        <a href="https://developer.mozilla.org/en-US/">
          <img src="pictures/mdn.svg" alt="it is mdn_logo">

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

      <div class="red-panda">
        <picture>
          <source media="(max-width:600px)" srcset="pictures/red-panda600.jpg">
            <source media="(min-width:601px)" srcset="pictures/red-panda1200.jpg" >
              <img src="pictures/red-panda.jpg" alt="This is red panda">
        </picture>
      </div>

    </main>
  </body>
</html>

中文区资源链接不能下载,怎么办,请问是网络问题吗

When the width of device is shorter than 500 (the first media condition is satisfied), the width of image is 80px.
 However when the width of device is longer than 501 (the second media condition is satisfied), the width of image is not 320px, but change with the width of the device. 
I will be appreicated if you could tell me why? 
 <img
        
        srcset="../SRC/img/firefox_logo-400px.png 400w,
                ../SRC/img/firefox_logo-120px.png 120w"

        sizes="(max-width:500px) 80px,
              (min-width:501px) 320px"
        src="../SRC/img/firefox_logo-400px.png" alt="logo"
>`预格式化文本`

Hello everyone, can someone check my assignment?

https://jsfiddle.net/demnnys/4fkor7ae/

The task itself:

Hi @demnnys :wave:

I don’t know who flagged your post. Maybe it was because you replied to this old post. So for future tasks make sure to create a new topic. It’s also easier for us to notice it.

Anyways, I will now assess your work and give you feedback soon.
Michael

Okay. I now had a look at your work. As a general note: When working with pictures it would be better to use for example https://glitch.com where you can upload images.
That being said, you did a very good work. I have only two small remarks:

  • When using srcset and sizes you should use the same widths in both attributes. This would be correct (481px => 400px):
<img srcset="firefox-logo120.png 120w,
             firefox-logo400.png 400w"
     sizes="(max-width: 500px) 120px,
            400px"
     src="firefox-logo400.png" alt="Download Firefox">
  • No need for the second <source> in the <picture> element. When the condition of the first <source> isn’t fulfilled the <img> gets automatically selected.

I hope that helps. If you have any further questions feel free to ask :slightly_smiling_face:

that weird a person flag his post but never show up to assist even other post

let us kick the flag hhhhhhhh
kick-elephant

and have a nice day @mikoMK @demnnys

Greetings from Russia!
Thank you so much for your course!

I’m glad to post it here.
It all works.
But I don’t scrupulously understand when I have to use which exactly “sizes” attribute. So made it by intuition.

Thank you in advance,

‘’’

<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>
<header>

  <h1>Mozilla</h1>

  <a href="#"></a><img src='firefox_logo120.png' alt='firefox logo'></a>

  <!-- insert <img> element, link to the small

      version of the Firefox logo -->

   

</header>

<main>

  <article>

    <iframe width="400" height="225" src="https://www.youtube.com/embed/ojcNcvb1olg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" 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='firefox_logo120.png 120w,

                firefox_logo400.png 400w'

        sizes= '(max-width: 100px) 120px,

                (max-width: 380px) 400px

                800px'

        src='firefox_logo120.png' alt ='firefox logo'>

    </a>

    <a href="https://www.mozilla.org/">

      <img

      srcset='mozilla-dinosaur-head120.png 120w,

              mozilla-dinosaur-head400.png 400w'

      sizes= '(max-width: 100px) 120px,

              (max-width: 380px) 400px

              800px'

      src='mozilla-dinosaur-head.png' alt='dino head'>

    </a>

    <a href="https://addons.mozilla.org/">

      <img

      srcset='firefox-addons120.png 120w,

              firefox-addons400.png 400w'

      sizes= '(max-width: 100px) 120px,

              (max-width: 380px) 400px

              800px'

      src='firefox-addons120.png' alt ='addons-logo'>

    </a>

    <a href="https://developer.mozilla.org/en-US/">

      <img src='mdn.svg' alt='MDN logo'>

    </a>

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

  </div>

  <div class="red-panda">

    <picture>

        <source media='(max-width: 599px)' srcset='red-panda600.png'>

        <img src='red-panda1200.png' alt='Red panda in the trees'>

    </picture>

    <!-- insert picture element -->

  </div>

</main>
'''

duprya vecher (good evening) @tomich not sure if i spell it right or not

welcome to the mdn world
could you please create new post and put your code on any online service like https://codepen.io/ or https://jsfiddle.net/ and just share that link in the new post you create and a link to the topic or task would be much appreciated

thanks and have a nice day :slight_smile:

For this particular task I think a good choice for the online editor would be glitch.com. Since there’s the possibility to upload the prepared images created in the first part.

1 Like

Hello everybody! Can someone check my code, please and tell me why the <sizes> attribute is not working? For any screen width, an image is displayed in 400px, although it should display an image in 120px with a screen width less than or equal to 480px.

<div class="further-info">

        <!-- insert images with srcsets and sizes -->

        <a href="https://www.mozilla.org/en-US/firefox/new/">

          <img  srcset="firefox_logo-only_RGB-120.png 120w,

                        firefox_logo-only_RGB-400.png 400w"

                sizes="(max-width: 480px) 120px, 400px"

                src="firefox_logo-only_RGB-400.png" alt="Mozilla">

        </a>

        <a href="https://www.mozilla.org/">

          <img srcset="mozilla-dinosaur-head-120.png 120w,

                       mozilla-dinosaur-head-400.png 400w"

               sizes="(max-width: 480px) 120px, 400px"

               src="mozilla-dinosaur-head-400.png" alt="Mozilla">

        </a>

        <a href="https://addons.mozilla.org/">

          <img srcset="firefox-addons-120.jpg 120w,

                       firefox-addons.jpg 400w"

               sizes="(max-width: 480px) 120px, 400px"

               src="firefox-addons.jpg" alt="Addons for Mozilla Firefox">

        </a>

        <a href="https://developer.mozilla.org/en-US/">

          <img src="mdn.svg" alt="MDN logo">

        </a>

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

      </div>

Hi @Groght and welcome to the community :wave:

Your <img> tags look correct. The bigger images may be cached and therefore the browser would reuse it instead of downloading the smaller ones. Try making your screen smaller first and than press CTRL-SHIFT-R to reload without cache.

If this doesn’t make a difference it would be helpful to upload your code and images to https://glitch.com and create a new topic with a link to it. This way we could take a deeper look.

I hope that helps,
Michael

Thanks for the answer! Your advice did not help me, so I am attaching a link to Glitch:
https://wave-literate-wheel.glitch.me
https://glitch.com/edit/#!/wave-literate-wheel

1 Like

Thank you very much for the Glitch!
I had a closer look and your code definitively is correct. I guess you tried it in Chrome with the responsive design mode, right? Because this didn’t work for me either. It seems that it doesn’t respect the smaller viewport and always uses the size of the whole browser window to calculate the image sizes. Your code did work on:

  • Firefox (always)
  • Chrome on Glitch with small preview section (You can drag it smaller and hit the reload button above)
  • Chrome with small browser windows (I changed (max-width: 480px) to (max-width: 600px) because I couldn’t make the window smaller than 500px)

I think @justsomeone also wrote about this problem before.

In conclusion you aren’t wrong, Chrome is. :grin:

Have a nice day,
Michael

2 Likes

Thank you very much!
In Chrome with small browser windows really working. :grinning:

2 Likes

I’m happy we could solve the problem :blush:

Good luck on you developer journey. Feel free to come back with more questions.

2 Likes

sorry for late reply @mikoMK @Groght

yes it naughty chrome :joy:

if you load the page in bigger size first then it will keep using the bigger one but scale it down when you shrink your window but if you load it first in small window then it will load both

to test that you would need to clear cache so it’s does not use the history one

and have a nice day both of you :slight_smile:

1 Like

Ah yes. That was about resizing :slightly_smiling_face: This situation here was a bit different. I don’t know if it is a new bug in Chrome, but in this case the small pictures wouldn’t load in Responsive Design Mode even when reloading without cache. It seems as if Chrome uses the whole browser width although the RDM viewport was much smaller.

i did not use responsive design mode i used only the resize of the window
not sure why i never used RDM even in firefox maybe i like to do it manual :joy:

1 Like

At least you now know another possible cause if someone has a problem with responsive images :grin:

1 Like