| View previous topic :: View next topic |
| Author |
Message |
linx New Programmer
Joined: 09 Feb 2009 Posts: 11
|
People, I'd like to discuss problems of positioning blocks on web-pages.
I don't understand the difference till the end...  _________________ ...and justice for all...
Reply with quote
|
| |
|
|
musician Enthusiastic Coder
Joined: 09 Feb 2009 Posts: 27
|
Within CSS you can position where exactly items will appear in the browser. This is done by either one of two ways. An absolute position, whereas you are defining exactly where within the browser that the item should appear. A relative position, where an item is placed within the browser based on its relationship to another item already in the browser output.
Reply with quote
|
| |
|
|
musician Enthusiastic Coder
Joined: 09 Feb 2009 Posts: 27
|
Look, it is simple:
| Code: |
<html>
<title>CSS - Absolute / Relative Position</title>
<body>
<img id='img_abs">
</body>
</html> |
in CSS:
| Code: |
#img_abs
{
position:absolute;
left:100px;
top:150px;
} |
Reply with quote
|
| |
|
|
max Guest Programmer
|
Value Description
static
Default. An element with position: static always has the position the normal flow of the page gives it (a static element ignores any top, bottom, left, or right declarations)
relative
An element with position: relative moves an element relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position
absolute
An element with position: absolute is positioned at the specified coordinates relative to its containing block. The element's position is specified with the "left", "top", "right", and "bottom" properties
fixed
An element with position: fixed is positioned at the specified coordinates relative to the browser window. The element's position is specified with the "left", "top", "right", and "bottom" properties. The element remains at that position regardless of scrolling. Works in IE7 (strict mode)
Reply with quote
|
| |
|
|
linx New Programmer
Joined: 09 Feb 2009 Posts: 11
|
Thanks!
I should do a column where there will be background, on that background I need to put an image and on that image - text...
I hardly understand how to do that... _________________ ...and justice for all...
Reply with quote
|
| |
|
|
musician Enthusiastic Coder
Joined: 09 Feb 2009 Posts: 27
|
Try putting in a div background
Then you can put two div's one by another with absolute position
Reply with quote
|
| |
|
|
musician Enthusiastic Coder
Joined: 09 Feb 2009 Posts: 27
| |
linx New Programmer
Joined: 09 Feb 2009 Posts: 11
|
It works!
| Code: |
#lftBar div.panelIMG {
position:absolute;
top:2px;
left:2px
}
#lftBar div.panelTXT {
position:absolute;
top:0px;
left:0 |
Now I have one more problem - in Opera 9.0 the text area is pushed from the right border by 5px as if I've put padding-right:5px... but I have
| Code: |
margin:0;
padding:0 |
any ideas? _________________ ...and justice for all...
Reply with quote
|
| |
|
|
musician Enthusiastic Coder
Joined: 09 Feb 2009 Posts: 27
| |
linx New Programmer
Joined: 09 Feb 2009 Posts: 11
|
I've resolved that problem... Helped fixed width:
| Code: |
#lftBar div.panelTXT2 {
position:absolute;
top:0;
left:0;
width:215px |
_________________ ...and justice for all...
Reply with quote
|
| |
|
|
|