|
|
#1 |
|
Super Moderator
![]() Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,053
|
Hello all,
Several people have been asking about the different types of css positioning...how to use them, is one better than the other, troubleshooting alignment, etc. I figured it would help if I posted a thread covering some basics. All this information I have gathered through various websites and forums. I am just posting what I have learned through the years. The sole purpose of this thread is to show others how these techniques are implemented. So, without further adieu, here it is: HTML Code:
<div class="rel"> <h2>#1</h2> <p>relative position</p> <div class="abs"> <h2>#3</h2> <p>absolute position</p> </div> <div class="stat"> <h2>#2</h2> <p>static position</p> </div> </div> <div class="fix"> <h2>#4</h2> <p>fixed position</p> </div> Code:
body, div, h2, p {
font-family:Arial, Helvetica, sans-serif;
color:#fff;
margin:0;
padding:0;
}
h2 {
font-size:18pt;
}
p {
text-transform:capitalize;
}
div.rel, div.abs, div.fix, div.stat {
font-size:10pt;
border:solid 1px #333;
padding:20px;
margin:0;
}
div.rel {
position:relative;
width:500px;
height:500px;
margin:50px auto;
background-color:#030;
}
div.abs {
position:absolute;
bottom:-25px;
right:-25px;
width:150px;
height:50px;
background-color:#093;
}
div.fix {
position:fixed;
right:5px;
bottom:5px;
width:75px;
height:300px;
background-color:#9C0;
}
div.stat {
border:solid 1px #fff;
background-color:#063;
height:70px;
margin-top:20px;
}
The default setting for an element. It will follow the normal html flow of the page. Element cannot be adjusted with the "top, right, bottom, and left" values. Relative Position Element is positioned in the normal html flow of the page and can be adjusted using the "top, right, bottom, and left" values. Absolute Position Element is removed from the normal html flow. Position is adjusted through the "top, right, bottom, and left" values and is based on the first parent container that has a position set to a value other that static. Fixed Position Element is removed from normal html flow. Position is adjusted through the "top, right, bottom, and left" values. These values are based on the html tag (browser window). Any questions/comments or other recommendations feel free to chime in
__________________
John Darling Graphic / Web Designer SmarterTools Inc. (877) 357-6278 www.smartertools.com |
|
|
|
|
|
#2 |
|
New Member
![]() Join Date: Mar 2010
Location: Dublin, Ireland
Posts: 19
|
dude thats awesome! thanks for sharing!
|
|
|
|
|
|
#3 |
|
Super Moderator
![]() Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,053
|
Your welcome.
__________________
John Darling Graphic / Web Designer SmarterTools Inc. (877) 357-6278 www.smartertools.com |
|
|
|
|
|
#4 | |
|
Super Moderator
![]() Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,053
|
Robert,
an excellent starting place to learn the basics of HTML and CSS would be W3Schools.com. Easy to follow, with plenty of examples. Quote:
__________________
John Darling Graphic / Web Designer SmarterTools Inc. (877) 357-6278 www.smartertools.com |
|
|
|
|
|
|
#5 |
|
Bronze Member
![]() Join Date: May 2010
Posts: 81
|
The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big
|
|
|
|
|
|
#6 |
|
New Member
![]() Join Date: May 2010
Posts: 7
|
This is definition exactly as per w3cschools.com
__________________
Mahesh photoshop filter effects and tutorial 80 excellent collection of Photoshop tutorial and filter effects |
|
|
|
|
|
#7 |
|
New Member
![]() Join Date: May 2010
Location: Bedfordshire, England
Posts: 21
|
Thankyou for sharing this dude
|
|
|
|
|
|
#8 |
|
New Member
![]() Join Date: Feb 2010
Posts: 5
|
Thx for sharing!
__________________
Optic Moon Webdesign |
|
|
|
|
|
#9 |
|
Super Moderator
![]() Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,053
|
You are correct this is similar and I made reference to the website in earlier posts. Thanks for sharing.
__________________
John Darling Graphic / Web Designer SmarterTools Inc. (877) 357-6278 www.smartertools.com |
|
|
|
|
|
#10 |
|
New Member
![]() Join Date: Jun 2010
Posts: 9
|
You can use css sprites that is mapping of images from a single image for faster image loading on your sites.
__________________
web design Australia |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|