ckportfolio.com - AJAX-based Microsite: Media Query (Bonus)

AJAX-based Microsite: Media Query (Bonus)

Responsive Design

Now that we have the JS-activated website, let's spend some time to make sure that the website is responsive to the user's various browser sizes. This is a review for those who participated in CSDM 1N15.

Media Query

Media queries can be described as conditional statements: if the user's browser satisfies a certain set of conditions, whatever that is placed between the subsequent pair of braces will be activated. Consider the following example:

Try to decipher whatever that means. In plain English, the above statement reads as the following:

"If the user's device is a screen, and happens to be equal to or less than 640px wide ... set the #container element's width to 320px, and make sure that the height of each individual square element is calculated automatically."

After applying the above code, see what happens to your website when the browser is resized to be small than 640px in width:

You can verify that the media query kicks in only when the browser matches the aforementioned conditions. It's that easy --- we now have the page optimized for mobile access.

How about widescreen accommodation, where the screen is wide enough to accommodate all of four squares in a single horizontal file?

Because they add up to 1280px in width, we can activate the widescreen mode when the browser happens to be wider than 1280px in width. The result, as you can imagine, is the following:

Screencast Recording

https://www.dropbox.com/scl/fi/ivhkmv8il861gnwl4g7mj/Page-7.mov?rlkey=s0lxshgawoormh7t234k5g58s&dl=0

Fin