Bare bones 3 column CSS layout

What is Liquid Design?

The sad fact is that the vast majority of Websites you’ll come across, especially small-medium sized business sites, would be better off being made into a print brochure.

You know what I mean: A 720×400 pixel «window» sitting in the middle of the monitor looking lonely and unloved. Possibly sporting «chunky buttons» «flashing knobs» and the legendary «Spinning Logo».

This article will introduce you to the basic concepts of creating a fluid Web page layout with CSS, and withTables. If you’ve not really explored this area before, it’s high time you did!

The Web is Not Print

People who find themselves faced with the task of creating or commissioning a Website tend to think in terms of print. It’s what we know, after all. The fact that the Internet can be accessed with many different variations of browser, platform, settings or even devices often escapes these, our potential Web design clients, entirely.

Your visitors can use almost anything to access your information, from simple variations on popular themes such as:

  • Browsers with large fonts
  • Browsers with Javascript and images turned off
  • «Alternative» browsers such as Opera, Mozilla, or Netscape

…to the more extreme ends of the spectrum such as:

  • Web TV
  • Text-only browsers
  • Screen readers and braille browsers
  • Hand held devices

So, trying to impose strict, rigid, pixel-perfect design on such a fluid and unpredictable medium is futile.

What is Liquid Design?

The term «liquid» implies that a Website should flow smoothly into whatever space it is given. If you use a high resolution monitor, this may mean that you need to resize your browser a little, which most people in that situation do. If you have a low resolution moitor, you will still see the information, it will just be a little more compact.

Читайте также:  Application config database php

If you do Liquid Design right, you should be able to make your pages display on almost anything and still make sense to the user.

But it’s not just about making a page ‘flow’ with the browser window. The principle of Liquid Design goes hand in hand with the principles of accessibility.

Not everyone has perfect vision, and many of your potential customers may indeed be blind. If you build your site using relative font units and percentage based widths for common elements, you’ll already be making life a lot easier for a portion of your visitors. Maybe even many of them.

Enough With The Theory!

Ok, so how do we implement liquid design principles on our Websites? Well, the first thing you’ll need to do is to change the way you think about the Web. The whole Liquid Design concept is a mindset…

  • Throw away the need to have your pages look exactly the same on every device
  • Be prepared to compromise your ideals
  • Start thinking about accessibility issues as you design
  • Hold your head high, you’re making the ‘net a better place!

There are two major ways to tackle Liquid Design:

I’m a great advocate of CSS (Cascading Style Sheets) and for accessibility and Liquid Design (not to mention speed, good markup and SEO issues) it’s a clear winner. Clean, uncluttered markup will not only make your pages load faster, but you’ll also find the whole process of writing liquid layouts much more intuitive.

….and before anyone starts shouting about NN4, yeah, I know: if your audience comprises a high proportion of NN4 users, you may well be best off with a tables-based approach.

Putting Liquid Design into Practice

So how do we do it? Well, let’s start by looking at a typical 3 column page layout. First we’ll look at this in CSS, and then with tables.

A «Bare Bones» 3 Column CSS Layout

  





#leftpanel <
position: absolute;
top: 140px; /* resize these bits to liking */
left: 0;
width: 200px; /* works best with fixed
width right - left divs*/
>

#rightpanel <
position: absolute;
top: 140px; /* resize these bits to liking */
right: 0;
width: 200px; /* works best with fixed
width right - left divs*/
>

#content <
position: absolute;
top: 140px;
padding-left: 220px; /* 20px to play with */
padding-right: 220px; /* 20px to play with */
>

Bare bones 3 column CSS layout





You can put your content here, under the space
for a header, or you can re-arrange the
divs in the html to put your right or left column first.





This is a good place to pop nice optimized
text into, especially if your #content div
is full of images and little text. I like to
put an 'editors note' here: Just an excuse to
squeeze optimized copy into the html flow without
bothering the user ;-)





Links, come last, presuming your 'header' has
a 'main sections' navigation with regular text links
this is just fine for SE's and magic for
optimization.

Paste that code into vim, notepad or whatever tickles your fancy, and you’ll see that it really is a bare bones example. You’ll notice that when you resize your browser, the middle column expands and contracts to make up the difference. The left and right coloumns remain fixed.

And if you’re wondering why I didn’t make it completely fluid, the answer is simple: it just looks and works better this way, to my liking at least. Try adjusting the left and right column widths to percentages: it should work fine.

You’ll have to adjust the commented sections in the css and add a great deal more presentation rules but this basic layout should give anyone who’s new to this a good building block to start with.

Further CSS resources can be found here:

If you’re wondering if you could implement fluid CSS layouts on your Webpages, you might also like to check out these examples:

Good examples of liquid layout from very different sites!

And Now With Tables

 "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 





border="0" height="120" width="100%">


Bare Bones 3 column Liquid Tables
Layout


border="0" width="100%">



This is your left panel.
Generally used for navigation and
with this kind of layout, getting in
the way of the content!




This is your content area
and flow with your browser just the same
as the CSS layout above. The content
is pushed down the code flow a bit
by the tables layout but the end result is
preferable to a fixed width page. You
can see I'm biased, right?




Right column - fixed width at 200 px
again for the purpose of this demo. Just adjust the
widths to suit and don't be afraid to experiment!

As you can probably tell, I’m not as used to writing tables layouts as I am CSS layouts. Despite its limitations, though, the above example gives you another building block for liquid design if you prefer — or need — to build your layouts with tables.

What About Fonts?

Good point! Well, if we stick with our liquid design principles we’ll need to use relative font units. Our choices are:

Using relative units will give your users the opportunity to adjust their fonts to suit. I must admit to not always following my own advice, but on most of my sites I opt for em’s. A detailed discussion on this would make a whole new article so I’ll leave it with you to decide for now.

Liquid Design: Can it be Done?

Yes, without a doubt! Fixed layouts are slowly becoming a thing of the past. And the principles and considerations involved in creating a liquid layout (rather than a fixed layout) are very easy to implement on your site.

However, the whole liquid idea does require a shift of focus. Stop thinking of the Web as a medium you can control, stop thinking for your users, and you’ll be happier, your visitors will be happier, and the Web will be just a little more pleasent for everyone.

If you like the ideas I’ve touched upon but just can’t implement them all, then don’t worry. Neither can I all of the time. If you love the idea, hate the idea, or feel that I’m talking absolute rubbish (it’s been known…) then follow the ‘discuss this article’ link at the bottom and to tell us why. The Web is a cool place — it has room for all kinds of opinions and ideas, and I’d love to hear yours! Have fun!

Share This Article

Nick Wilson runs Tioka.com and is involved in various ecommerce projects ranging from Gifts for Men to Cufflinks. Nick’s latest project is Phentermine Express.

Источник

Styles with Liquid

Styling Shopify themes has always been inherently more complex than a typical web project thanks to the common need to combine styling languages with Liquid. The complexity only grows worse when using compiled styling languages like Sass, since including Liquid in Sass results in invalid syntax.

Liquid is required in your styles if you want your theme to be customizable via the Online Store Editor. For example, if you wanted the background colour of your theme to be customizable, you could add a setting in your config/settings_schema.json and then use the value of that setting in your stylesheet. If you were using vanilla CSS, it might look something like the following:

In order for Shopify to compute the Liquid values inside a stylesheet, you must give the stylesheet a .liquid extension. When a .css.liquid is uploaded to the assets folder of your theme on Shopify servers, the Liquid values are populated and a .css stylesheet is made available. For example, if you were to upload a styles.css.liquid file, you could include it in your theme with the following markup:

type="text/css" href=">" rel="stylesheet"> 

Similar to css.liquid stylesheets, if theme developers want to include Liquid directly in Sass ( .scss.liquid files), those stylesheets need to be compiled on Shopify servers. This is because using Liquid in Sass results in invalid Sass syntax that local Sass compilers cannot parse.

Luckily for developers, Shopify has a Sass compiler built into the platform. When a .scss.liquid file is uploaded to the assets folder of your theme on Shopify servers, the Liquid values are populated and a scss.css stylesheet is made available. For example, if you were to upload a styles.scss.liquid file, you could include it in your theme with the following markup:

type="text/css" href=">" rel="stylesheet"> 

Note: Shopify is using a forked version of Sass v3.2 which does not support importing partial Sass files with the @import directive. This may cause some issues when trying to work with 3rd party Sass libraries.

Liquid with CSS custom properties

Slate introduces a new way of handling styles made possible through CSS custom properties. CSS custom properties are the perfect mechanism to link stylesheets to Theme Editor Liquid settings. They allow you to write valid CSS that plays well with build tools like Sass and PostCSS. CSS custom properties are also supported in all modern browsers, so there’s never been a better time than now to use them!

When local Sass compilation is combined with Slate’s Local Development Assets Server, style changes are instantly injected into the page, without waiting for Shopify servers, resulting in a lightning fast development experience.

To support legacy browsers, Slate includes a transpiler that replaces CSS variables with matching Liquid Variables as a last step in the production build script.

For an example, take a look at Shopify/starter-theme or continue reading below:

  • We define all of our CSS variables in a snippet called css-variables.liquid which is included in the of the theme.liquid file.
  • We create each variable like so, using CSS custom properties as described above:
style> :root < --color-primary: >; --color-body-text: >; --color-main-background: >; > style> 
  • What we did here is create a CSS custom property which is tied to the value from the theme editor (that the merchant can change). We can access these variables in our .scss files:
$color-primary: var(--color-primary); $color-body: var(--color-main-background); 
  • In doing so, we successfully link up the values from the Shopify Theme Editor to our .scss files without the need of using a .scss.liquid file.

Источник

Оцените статью