Landing pages in laptop and mobile phone environments
posted 2020.01.23 by Clark Wilkins, SImplexable

Today, I got involved in a small project to redesign the landing page for a marketing outreach, and it gave me inspiration to talk about the general principles of adaptation for desktop screens (width > height) vs. mobile ( height > width).The examples I am going to show here use CSS3 flexbox, but nothing really cutting edge.

First, I laid out the desktop version. Again, this aspect ratio is wider than tall, so I used two equivalent-width flexbox DIVs.1 Additionally, the right side column is vertically centered in its container DIV.2 Easy, right?

Just to make it even better, I am using a centering on the entire display element to put it in the middle of the screen.3 Another trick used in this layout was a non-proportional cropping of the photo, because it's going into a column that's ~ 45% of the width of the screen. By cropping to ~ 5:8 aspect ratio, the picture is 62.5% as wide as it is tall, so it fits better in an essentially tall DIV.

If you try to do this layout on a mobile screen, it's a disaster because the columns are so narrow, and therefore become very tall to fit the text (right column) inside, and the input boxes are too small. What we do instead is a single-column layout and center everything. (Also, the original photo is used without cropping, so it has ~ 1:1 aspect ratio.

Now it looks great on a mobile phone as well. My marketing person is happy again. :-)

If you're a lay-person, just stop reading here and go tell your designer this is what you want. For those interested, this is pretty basic CSS3 as discussed in the notes below.

NOTE 1: flexbox css

.flexBox
{
display: flex;
overflow: auto;
clear: both;
}

.flexCol
{
float: left;
padding: 1%;
overflow: hidden;
clear: right;
align-items: stretch;
flex: auto;
}

.flexCol1
{
-webkit-flex: 1 0 0;
flex: 1 0 0;
}

NOTE 2: the containing DIV has some inline styling to do the vertical alignment.

<div class = "flexcol flexCol1" style = "align-self: center;">

NOTE 3: centering the text in column2 with respect to the content of the entire screen below the menu bar.

<div id = "content" style = "display: flex;">

  <div class = "flexbox desktop" style = "border-radius: 20px; background-color: #fff; align-self: center;">