How to adjust the page width with CSS?

I am adjusting this blog to scale width dynamically. 

I am focusing on the desktop size as the mobile has a separate CSS code which works well.

What are the most popular Desktop display resolutions?

In 2022, the global statistics for the Desktop and Tablet display width are the following:


width x heightglobal usage %
1920×108021.5%
1366x76816.7%
1536x86410.6%
1280×7205.8%
1440x9005.4%
768x1024 (flipped to portrait)3.8%
Based on the statistics, I decided to make to CUT OFF the width at about 1024 pixels wide. This matched my empirical experience of making the narrowest possible window with the tinies of fonts before the page is unusable.


Before you copy and paste my code into your page, please remember that,
like anything in life, it will require try-and-error practice
.


// START HORIZONTAL / WIDTH SIZING SECTION 
body {
  width: 95%;   
//max-width: max-content;
margin: auto;
}
.columns-inner {         // container that hold both main and right columns 
width: 100%;
min-width: 670px;   // number above which the content starts sliding beyond RIGHT margin of the browser
}
.column-center-outer {
width: 75%;
}
.column-right-outer {  
width: 25%;
min-width: 14.1em;  // empirically derived, moves the RIGHT colunm to the BOTTOM if it shrinks to less than that
}
// END HORIZONTAL / WIDTH SIZING SECTION 


What were the results of the width adjustments?

The full 2K display looks like this


The minimal "full-width" page looks like this



and, the minimal page width looks like this



Summary

Overall, I am very happy with the result. It took way too long, but it was fun to get back into HTML and CSS Web development, it is something, I used to be very good at but did not practice for a while.



Resources:



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles