Reading notes for Code Fellows!
The boxes of elements that appear later in the HTML code can sometimes overlap the ones which came before. We can control which elements sit on top by utilizing the z-index
property. Sometimes known as the stacking context manipulation of this property is tantamount to “bringing to the front” and “sending to back”.
The float property allows us to take an element in normal flow and place it as far to the left or right of the containing element as possible. Other elements that reside in the same container will flow around the floated element. When we use the float
property, we should also use the width
property to indicate how wide the floated element should be.
float
is often used to place elements side-by-side, but can have unexpected results when neighboring elements have differing heights. This can be solved by using the clear
property.
The clear
property allows us to indicate that no element in the same container should touch the left, right or both sides of a box.
Different visitors to web sites will have different sized screens that show differing amounts of information. Our design must, therefore be able to work on a range of different sized screens. Also, some devices have a higher resolution than desktop computers and most operating systems allow users to adjust the resolution of their screens.
Because screen sizes and display resolutions vary so much, web designers often try to create pages around 960-1000 pixels wide.
Fixed width layout designs do not change size as the user increases or decreases the size of their browser window.
Liquid layout designs stretch and contract as the user increases or decreases the size of their browser window. They typically use percentages.
Many web designers use a grid structure to help them position items on a page. Grids set consistent proportions and spacing between itemsto create a professional looking design. One widely used layout tool is called the 960 pixel grid. It is possible to create many different layouts using this one versatile grid. Far from being restricting, a grid:
A wide range of layouts can be created from a single 960 pixel wide 12 column grid, for example. Each column in a grid has a margin setting. This setting creates a gap between the columns that is twice as wide as the setting.
CSS frameworks aim to make our life easier by providing the code for common tasks:
We can include the CSS framework code in our projects rather than writing the CSS from sctratch.
One of the most popular uses of CSS frameworks is in creating grids to layout pages. There are several grid frameworks available, but one of the most popular is the 960 Grid System. It provides a style sheet we can include in our HTML pages by linking to it. Then, all we have to do is provide the appropriate classes to our HTML code and it will create multiple column layout for us.
<head>
of the page<div>
to contain the entire page and give it a class of "container_12"
to indicate that we will be using a 12 column grid<div>
a class of clearfix
to ensure that browsers know the height of the containing box, because it only contains floated elementsMultiple CSS files can be included in one page. Some authors split their CSS style rules into separate style sheets: one to control the layout and another to control fonts and colors, etc. Some authors subdivde their style sheets roles into even smaller scopes, in a more modular approach.
There are two ways in which we can add multiple style sheets to our page:
@import
rule to import other style sheets.
@import
rule, it should appear before the other rules.<link>
element for each style sheet in our HTML.