CSS Assignment – 5
Basic Questions
- Add a meta viewport tag in HTML for mobile responsiveness.
- Create text that resizes with the screen width using font-size: 5vw;.
- Use max-width: 100%; to make an image shrink responsively.
- Apply object-fit: cover; to keep an image from stretching.
- Create a paragraph with line-height scaling using em.
- Apply rem sizing to make consistent padding across 3 divs.
- Give a box width: 50% and observe how it adjusts across screen sizes.
- Write a media query that changes background coloUr when screen width < 600px.
- Create a button that increases font-size at breakpoint (768px).
- Apply a media query that hides a sidebar when screen < 500px.
- Set different text colours for mobile (under 600px) vs desktop (above 600px).
- Create a flex container with 3 items in a row.
- Stack the flex items in a column using flex-direction: column;.
- Create a 2-column grid with grid-template-columns: 1fr 1fr;.
- Add spacing between grid items using gap: 20px;.
- Define a CSS variable –main-colour and apply it to colour.
- Use var(–padding-size) to apply padding inside a div.
- Change a CSS variable value in a :hover state.
- Nest two selectors where a paragraph inside a div has different styles.
- Use margin-inline: auto; to centre a block element.
Intermediate Questions
- Make a mobile-first layout where the nav bar is stacked, but at min-width: 768px it becomes horizontal.
- Create media queries for 3 breakpoints: mobile (<600px), tablet (600–1024px), desktop (>1024px).
- Build a hero section that uses vh height responsiveness.
- Apply max-width: 1200px; to keep content from stretching on wide screens.
- Use min-height: 100vh; to create a full-screen hero section.
- Make headings scale using clamp(1rem, 5vw, 3rem);.
- Create a flexbox layout where direction switches between row and column depending on screen size.
- Use Grid to create a responsive 3-column layout that collapses to 1 column on mobile.
- Build a flex container with justify-content: space-between; that becomes center on small screens.
- Create a 2-row grid with different row heights using grid-template-rows.
- Use place-items: center; for centering content inside a grid.
- Use nested flexboxes: parent flex → child flex row → responsive stack on small screens.
- Create a responsive card layout with grid-auto-rows: minmax(150px, auto).
- Use CSS variables to define theme colors (–primary, –secondary) and apply them to 2 sections.
- Change theme (dark vs light) by redefining variables in :root.
- Combine variables with calc() for responsive margins.
- Use gap inside a flexbox container for spacing instead of margin.
- Create padding that works in block direction only using padding-block.
- Use margin-inline-start and margin-inline-end instead of left/right for logical independence.
- Nest 3 selectors using modern CSS nesting to style elements hierarchically.
Advanced Questions
- Create a responsive portfolio layout using Grid — four columns on desktop, two on tablet, one on mobile.
- Build a navbar that switches between hamburger menu on mobile and full nav on desktop.
- Implement a fully fluid image gallery using object-fit and minmax() with grid.
- Create a responsive split-screen hero section using Flexbox (image + text side-by-side on desktop, stacked on mobile).
- Build a theme switcher (light/dark) using CSS variables and a toggle button.
- Define spacing scale variables (–space-xs, –space-s, –space-m, etc.) and apply consistently to design.
- Use complex nesting with child selectors and variables for a module-based card layout.
- Build a CSS grid + media queries responsive dashboard layout (header, sidebar, content, footer).
- Create fluid typography using only responsive units: clamp() with rem + vw.
- Build a responsive form layout using grid-auto-flow and place-content: center;.