.

Monday, September 20, 2010

Learn CSS DIVs

float columns

If we float one column to the left, then also float the second column to the left, they will push up against each other.

#div-1a { 
float:left;
width:150px;
}

#div-1b {
float:left;
width:150px;
}

http://www.barelyfitz.com/screencast/html-training/css/positioning/ go to tab 8



two column absolute

Now we can make a two-column layout using relative and absolute positioning!

#div-1 {  position:relative; } #div-1a {  position:absolute;  top:0;  right:0;  width:200px; } #div-1b {  position:absolute;  top:0;  left:0;  width:200px; } 

One advantage to using absolute positioning is that we can position the elements in any order on the page, regardless of the order they appear in the HTML. So I put div-1b before div-1a.

But wait - what happened to the other elements? They are being obscured by the absolutely positioned elements. What can we do about that?


two column absolute height

One solution is to set a fixed height on the elements.

But that is not a viable solution for most designs, because we usually do not know how much text will be in the elements, or the exact font sizes that will be used.

#div-1 {  position:relative;  height:250px; } #div-1a {  position:absolute;  top:0;  right:0;  width:200px; } #div-1b {  position:absolute;  top:0;  left:0;  width:200px; }


No comments:

Post a Comment

Speak your mind

web hosting reviews

Top 3 Web Hosting for Designers

Our reviews of the best web hosting providers for Designers.

Rank Features Features Extra Features Web Hosting Review
1
HostRocket
Many Features

Disk Space: Unlimited
Bandwidth: Unlimited
Email Accounts: Unlimited

MySQL Databases: Unlimited
FTP Accounts: Unlimited
- Streaming audio/video capabilities
- Ready to go scripts:
E-commerce, gallery, forums etc


HostRocket
Review
Email in your review
2
WebHostingPad
Reliable Host

Disk Space: Unlimited
Bandwidth: Unlimited
Email Accounts: Unlimited

MySQL Databases: Unlimited
FTP Accounts: Unlimited
- Ready to go scripts:
E-commerce, gallery, forums etc
- $25 Google Credit - Advertise on google. They give you $25 credit

- $25 Yahoo Credit
WebHostngPad
Review
Email in your review
3
Globat
Reliable Host

Disk Space: Unlimited
Bandwidth: Unlimited
Email Accounts: Unlimited

MySQL Databases: Unlimited
FTP Accounts: Unlimited
- $4.44 One of the cheapest
- You get FREE Domain too
- $30 Google AdWords Marketing Credit
- Ready to go scripts:
E-commerce, gallery, forums etc

Globat
Review
Email in your review