<!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="/assets/reset.css" rel="stylesheet"> <link href="setup.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <section> <p>This element is responsive.</p> <p>I’ll add some text more here so we have something to look at and so that it wraps, but the text itself isn’t important, at the moment.</p> </section> <section> <p>This is another responsive element, with some more text in it. Again the text doesn’t really matter, I just want a bit of stuff in here. A few lines, is all.</p> </section> <section> <p>And a third one, to have an element for each rule. I probably should just grab some lorem ipsum, but at this point I’m committed to typing nonsense.</p> </section> </body> </html>
body { font-family: sans-serif; padding: 20px; } section { padding: 10px; } section:not(:first-child) { margin-top: 10px; } p:not(:first-child) { margin-top: 10px; }
section { background-color: aquamarine; } @media (min-width: 500px) { section:first-child { background-color: coral; } } @media (width: 500px) { section:nth-child(2) { background-color: orange; } } @media (max-width: 500px) { section:last-child { background-color: gold; } }