DEV Community

Discussion on: Master Frontend Development πŸ’» By Cloning These Websites πŸ’―

Collapse
 
hyggedev profile image
Chris Hansen

Hey there, thanks for dropping by πŸ‘‹

Good question. Usually, I try my best to just analyze the website. Starting from big, then begin working my down to smaller components. So if there is a 'section' break that section down. Whats in the section. Maybe a banner? A banner with children. Theres probably a container containing the children. Should you use flexbox or grid here?

(if your not a complete beginner, you MUST not read on! 🀣 )

Since you're doing apples website, let's take a look at the navbar. The Navbar is full width. It's 100% across, or 100vw. However its contents are contained. So it's probably safe to assume theres a container. So far, we have a navbar, and a container, and nav elements. So you can give the container some pre-defined widths, maybe something like max-width: "1400px" with a margin: "0 auto". Some padding, 1rem maybe. Then, set the parent container of the nav elements, "container" in this case, to flex. Then add justify-content: "center", align-items: "center", and flex-direction: "column." Remember I said mobile first approach is easier, at least IMO. So it looks awkward now, but set a responsive query as easy as this: @media screen and (min-width: 790px) { flex-direction: "row" }. Then, once the screen size drops below this, another another media query somewhere, or add javascript, and make the navbar disappear completely. Then in the DOM, create a separate, mobile menu, that only displays at the correct breakpoint. This is if your'e working with plain HTML and CSS anyway. Otherwise, if your'e using javascript, you can simply use javascript and state to toggle things 😎 .

One last section, if you scroll down to the "Apple event" and "Fitness+", etc section below the apple watch, you can see it's just a section, with small components. Break this down in your head mentally. It's just a full-width, 2 column section, containing big blocks with some content inside. Turn the section into a grid, with either flex or grid. So maybe a display: "grid", grid-template-columns: "1fr 1fr". Inside each block is a flex container. So something like a display: "flex" and justify-content: "flex-start" or "flex-end" depending. Each block has a background-image, probably set to a background-size of "cover" and positioned "center". The text is also contained, with a max-width of something like 300 pixels?

I could be off, as I'm just glancing at once screen and typing on another LOL. But I hope this helps you. This is my mental process of I break down over-complicated layouts! Give a share once your done i'd love to check it out!

Collapse
 
hemantssingh776 profile image
Hemant singh

Thanx for the helping me out on this.