reading-notes


Project maintained by Razan-am Hosted on GitHub Pages — Theme by mattgraham

HTML & CSS

Chapter 15: “Layout”

<h1> <p> <ul> <li>

<img> <b> <i>

- Containing Elements: If one block-level element sits inside another block-level element then the outer box is known as the containing or parent element.

- Controlling the Position of Elements:

1. Normal Flow (position-static): each block-level element sits on top of the next one.

2. Relative Positioning (position-relative): It’s moves an element in relation to where it would have been in normal flow.

Example:

p.example {

position: relative;

top: 10px;

left: 100px;}


3. Absolute Positioning(position-absolute): When the position property is given a value of absolute, the box is taken out of normal flow and no longer affects the position of other elements on the page.

Example:

h1 {

position: absolute;

top: 0px;

left: 500px;

width: 250px;}

3. Fixed Positioning(position-fixed): It is a type of absolute positioning that requires the position property to have a value of fixed.

Example:

h1 {

position: fixed;

top: 0px;

left: 50px;

padding: 10px;

margin: 0px;

width: 100%;

background-color: #efefef;}

4. Overlapping Elements(z-index): It is used to control which element sits on top, you can use the z-index property. Its value is a number, and the higher the number the closer that element is to the front.

Example:

h1 {

position: fixed;

width: 100%;

background-color: #efefef;

z-index: 10;}

5. Floating Elements(float): It is allows you to take an element in normal flow and place it as far to the left or right of the containing element as possible.

Example:

blockquote {

float: right;

width: 275px;

font-size: 130%;

font-style: italic;}

You can use the float to place the box elements side by side.


6. Clearing Floats(clear): It’s allows you to say that no element within the same containing element should touch the left or righthand sides of a box,and it is takes:

- left:which means the left-hand side of the box should not touch any other elements

- right:which mean the right-hand side of the box will not touch elements appearing in the same containing element.

If a containing element only contains floated elements, some browsers will treat it as if it is zero pixels tall.


Example:

div {

border: 1px solid #665544;

overflow: auto;

width: 100%;}

- Creating Multi-Column Layouts with Floats: To use multiple columns in the design, it will achieved by using a<div> element to represent each column. And these following CSS properties to place the columns next to each other.

Example:

.column1of2 {

float: left;

width: 620px;

margin: 10px;}

.column2of2 {

float: left;

width: 300px;

margin: 10px;}

Screen Sizes

1. Screen Resolution:

2. Page Sizes:

3. Fixed Width Layouts:

Measurements tend to be given in pixels

4. Liquid Layouts:

They tend to use percentages.


<An overall about the layout:>

References:

@Jon Duckett/HTML & CSS