Negative margin Issues only with IE - html

I'm having a issue with the navigation bar drop down positioning in IE.
As you can see, the Adhesive Tapes drop down is positioned fine on hover but when hovering over 'Adhesives' and Sealants it is slightly out of position.
I've checked it in Firefox and it's the same but only out by a few pixels.
I've spent some time this morning trying to solve it but only have limited knowledge.
Any help would be great.
www.stickyproducts.co.uk
HTML:http://pastebin.com/z7tu6wCX
CSS:http://pastebin.com/XjnXqEN8
Thanks in advance for any help

Personally I wouldn't set the position of the drop down menu to -999. I would position it in the exact spot it needs to be and then set the visibility: property to hidden;
something like this
.dropdown_4columns_sealants {
margin:4px auto;
float:left;
position:absolute;
left:-999em; /* I would set this to position where it should be all the time */
text-align:left;
padding:10px 5px 0px 5px;
border:1px solid #777777;
border-top:none;
z-index: 999;
visibility: hidden; /* I would set this to hide the menu right where it is at */
}
then in my JavaScript I would change the visibility property to visible when you hover over the links rather than reposition it from the original -999em.

I don't think you have a problem with the dropdown, unless there is something else I'm not seeing. But I did see you are forcing a margin -9px to left. I corrected that. Here is the code corrections and the before and after pictures
#menu, .nav-cush {
margin: 0px;
}
.overhang-right {
float: right;
position: relative;
right: 0px;
}
You can actually replace those margin corrections in the css that is already made for them instead of copying and pasting that exact code I gave you. That way you don't have to use !important to overrride anything.
Since you are displaying several behaviors in different browsers. I've edited the lines below with browser hacks. I tested in all browsers and they work. Please do some testing yourself and let me know if it needs work or mark it as an answer so that others can benefit from it.
Find and replace the following:
.dropdown_4columns_adhesives {
width: 988px;
float: left;
margin: 11px 0 0 -204px; /* Chrome & Safari */
margin: 11px 0 0 -198px \0/IE9; /* IE9+ & Opera*/
}
#-moz-document url-prefix(){
.dropdown_4columns_adhesives {margin: 11px 0 0 -203px;} /* Firefox */
}
.dropdown_4columns_sealants {
width: 988px;
margin: 11px 0 0 -349px; /* Chrome & Safari */
margin: 11px 0 0 -339px \0/IE9; /* IE9+ & Opera*/
}
#-moz-document url-prefix(){
.dropdown_4columns_sealants {margin: 11px 0 0 -348px;}/* Firefox */
}
This shows your menu bar pushed to the left
This shows your menu bar and ad image corrected

A better way to handle what you're doing would be to absolute position the dropdown within the main ul#menu (set to relative). Also, take position:relative OFF of the #menu li
this way you could set the dropdown div to position:absolute; top:100%; left:0; right:0; .
The way you have it right now (handling with negative margin) is dependent on the browsers' font rendering. As you can tell this is not consistent between browsers.
Doing it this way you wouldn't have to specify anything for the individual submenus. top:100%; left:0; right:0; would be able to be used for all 3.
An alternative option would be to set specific widths on all of your top level menu links.

Related

How to get cross-browser form `fieldset` content height in % (with legend)

I want to set in % the height of a div included in a fieldset,
but browsers don't calculate the same way the inside height of the fieldset when you use legend !
Firefox: height: 100% consider the height of the legend: it's ok.
Chrome: height: 100% does NOT consider the height of the legend: it overflows.
Internet Explorer: height: 100% does NOT consider the height of the legend: it overflows.
1. Do you know a clean solution to have the same result in the 3 browsers?
2. Which is right compared to W3C recommendations?
Here is the code used to make the test:
<html>
<body>
<fieldset style="height:60px;width:150px;">
<legend>Legend</legend>
<div style="height:100%;width:100%;margin:0;padding:0;background-color:#FF0000;">
DIV : height 100%
</div>
</fieldset>
</body>
</html>
This is an interesting case.
To your 2nd question: It might arise out of W3C HTML5 standard spec being very vague of the visual representation of <legend> element. There has been a long history of browser inconsistencies around <legend>.
To answer your question 1. and come up with a cross-browser consistent position of legend:
In order to get the miscalculation resolved, you have to remove legend from the content flow, for example by adding float to it. Then you need to reposition it relatively and 456bereastreet.com came up with a sibling selector clearing the float immediately after.
Demo:
https://codepen.io/Volker_E/full/zqPjrK/
CSS code on top of your inline styles:
fieldset {
position: relative;
margin: 0;
border: 1px solid #000;
padding: 0;
}
legend {
float: left;
margin-top: -1em;
line-height: 1em;
}
legend + * { /* #link: http://www.456bereastreet.com/archive/201302/fieldset_legend_border-radius_and_box-shadow/ */
clear: both;
}
It is indeed browser differences (bugs?) or vague spec, which don't allow to style it consistently without taking legend out of flow.
This is an old topic, but still can be useful to someone (my solution is below).
I searched all day for a solution and did not find it. I want to display it correctly in chrome, firefox, edge, opera and IE11 (which will probably also work on IE10).
"Float" or "position: absolute;" does not solve the problem for me, because it removes the transparent background of the legend. I want to keep it on the fieldset 's border and also keep its transparent background (so as one does not see the border beneath it).
I tried with negative top/bottom margins, but then I have a problem in firefox (which infact is the only one who displays the legend correctly).
How I solved it:
I just put "line-height: 0;" (no unit) on my legend and now it displays it correctly.
This way I managed to get the full height of the filedset, from top to bottom border (without the bottom overflow), with overlapping the content with the legend.
Now this can be solved with filedset's padding (detach the content from the label and/or vertically center it with top/bottom padding on the fieldset etc.).
If you need a border on the legend, you can do it with an absolutely positioned pseudo-element (width 100%, height in px/em/rem, top 50%, left: 0, translateY -50%), because padding on legend (even with negative margins) will bring back the same problem.
I tested this in all above-mentioned browsers, on Windows 8.1.
I have not tested it on mobile or safari. I will test it on several mobile browsers (android), but if there's someone to check it on safari, it would be nice.
I was going crazy with the same issue and I've found a css snippet for normalizing fieldsets, And it goes right, in my case I had to remove some properties that are unnecesary, I've removed the old IE versions support too.
this is what I've used to solve my problem commenting unnecesary lines and IE support:
fieldset {
margin: 0px; padding: 0px; display: block; position: relative; width: 100%;
//%border-top: none !important; /* for IE7, does not work with Webkit */
//_padding-top: 3em; /* for IE6 */
}
fieldset > * {
width: auto;
//%width: auto !important; /* for IE7 */
// margin-left: 1.5em; /* emulating fieldset padding-left */
// margin-left: 1.5em !important; /* for IE7 */
}
fieldset *:first-child + * {
// margin-top: 3em; /* emulating fieldset padding-top */
}
fieldset:last-child {
margin-bottom: 1.5em; } /* emulating fieldset pading-bottom */
legend {
width: 100%;
//%width: 100% !important; /* for IE7 */
position: absolute;
top: -1px; left: -1px; /* hide the fieldset border */
margin: 0px !important; /* suppress all margin rules */
line-height: 2em; /* emulating padding-top/bottom */
text-indent: 1.5em; /* emulating padding-left */
//%left: -8px;
} /* for IE7 */
/* user format */
fieldset, legend {
border: 1px solid #ddd;
background-color: #eee;
-moz-border-radius-topleft: 5px;
border-top-left-radius: 5px;
-moz-border-radius-topright: 5px;
border-top-right-radius: 5px;
}
legend {
font-weight: normal;
font-style: italic;
font-size: 1.2em;
text-shadow: #fff 1px 1px 1px; }
fieldset {
background-color: #f7f7f7;
width: 360px;
-moz-border-radius-bottomleft: 5px;
border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-right-radius: 5px; }
This is the first time I try to help on stackoverflow, usually I only read the answers. Well the original and Snippet is on https://gist.github.com/paranoiq/827956/31303920733a98805cd46915c249ec788cfca6a6
Really, really usefull to understand how fieldsets works around different browsers, hope it can save others from frustration.
Pd: Sorry if my english isn't good enough, but hope you can understand it perfectly

Prevent IE8 from making content transparent

I have a div with its individual CSS for IE8, it is transparent. How can I prevent IE8 from making content inside this div also transparent? It should be 100% visible and not transparent. Thanks so much for suggestions.
Fiddle (to be watched at in IE8)
.mybox {
position: absolute;
top: 362px;
left: 0;
width: 460px;
height:94px;
overflow: hidden;
text-align: left;
padding-left: 10px;
padding-top: 3px;
overflow:hidden;
background-color:#000000;
/* background: transparent; */
-ms-filter: "alpha(opacity=60)";
/* zoom:1 ; */
/* -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)"; */
/* -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; */
/*filter: alpha(opacity=60);*/
}
OT: Ok I know this is kind of old school. But still my customer wants this page to be compatible with IE8.
Related resources:
2
3
4
Opacity in inherited to all children, by design. New browsers can use alpha-channel (RGBA) to get around this, IE8 cannot.
All you can really do is use absolute-positioning to place the content you want visible over-top of the transparent bits. You of course need to rearrange the element stacking order to do this.
You can cheat by making a copy of the contents, minus the transparent element, and placing it over top of the existing element using JS.
If the div has the class called .mybox then try and definitively set the opacity perhaps by adding opacity: 1;
Finally, I found an even better solution:
.mybox {
background:none transparent scroll repeat 0 0;
filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#98000000,endColorStr=#98000000);
}
UPDATED: Take a look with IE8
I obviously messed up something with the filter declaration, I am sorry about that... :(

Issue with formatting in Internet Explorer (float)

Having a bit of an issue with formatting on internet explorer
Site here
In the header, all that stuff is supposed to appear in 1 row. In chrome and FF, it does, but when I open up ie9, it appears as a new line. I've tried changing the float, changing the display type and modifying the width and margin attributes but I can't get a fix on the issue.
For the headRight class, even when I change the width, it doesn't change in IE and I'm not sure why.
Code here:
.headRight { width:650px !important; _width:600px!important; float:right;}
.faderdiv
{
display:inline;
float:right;
margin-top: 35px !important;
}
.donate
{
display:inline;
float:left;
margin: 55px 90px 0 !important;
}
this is actually for ie7 but I think this will work for your problems too. IE7 float right problems

Tables inside a div? IE7 compatability issue - looking for a resource to expand knowledge on how to deal with IE7 problems

I'm currently doing the redesign for this site: http://www.palosverdes.com/rpv2012/ and have run into a problem with repeating a gradient inside a div (cnews). The issue is that when the gradient is repeated on IE7, there is a color problem. It almost seems as if the blue on the image is lightened somehow. When I set the attribute to no-repeat, I don't get the rounded edges effect I'd like the achieve.
Here's the code in question:
<div class="box-noshadow" id="cnews">
<div id="spotlight">
</div><!--spotlight-->
<div onmouseout="document.getElementById('stop').start();" onmouseover="document.getElementById('stop').stop();" id="stopmarquee">
<div align="center" id="toptitle">
CITY NEWS & EVENTS
</div><!--toptitle-->
<div id="cnewscontainer">
<iframe align="middle" width="400px" scrolling="no" height="100px" frameborder="0" src="scroll_file_b/break2.cfm"></iframe>
</div><!--cnewscontainer-->
</div><!--stopmarquee-->
</div><!--cnews-->
and the relevant CSS:
#cnews {
width: 100%;
background-image:url(images/cnews-back.jpg);
float: left;
padding: 5px;
font-family:Arial, Helvetica, sans-serif;
overflow:hidden;}
#spotlight {
width: 50%;
height: 200px;
background-color: yellow;
float: right;
padding: 5px;}
.box {-moz-border-radius: 15px; /* Firefox */
-webkit-border-radius: 15px; /* Safari and Chrome */
border-radius: 15px; /* Opera 10.5+, future browsers, and now also Internet Explorer 6+ using IE-CSS3 */
-moz-box-shadow: 10px 10px 20px #000; /* Firefox */
-webkit-box-shadow: 10px 10px 20px #000; /* Safari and Chrome */
box-shadow: 10px 10px 20px #000; /* Opera 10.5+, future browsers and IE6+ using IE-CSS3 */
behavior: url(PIE.htc); /* This lets IE know to call the script on all elements which get the 'box' class */}
What solution can I pursue that will allow this to still render correctly in modern browsers as well? Should I use IE7-specific CSS?
Also, where can I look to see what HTML/CSS ie7 has problems interpreting compared to modern browsers?
Your width:50% on your stopmarquee is causing that item to drop down lower in IE7, instead of rising up next to the right floated spotlight div. This is causing your cnews container to expand down further, which is then causing your background image to repeat in the 'y' direction (like 3rror404 stated in his comment).
Your background image itself has a color shift within it, so that the top of the image is lighter than the lower part of the image, thus you are getting a lighter look when the image repeats in the 'y' direction.
You can correct the stopmarquee position by changing to width: 49% (which I don't think will hurt your layout), and that will probably resolve your issue. Otherwise, make the background image a solid color so that a repeat does not cause the issue.

The height of my div is not the same in IE and firefox

I am having trouble with handling the vertical alignment of a div within another div in IE.
My html code is as follows :
<div class="header">
<div id="mainMenu">
<!--Here goes my main menu-->
</div>
</div>
My styles are as follows :
#mainMenu
{
/*background-color: #FFF;*/
font-family: fantasy, cursive, Serif;
font-size:16px;
/*border-bottom:1px solid #000000;*/
height:125px;
position:relative;
}
.header {
top: 0px;
color:#FFA500;
z-index:1000;
height:120px;
padding:8px 2px 8px 15px;
overflow:hidden;
-moz-border-radius:0 0 10px 10px;
-webkit-border-radius:0 0 10px 10px;
border-radius:0 0 10px 10px;
-moz-box-shadow:0 1px 3px #777;
-webkit-box-shadow:0 2px 3px #777;
box-shadow:0 2px 3px #777;
background: url("../images/plusoneurls_resize.png") repeat scroll 0 0 transparent;
}
Now in firefox , my main items are showing at the bottom when I mahe the height attribute to 120px (100%) for the style attached to #mainMenu , but it's not working in IE.
I even tried by giving top:100% , in firefox it shows fine ,but in IE , it's overflowing into the main content.
How to devise a workaround for this?
Check that you're not in Quirks mode.
If you don't have a valid <!DOCTYPE> declaration at the top of your HTML code, IE will drop into Quirks mode. This mode changes a number of aspects of CSS, and tends to have a fairly dramatic effects on heights and widths of elements.
Quirks mode is a legacy feature, which should never be used any more, so you should always make sure you have a valid doctype. you haven't provided enough of your code for me to know whether you've got one or not, but if not, you need to add one.
If you're not sure what doctype to use, simply use the HTML5 doctype, like so:
<!DOCTYPE html>
Put this at the very top of your HTML code (first line, before the <html> tag or anything).
Use a CSS reset.
YUI provides a good one.
#mainMenu
{
position: absolute;
bottom: 0;
left: 0;
}
.header
{
position: relative;
}
How (Not) To Vertically Center Content
Would definitely recommend using CSS, but they also illustrate and example using Tables
Make sure the zoom level is set to 100% on both browsers. (Ctrl+0)