this is my css. It is working fine in firefox but not working in IE.
#Createinner {
position: fixed;
width: 400px;
height: 280px;
margin-left: -200px;
margin-top: -140px;
top: 50%;
left: 50%;
background-color: #ccc;
}
How to solve this.
Thanks in advance
Simply add DocType Tag on top of the page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
What sorted my problem with IE was the code in:
http://annevankesteren.nl/test/examples/ie/position-fixed.html
basically added:
h1{
position:fixed;
_position:absolute;
top:0;
_top:expression(eval(document.body.scrollTop));
}
for fixed position in IE 8
DOCTYPE is very very important.
one of:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
or
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
or
<!DOCTYPE HTML>
And its very very important that
those be in first line.
css:
#footer
{position: fixed; right: 0px; bottom: 0px; }
html:
<div id="footer" >
Fixed Div
</div>
IE6 doesn't support position fixed.
If you really need this to work in IE6, use conditional comments to serve an IE only CSS file and fake position:fixed with CSS expressions.
(edited to correct IE version info.)
I recently wrote a jQuery plugin to get position:fixed working in IE 6+. It doesn't jitter on scroll, it looks at capability (not user-agent), works in Internet Explorer 6, 7, 8.
If you use strict mode in IE7+ position:fixed will be honoured, but by default IE7+ operates in Quirks Mode. This plugin checks for browser capability, and if it doesn't honour position:fixed, then it implements the jQuery fix.
http://code.google.com/p/fixedposition/
Something like this may work for you:
$(document).ready(function(){
$("#Createinner").fixedPosition({
debug: true,
fixedTo: "bottom"
});
});
You may need to make some minor CSS adjustments to get it working for your code. I'm working on "offset" values as options as we speak.
Versions of IE pre 8 do not support position fixed properly.
What is the problem with the CSS e.g. why is it not working, what do you see on the screen?
http://ieproblems.blogspot.com/ use this one it will solve your problem
#mainDiv{
overflow:auto;
}
#subDiv{
position:relative;
top:expression(this.offsetParent.scrollTop+'px');
left:expression(this.offsetParent.scrollTop+'px');
}
<html>
<head>
</head>
<body>
<div id="mainDiv">
<div id="subDiv">
This Text is Fixed
</div>
</div>
</body>
</html>
You have tagged this as HTML but `` is not an HTML element. Internet Explorer will not let you style elements that it does not recognise.
- Use only [HTML elements][1] in HTML documents
You have updated your question so that it appears you are using an id selector not a type selector. This renders my original comment irrelevant.
IE 6 does not support position: fixed
Use workarounds if you need to support IE6
Other versions of IE don't support position: fixed in quirks mode
Use a standards mode triggering Doctype (generally HTML 4.01 Strict is the right choice)
Related
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to make IE support min-width / max-width CSS properties?
I have a site that has it's main navigation in a list (floated left).
The li elements need to have a min AND max width.
This css of course works fine in all good browsers.
But IE (9) doesn't react to it.
ul.dropdown li {
line-height: normal;
text-align: center;
max-width: 145px;
min-width: 88px;
min-height: 30px;
}
If I use this code on one condition, for example max width IE respects it.
http://perishablepress.com/maximum-and-minimum-height-and-width-in-internet-explorer/
But of course I can't use the same for min-width.
I need a solution that IE respects max AND min width.
Is there a solution?
Thank You!
edit: I forgot to mention i already added
<!DOCTYPE html>
;)
Ok, I found the problem.
It wasn`t in the code, my IE just automatically switched into Quirks mode.
Changed it by going in the console (F12) and changed the Document Mode to IE9!
Thank You!
Try this (it's work on my ie8)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>template</title>
<style type="text/css">
#content{
height:400px;
background:yellow;
*width: expression(if(document.body.clientWidth < 534){"533px";}else if(document.body.clientWidth > 776){"777px";}else{ "auto"; }); /* set min-width for IE */
background: red;
}
</style>
</head>
<body>
<div id="content">
hello
</div>
</body>
</html>
I don't know how to write this with ? and :.
Hack width with this : http://paulirish.com/2009/browser-specific-css-hacks/
Is margin treated differently in IE and Mozilla ? Because when I tried Mozilla 3.6 displaying margin correctly but IE 8 stretching it too far.
Here is my code
<div id="searchCriteria">
<table width="100%" border="1" bordercolor="#64A4F5">
</table>
</div>
<div id="searchResult">
</div>
Here is my css
#searchCriteria{
height:24%;
width:100%;
float: right;
display: block;
font-family:
verdana,arial;
font-size: 12px;
}
#searchResult{
height:70%;
width:100%;
float:right;
display:block;
margin-top:15px;
margin-bottom:5px;
}
Margin between searchCriteria and searchResult div is getting stretched in IE but working fine in Mozilla.
(It looks like in IE some space is coming between table element and searchCriteria div)
I tested your code In FF 3.6.13, IE7-8. I observed the issue only in quirks mode in IE, which probably means that you're either not using a Doctype declration or using IE in quirks mode. If you're using XHTML use:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
</head>
<body>
<p>… Your HTML content here …</p>
</body>
</html>
If you're using HTML5 use:
<!DOCTYPE html>
See this for a list of other Doctype declarations to use.
height:24%;
Any certain reason to use percent values?
Anyway, I think it's probably Quirks Mode. Try adding <!DOCTYPE html> at beginning of document to see if it'll help.
Are you using a stylesheet reset? It's possible browser-inherited margins are conflicting with your design.
Eg.
div, table, td, th, tr, {
margin : 0;
padding : 0;
border : 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
Here's a link to a more extensive CSS reset
It also may be helpful to use the developer tools (F12 in IE, and the Firebug extension in Firefox) to troubleshoot the discrepancy in your design--if you gather specific information (eg. there's 4px unaccounted for,) you will have a better change at spotting the problem.
P.S. Be extra careful when working with percentages--something like padding will compound the percentage values, resulting in overages. I'm actually not sure if your border : 1 compounds with 100% (resulting in 100% + 1px,) but just a helpful reminder.
Add a second margin-top declaration to your searchResult div like so :
margin-top:10px\9;
This will target only IE8 and below. Change the amount of pixel until it looks good to you.
Added height=100% to <table> and it works.
Thank you all for your suggestions :)
i m trying to center a div(only horizontal) using the following css
.body_div
{
width: 900px;
margin-left: auto;
margin-right: auto;
background-color: #f8f3ed;
}
and it does it work in chrome and ff but not in ie
take a look here
eventually i used the same code in another site too and it worked well in ie too
now a hell lot another problem...
the borders around the #courses and #call are not shown in ie...
thanks
Remove the comment before the DOCTYPE. That places IE in quirks mode where it doesn't supports all standards.
These are currently the top lines of your site:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Change them to this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Use a single margin setting:
margin: 0 auto;
Why does this create a veritcal scrollbar in IE6, IE7 and IE8? How to avoid it?
(I had a real applet in there, but I discovered that this heavily mutilated one gave the same result and helps simplify the test case)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Why vertical scrollbar in IE?</title>
<style>
HTML, BODY {
height: 100%;
}
BODY {
padding:0;
margin:0;
}
/* And yes I can use this, but I'd rather not
BODY {
overflow-y: hidden;
}
*/
</style>
</head>
<body>
<APPLET WIDTH = "100%" HEIGHT = "100%"></APPLET>
</body>
</html>
Above also available as http://www.morch.com/download/ieVerticalScrollbars.html
applet {
display: block;
}
To prevent rendering the applet as an inline-element, which enforces line-height rendering.
Add position: absolute; to the applet's style.
Try bringing the height down to 99% or 98%. Or try throwing in some more thorough reset CSS. Don't ever use overflow-y on a body element. Terrible usability.
Thing 1 -- CSS/overflow
Here are the CSS settings you can work with (if they help): http://www.w3schools.com/Css/pr_pos_overflow.asp
Thing 2 -- CSS-erize the scrollbar itself (i.e., turn it completely white, or whatever works for your page.: http://www.draac.com/css/csstricks.html (scroll down a ways)
The following code renders differently in IE7 and FF3 (NEW CODE POSTED OLD CODE WAS MISLEADING - sorry for confusion)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
#boxr1{
background-color:#FFFFFF;
border:3px solid #DDDDCA;
float:right;
width:420px;
}
#boxr2{
background-color:#FFFFFF;
border:3px solid #DDDDCA;
float:right;
width:420px;
}
#boxleft{
border:3px solid #DDDDCA;
color:#277491;
width:300px;
}
</style>
</head>
<body>
<div style="width:800px">
<div id="boxr1">test<br/>test<br/></div>
<div id="boxr2">test2<br/>test2<br/></div>
<div id="boxleft">leftdiv</div>
</div>
<div style="clear:both;"></div>
</body>
</html>
I can't seem to figure out what is causing the difference. I want it to behave the way FF does (of course). Any guidance is appreciated. The difference I see is that in FF the left div starts at the top of the page whereas in IE it is rendered "below" the other divs (although it is over to the left).
Starting with FF 3.5, they starting using the same box-model rendering as other more modern browsers (IE8, Safari, Chrome). IE7 is using an earlier out-dated model. You may need to target IE7 specifically with a CSS hack. One common IE7 hack is the *:first-child+html hack.
*:first-child+html <your class or id>
{
margin: ...
}
This will target ONLY IE7. If you want to target FF 3+, you can use:
html>/**/body <your class or id>
{
margin: ...
}
and for FF 3.5 ONLY:
body:nth-of-type(1) <your class or id>
{
margin: ...
}
I tweaked your original example a little and the code below looks the same in IE, FF, Chrome, and Opera.
<html>
<head>
<style>
#wrapper{
width: 923px;
vertical-align: top;
}
.boxRight{
background-color:#FFFFFF;
border:3px solid #DDDDCA;
float:right;
margin:3px 0;
width:560px;
}
#boxleft{
color:#277491;
width:357px;
float: left;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="boxleft">leftdiv</div>
<div id="boxr1" class="boxRight">test<br/>test<br/></div>
<div id="boxr2" class="boxRight">test2<br/>test2<br/></div>
</div>
<div style="clear:both;"></div>
</body>
</html>
EDIT:
I updated my code after your edit to your original post. The above works in FF, Chrome, IE, Opera.
Since IE 7 does not include padding when deciding the width of the element while other modern browsers do the only option for you is to use a IE 7 only hack with width:560px
Instead of doing any hacks, try adding this to the beginning of the document before the <html> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Without a doctype declaration, IE7 goes into quirksmode and padding works differently than in Firefox.
From wikipedia (in quirksmode IE7 acts like IE5 in this regard):
When a width or height is explicitly specified for any block-level element, it should determine only the width or height of the visible element, with the padding, borders, and margins applied afterward. Internet Explorer 5 includes the content, padding and borders within a specified width or height; this results in a narrower or shorter rendering of a box.