Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Absolute positioning creating layout issues
Old 05-08-2012, 09:07 AM Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
On the following website:
http://tinyurl.com/cyuvh65

I have an absolutely positioned element with a negative right margin so that it extends out of the side of the containing elements:
Code:
#banner-disc {
    background: url('../image/banner-disc.gif');
    width: 846px;
    height: 270px;
    position: absolute;
    right: 0;
    top: 0;
    clear: both;
    z-index: 0;
    margin-right: -100px;
}
I've attached a screenshot showing the element in question.

It's creating two problems, one being if I resize my browser to 1024 pixels wide a horizontal scrollbar appears. I didn't expect this seeing as the element is absolutely positioned?

Secondly, I cannot add overflow:hidden to my #wrapper element in order for the 50px of bottom padding on the body element to work. If I do this, the side of #banner-disc is chopped off.

Is the only way I can clear it is to add a br.clear style before the closing tag for #wrapper?
Attached Images
File Type: jpg screenshot.jpg (45.3 KB, 6 views)
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 05-08-2012, 10:26 AM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
clear will not work on absolute elements as they are not in the normal flow so cannot affect elements that are in the flow or floated.
Also from http://www.w3.org/TR/CSS2/visuren.html
Quote:
Note. This property applied to all elements in CSS1. Implementations may therefore have supported this property on all elements. In CSS2 and CSS 2.1 the 'clear' property only applies to block-level elements. Therefore authors should only use this property on block-level elements. If an implementation does support clear on inline elements, rather than setting a clearance as explained above, the implementation should force a break and effectively insert one or more empty line boxes (or shifting the new line box downward as described in section 9.5) to move the top of the cleared inline's line box to below the respective floating box(es).
spans are inline elements and do not take width or height either.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-09-2012, 09:14 AM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Thanks, but I don't believe it's the span that I need to clear?

I need to clear something in order for the bottom padding to display on the body element. I imagine I could just add a <br style="clear" /> before the ending #wrapper </div>

Because if I add overflow:hidden to #wrapper then the body padding shows up but it chops off half of the absolutely positioned span

But then there's also the issue of the horizontal scrollbar appearing when the viewport is 1024 pixels wide :/
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 05-09-2012, 09:52 AM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
but I don't believe it's the span that I need to clear?
Maybe, but you do have the CSS rules above applied to a span
HTML Code:
<span id="banner-disc"></span>
Quote:
But then there's also the issue of the horizontal scrollbar appearing when the viewport is 1024 pixels wide
In what browser does this happen with?
I don't get a horizontal scroll in any browser I tried?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-11-2012, 06:23 AM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Quote:
Originally Posted by chrishirst View Post
In what browser does this happen with?
I don't get a horizontal scroll in any browser I tried?
All of them! In both Windows and Mac. But I have a feeling I may have hidden the <span> with display:none; when you'd be looking. I've made it visible again now
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 05-11-2012, 02:39 PM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok see it now.

By the way, did I mention how much I dislike these stupid "grid systems" with the ridiculous fractional numbers for padding and margins?????

There's no [insert expletive of choice] wonder that the screw things up badly when it goes slightly wrong.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-11-2012, 02:44 PM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Why does it have to be absolute and using margins to push it "outside of the container"? is there some problem with using relative position and the left/right properties, it would be far less messy and less problematic because the natural flow can remain in place.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-11-2012, 04:52 PM Re: Absolute positioning creating layout issues
vultren's Avatar
Super Spam Talker

Posts: 790
Name: Tony
Location: Seattle Washington
Trades: 1
Quote:
Originally Posted by chrishirst View Post
Why does it have to be absolute and using margins to push it "outside of the container"? is there some problem with using relative position and the left/right properties, it would be far less messy and less problematic because the natural flow can remain in place.
That's how it SHOULD be coded. It should always work with the natural flow. Don't even use relative positioning, learn floats for crying out loud!
__________________

Please login or register to view this content. Registration is FREE

"Do or do not, there is no try"
vultren is offline
Reply With Quote
View Public Profile
 
Old 05-12-2012, 03:41 AM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Hmmm I'm unsure how I could get it working by applying relative positioning to #banner-disc sorry?

If I set the rules like so:
Code:
#banner-disc {
    background: url('../image/banner-disc.gif');
    width: 846px;
    height: 270px;
    float: right;
    position: relative;
    left: 100px;
    top: 0;
    clear: both;
    z-index: 0;
    display: block;
}
Then the element is knocked beneath the other immediate children of #banner-home (see attached image)

I'm guessing I've got the wrong idea though!
Attached Images
File Type: jpg screenshot.jpg (82.4 KB, 2 views)
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 05-12-2012, 08:36 AM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
a z-index of 0 means that it is at the bottom of the stacking order therefore is BELOW all other elements.

http://webmaster-talk.eu/en/articles...ss-positioning

z-index is the third dimension of positioning, imagine it as a tower block and relative positioning is what creates the floor offset that is on the Manchester Hilton (Beetham Tower) the building "flow" is not disturbed on the opposite side and in the floors below (lower stacking order) but everything above (a higher stacking order) follows the new flow in the offset direction.
http://examples.webmaster-talk.eu/ch...ning/relative/

It's not exactly like that but it a pretty big and close example of how it works.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-12-2012, 10:31 AM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Hmmm, I've modified the CSS like so:

Code:
#banner-disc {
    background: url("../image/banner-disc.gif") repeat scroll 0 0 transparent;
    bottom: 270px;
    clear: both;
    display: block;
    float: right;
    height: 270px;
    position: relative;
    left: 100px;
    width: 846px;
    z-index: 0;
}
However I'm still getting a horizontal scrollbar at a 1024px resolution :/
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 05-12-2012, 11:54 AM Re: Absolute positioning creating layout issues
chrishirst's Avatar
Defies a Status

Posts: 43,959
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
lose the display: block;
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-15-2012, 02:25 PM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Hmmm, I've set it to display:inline (to overwrite the display: none; in the other stylesheet) however the problem still persists
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 05-19-2012, 10:28 AM Re: Absolute positioning creating layout issues
pealo86's Avatar
Super Spam Talker

Posts: 878
Name: Matt Pealing
Location: England, north west
Trades: 0
Turns out it's more common than I thought:
http://stackoverflow.com/questions/6...hich-is-outsid

Adding left:-100px is fine but browsers don't seem to like it on the right!?
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Absolute positioning creating layout issues
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65103 seconds with 12 queries