IE and absolute positioning divs - css

This problem is only in IE. Consider the following HTML:
<html>
<body>
<div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
Put more than a full screen of text in here. It *should* create a scroll inside the div.
In IE, it stretches the div out vertically.
<div>
<body>
<html>
If you put a ton of text in the div, IE will stretch the div out beyond the declared "bottom". I know what it is doing. It considers the bottom of the page to be the bottom of the page after all of the text has been rendered. I want bottom to be the bottom of the visible window. So, I want to have a div that is centered inside the window. Is there some retarded hack to make IE comprehend the basic concept of CSS?

When using conflicting absolute positions don't forget the fix for IE6 under the 'Creating the exception for IE5 and IE6' header in that article.

You could try using a conditional comment to add overflow:auto; for IE only.

body: 100%;
div#id height: 100%;

Related

how to fix failure of scroll attribute on CSS overflow property

I'm trying to include a large image (a map) as background in a web page, with the ability to scroll to view the areas outside the current viewport. I'm using the CSS overflow property and its scroll attribute. 'Scroll' attribute on the CSS 'overflow' property fails. The borders appear on the right and bottom of the browser window, but without scrollbars. As a result it is not possible to scroll the HTML element. Desired behavior is functional scroll bars.
I tried switching the sequence of the CSS properties, understanding that the last one rules. No impact. Tried viewing in different browsers, to see if it's browser-specific. Fails equally in Firefox, Chrome, Chromium, and Safari. MDN docs indicate this should work.
...
<style type="text/css">
html {
background-image: url(art/GbMap.png);
background-size: 2000px 2100px;
overflow: scroll;
}
</style>
...
Expected: borders on the bottom and right with scrollbars that allow me to scroll the image.
Actual: borders on the bottom and right, but no scrollbars.

Can' t scroll on my web page

I am beginner in HTML/CSS and I come to one issue that is strange to me. Can't remember that I had this problem when started to learn. Nevertheless, the problem is that I can't scroll when I resize my browser window. Her is the code:
<!DOCTYPE html>
<html>
<head>
<body>
<img id="pic" src="http://0.tqn.com/f/lg/a154.png"/>
<style>
#pic {
position: fixed;
left: 1060px;
top: 150px;
right: 300px;
bottom: 658px;
}
</style>
</body>
</head>
</html>
I put position of picture on left and right because that is the only way that I know to fix image on one specific position. I tried auto, but the picture moves when I resize browser.
Thank you for your time and effort
Ok, the issue I think you have is that when you position an element absolute, it removes it from the flow of the document.
So think of it as if the absolute element is removed from the body of the page.
The body of a page is always 100% width of the browser. Your image is being positioned outside of the browsers view port.
you have two options. either do not user absolute positioning and use a css layout to get it the image in the proper place.
or you can set the width of the browser to the width that you need it to be e.g. 1200px
the first option is better for modern days and doing more future facing sites.

Webkit absolutely positioned buttons stretch all the way across

The following code works differently in Firefox and Webkit (Safari/Chrome) and should not. From what I understand, Firefox is rendering it correctly. How can I make Webkit render it the same?
<!doctype html>
<html>
<head>
<style type="text/css">
.frell {
margin: auto;
position: absolute;
left: 0;
right: 0;
}
</style>
</head>
<body>
<div id="container">
<button class="frell">Test</button>
</div>
<body>
</html>
Probably inheriting either it's parent's width or getting display:block. What does the Chrome developer tools say? I'd either specify a width (% or px) or display:inline (possibly inline-block)
Firefox is rendering it incorrectly, webkit is rendering it correctly. To make firefox behave, you need to add width: 100% to the class, even then, that won't work in all cases, but it will be closer.
Absolutely positioning an item and specifying both left and right should make the item become the necessary width to fill the space between them. For a simple test, here is a jsfiddle http://jsfiddle.net/c3EeF/2/ that shows what happens when you apply the same class to both the button and div tags. Firefox misbehaves when using the button, and I have been unable to find any setting that makes it work 100% correctly.

How to get correct overflow for proper div with fixed footer?

I am creating a site that has three major components - the navigation bar on the left, the central content (which is broken into a Title + Data), and a footer. The footer is fixed to the bottom of the page. I have JSFiddle example here: http://jsfiddle.net/6Ur89/1/
The issue I am running into is that, I want to the #data div to scroll vertically when it is too big for the div. The problem that I am seeing is that, when this happens, the div just gets pushed underneath the footer (instead of stopping at the footer) until infinity and scrolling never happens.
Within my CSS, I do have this:
html, body {
overflow: hidden;
}
which I put in to prevent horizontal and vertical scroll bars appearing (presumably due to the footer). However, when I remove this style, the entire content div scrolls which is almost what I want (I would prefer that the title doesn't scroll...but that isn't the end of the world).
Can anybody provide any suggestions where I am going wrong? Again - want #data div to scroll and to stop at the footer. I want a fixed footer at the bottom of the site and I don't want the footer to create the scroll bars. Please let me know if you need clarifications.
Update: Yay for Stackoverflow - after typing up this question, one answer popped up immediately. I put a clearfix on the wrapper, so scrollbars don't appear due to the fixed footer. Updated my jsfiddle to reflect. So, essentially, I'm looking to understand how to just have the #data div scroll.
http://jsfiddle.net/Xsu3Q/
added a padder inside the content div:
<div id="content">
<div class='padder'>
<div id="title">title</div>
<div id="data">Lots of data...
.padder {padding-top: 100px;}
moved the content 100px up outside the frame:
#content {
position: relative;
top: -100px;
margin-left: 350px;
height: 100%;}
This way you can use the height:100% property to match the height of the body
AND subtract the 100px for your footer.
for a cleaner example look at a similar answer

div and background image?

im having a problem regarding using background property with url('location') value with a div element. All browsers do not show the background image for any content written within the div tag.
code:
HTML:
body has a div tag with the class = slide. this div tag contains some content and links.
CSS:
div.slide {
margin: 0 auto;
background: url(images/btnslide.gif);
}
please help me identify the error. maybe i have misused div tag. please point out the solution for the above problem
thanks in advance
You either haven't set the height for your .slide element, or you haven't cleared the floats for the elements inside .slide. Try setting a height or adding overflow: auto if you want to clear the floats inside your <div>.
This code should work by default, as everybody said something else is wrong.
Either the height is wrong or the image does not exist.
Which browsers are failing exactly?
If you like you can try writting the CSS with full syntax:
background: url(..) top left repeat;

Resources