header overlapping the content - css

I have placed an absolutely positioned element (header) after relatively positioned element (body content). Due to some reason and this works fine in all the browsers except IE8.
The header is overlapping the content element with not positioned at its absolute position.
The css rules I have used:
#bodyContent{
clear: both;
display: table;
width: 920px;
margin-top: 173px;
_margin-top: 178px;
position: relative;
}
#headerContainer {
position: absolute;
top: 0px;
left:0px;
}
The header part is rendering from the content element postition with space in its position.
Is this the bug in IE8? Can anyone help me sort out this issue?

This sounds like an old IE7 bug.. can you place an element between them? That fixed it for me.

I've also had similar problems. I used the float command which solved the issue. Try float: left; in #headerContainer

Related

position: sticky not working in firefox

position:sticky is said to be working in firefox but I'm not seeing my sidebar stick.
My html looks like this:
<div class="wrap">
<div class="sticky">side </div>
<div class="content">content <div>
<div>
My css:
.content{
height: 2000px;
overflow: hidden;
}
.sticky{
position: sticky;
width: 200px;
float: left;
}
As I scroll down the sidebar scrolls with the content. It doesn't stick. Anyone know what could be the issue?
I have the same issue in 2020 - this post pops up first in google but none of the answers helped me.
The actual problem was that sticky doesn't play well with the parent element being display: flex.
References:
- position: sticky, works in Chrome but not in Firefox
- https://bugzilla.mozilla.org/show_bug.cgi?id=1488080
It sticks if you specify a top value:
.sticky{
position: -webkit-sticky; /* for safari */
position: sticky;
width: 200px;
float: left;
top: 10px;
}
fiddle
Position sticky also don't work if the parent element is set to overflow: hidden because it can't calculate the height correctly.
position: sticky does not work on table elements such as tr as well as some others.
A workaround is to wrap whatever you want sticky inside a span element.
<style>.sticky span {position: -webkit-sticky; position: sticky; top: 0;}</style>
<td class='sticky' valign='top' width='200'>
<span>
(table contents)
</span>
</td>
Related answers and solutions
I was able to fix it by using 'display: table-cell'.
My problem concerned a thead that didn't want to stick anymore on Firefox as soon as I fixed the same problem in Chrome by using display: block or inline-block.
I had same issue, even though I set a top value, the sticky element would not stick. The solution was to set a value also for height...
.sticky-top {
position: -webkit-sticky;
position: sticky;
z-index: 1020;
top: 86px;
height: min-content;
}
Adding height: min-content; fixed my issue on firefox
To anyone still having this trouble:
Firefox uses the parent display as a rendering condition
So try making the child display: inline and parent display: inline
Remember that you still need to check the parent position and size for all browsers.
Sticky is great but it is very case-specific use.
I found the alt way with very simple but works.
position:fixed;
width:100%;
top:0;
z-index:1; /*depends on your elements*/
Work on every browsers, no bulls. If your topnav has a lot of elements, the sticky wil not working, I beleive it's because of some overflow:hidden;
In my case, the sticky element was taking a display: table; property, which when I changed to display: block;, the sticky was fixed in Firefox. So, have a look at the display property before considering other fixes.
Just stumbled on this so it seems to still be an issue in 2022. I'll leave here what I had that allowed me to clearly replicate the OP and what I added to mitigate it.
div {
position: sticky;
- display: inline;
+ display: block;
+ height: 100px;
z-index: 2;
top: 0;
}

How can I prevent a parent div from growing with its children?

I have a ul inside of a div, and want the containing div to not be affected by the child ul in terms of height.
Jsfiddle: http://jsfiddle.net/9eCq6/3/
Referring to the jsfiddle, I'd like the yellow div to not be any taller than the blue divs, and for the block of text below the colored divs to not be pushed down by the red ul - that is, I'd like it to overlap the block of text below.
I suspect the answer lies in positioning and is affected by the floats being applied, but I haven't been able to find the solution yet. What should I do, or read, to find the solution?
Edit: I want to not give the parent a fixed height, because I don't know what content might get added to it.
Use absolute positioning to breakaway from parent. Also you will need overflow: visible and a clearfix:
.wrap {
position: relative;
overflow: visible;
}
.wrap::after {
content: "";
display: table;
clear: both;
}
.right {
position: absolute;
top: 0;
right: 0;
}
.right ul {
position: absolute;
top: 100%;
left: 0;
}
This old BrainJar article is a great, thorough reference on CSS positioning. It is absolutely dated, but holds up surprisingly well. You will run into these sorts of issues far less often if you spend the time first to get a solid understanding of the underlying systems you're dealing with.
That said, a (partial) solution to your problem is straightforward. Put the div.under inside the div.wrap, and add clear: left; to the CSS .under selector. See this fiddle.
Give the parent fixed size, and use overflow:hidden.

Trying to stick a span tag to the bottom of the div

It works in chrome , and not in ff/opera.
Demo here: http://booksnearby.in/browse_items.php . The 'location: Dhoolsiras Village, delhi' line 'hangs' in the middle. I am trying to make it stay at the bottom of its container.
For this I tried
Child span tag- {
bottom: -5px;
font-size: 11px;
left: 115px;
line-height: 20px;
position: absolute;
}
Parent:- element.style {
height: 100%;
position: relative;
}
But it doesn't work, except in chrome. Please help
Thanks.
Do you have to use a table? Because your problems come from the td element's height. Tables have the worst cross browsers support out of all the html elements :)
Is it possible to change the structure to use div elements instead?
OR you could give the position: relative to your .listtd instead of the div (which means remove the position property from the div). This solution will do the trick.

allow overflow on fixed positioned element

I have a fixed positioned element somewhere near bottom of my page. As there is more content to it than window height itself displays rest of it's been cut down.
I've tried adding overflow:auto to fix this issue and be capable of scrolling through fixed positioned element but no luck.
I suppose there might be a javascript solution near by but wondering if there is a css one as well.
Hope my question made sense.
Thanks
You have to fix the height/width to get scrollbars, otherwise the fixed element expands out of view. Here's a little demo: little link. Basic outine:
HTML:
<div class = "fixed">
Glee is awesome!<br/>
...
Glee is awesome!<br/>
</div>
CSS:
html, body {
height: 100%;
}
.fixed {
position: fixed;
left: 0px;
top: 0px;
height: 100%;
width: 100px;
overflow: auto;
}

Absolute positioned child div expands to fit the parent?

Is there anyway for an absolute positioned child to expand to fill its relative positioned parent? (The height of parent is not fixed)
Here is what i did and it is working fine with Firefox and IE7 but not IE6. :(
<div id="parent">
<div id="child1"></div>
</div>
#parent { position: relative; width: 200px; height:100%; background:red }
#child1 { position: absolute; top: 0; left: 200px; height: 100%; background:blue }
That's easy. The trick is setting top: 0px and bottom: 0px at the same time
Here's the working code
html, body {
width: 100%;
height: 100%;
overflow: hidden;
}
#parent {
display: block;
background-color: #ff0;
border: 1px solid #f00;
position: relative;
width: 200px;
height: 100%;
}
#child1 {
background-color: #f00;
display: block;
border: 1px solid #ff0;
position: absolute;
left: 200px;
top: 0px;
bottom: 0px;
}
Check out a working example here http://jsfiddle.net/Qexhh/
If I remember correctly there is a bug with how IE6 handles div height. It will only create the div to the height needed to contain the content within it when height is set to 100%. I would recommend two approaches:
Don't worry about supporting IE6 as it is a dead browser anyway
If that doesn't work, use something like jQuery to get the height of the parent div and then set the child div to that height.
fake it by setting the backgrounds to be the same colour so no-one notices the difference
You can achieve this with setting both the top and bottom attributes of the child.
See how this is done
At the bottom of that article, there is a link to Dean Edwards' IE7 (and IE8) js library that you should include for IE6 visitors. It is a JS library that actually MAKES IE6 behave like IE7 (or 8) when you include it. Sweet!
Dean Edwars' IE7 and 8 JS libraries
As far as I know, there is no way of expanding a parent element around an absolutely positioned child element. By making the child element absolutely positioned your are removing it from the regular flow of page items.
I recently built a 2-column website where the right column was absolutely positioned but the left column was not. If the left column had less content and a smaller height than the right column, the page would cut off the right column since it was absolutely positioned.
In order to resolve this, I had to determine if the height of the right column was greater than the height of the left column and if so set the height of the parent div height to the greater of the two.
Here is my jQuery solution. I'm not much of a coder so feel free to tweak this:
jQuery(function(){
var rightColHeight = jQuery('div.right_column').height();
var leftColHeight = jQuery('div.left_column').height();
if (rightColHeight > leftColHeight){
jQuery('.content_wrap').height(rightColHeight+'px');
}
});

Resources