IE7 Menu HasLayout issue - css

So I have been Googling and I am quite sure my problem emerge from the hasLayout issues with IE7 and lower.
My problem:
See image here
The HTML Code under here. The problem lies between the id="header" div and the id="colortab" div.
<div id="header">
<div class="logo"><img src="images/logo.gif" border="0" alt="" /></div>
<div class="hotline"><img src="images/ds_garanti.png" border="0" alt="" /></div>
</div>
<div id="colortab" class="ddcolortabs">
<ul>
<li><span>Forside</span></li>
<li><span>Vi tilbyder</span></li>
<li><span>Faste Tilbud</span></li>
<li><span>Garanti</span></li>
<li><span>Kontakt</span></li>
</ul>
</div>
<!--1st drop down menu -->
<div id="dropmenu1_a" class="dropmenudiv_a">
Stål og smedearbejde
VVS arbejde
Udlejning
</div>
<!--2nd drop down menu -->
<div id="dropmenu2_a" class="dropmenudiv_a">
Tilbud på stål og smedearbejde
Tilbud på VVS arbejde
Tilbud på udlejning
</div>
<script type="text/javascript">
//SYNTAX: tabdropdown.init("menu_id", [integer OR "auto"])
tabdropdown.init("colortab", 3)
</script>
And the belonging CSS can be seen here http://mhlhost.com/stackstyle.css
Very much appriciated if someone can help me out here. I can't figure out which elements causes me trouble :(

Floating the header left will close the gap in ie6/7.
#header{
position:relative;
height:100px;
background-color:#fff;
width:855px;
float:left;
}

Related

Unable to set div margin-top

I tried the following html code (an example from w3schools site):
<!DOCTYPE html>
<html>
<body>
<div id="container" style="width:500px">
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1>
</div>
<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br />
HTML<br />
CSS<br />
JavaScript
</div>
<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here
</div>
<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;margin-top:20px">
Copyright © W3Schools.com
</div>
</div>
</body>
</html>
And this is the output:
I need to add a space between the sections #footer and #content, and as you can see I tried using the margin-top attribute, but any value I use (in my example 20px) does not change the result: there is no space between the two sections.
How can I solve this problem?
Another reason why floats suck as much as they rock.
You can add an empty div in between the footer and the content like...
//content html
<div style='clear:both;'></div>
//footer html
http://jsfiddle.net/rK5zV/1/
Or you can make the footer a float also with a width of 100% like...
http://jsfiddle.net/7KZy9/
Other solutions can be found here...
Why top margin of html element is ignored after floated element?
You can add to content margin-bottom:20px;
<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;margin-bottom: 20px;">
You can place all your elements apart from the footer in a wrapper that has margin-bottom: 20px:
<body>
<div id="container" style="width:500px">
<div id="wrapper" style="margin-bottom: 20px; border: 1px solid black; width: 100%; float: left;">
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1>
</div>
<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</div>
<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here
</div>
</div>
<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
Copyright © W3Schools.com
</div>
</div>
</body>
Here is a jsFiddle that demonstrates the behavior.
I gave your footer relative positioning and used the top attribute
Here is a working DEMO
<div id="container" style="width:500px">
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1>
</div>
<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br />
HTML<br />
CSS<br />
JavaScript
</div>
<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here
</div>
<div id="footer" style="background-color:#FFA500;clear:left;text-align:center;position:relative;top:20px">
Copyright © W3Schools.com
</div>
</div>
Try making footer display: inline-block; width: 100%. It's not ideal, but it works.
After two blocks with styles float you should to use element with style cler:both;
You code view like this
<div id="content">
...
</div>
<div style="clear:both;"></div>
<div id="footer">
...
</div>

3 horizontal image layout issue

I have been trying to achieve getting 3 images side by side. I finally got it the exact way I want them laid out. A few ways I tried, one image would always move down on smaller screens. They way I have it now is the exact way I want but the code i used is a bit messed up(not even sure if correct but it works).
My code has 4 images and just 3 show up. Again it shows up the way I want. The image that doesn't show up is the 2 one in the code. I dont want the image to show up anyways but I know it shouldnt be in there either.
I struggle with this stuff so any help on how this should read correctly is appreciated.
When I remove the 2 image in the code they all go out of line.
<div id="content">
<center><div><br><br><br><br><br><br>
<img src="images/image1.png" width="30%" style="float:left;/> <img src="images/image2.png" width="50%" style="float:left;"/>
</div>
<img src="images/image3.png" width="30%"/><img src="images/image2" width="30%" style="float:right;"/>
</div>
</center>
<br><br><br><br><br><br><br><br><br></div>
</div>
<div id="content" width="100%">
<div>
<img src="1.jpg" width="30%" style="float:left"/>
<img src="2.jpg" width="30%" style="float:left"/>
<img src="3.jpg" width="30%" style="float:left"/>
</div>
</div>
Here is the simplest and clean code...
fiddle :http://jsfiddle.net/ag3Et/1/
css
#content{
width:100%;
float:left;
}
#content img{
width:32%;
margin-left:1%;
float:left;
}
html
<div id="content">
<img src="http://www.birds.com/wp-content/uploads/home/bird4.jpg"/>
<img src="http://www.hdwallpapers3d.com/wp-content/uploads/2013/05/HD-Birds-wallpaper-3.jpg"/>
<img src="http://www.oassf.com/en/media/images/birds_wallpaper.jpg"/>
</div>
This is the answer for your ques.. please mark it as an answer after using this code so that others can also use it in future...
<div id="content">
<center><div><br><br><br><br><br><br>
<img src="1.jpg" width="30%" style="float:left;"/>
<img src="2.jpg" width="30%"/>
<img src="3.jpg" width="30%" style="float:right;"/>
</div>
</center>
</div>
<br><br><br><br><br><br><br><br><br></div>
</div>
You should definitely brush up on your html and css.
You need to set fixed pixel values so your images can fit into place and stay as you would like them to.
CSS:
#content{ width: 960xpx; margin:30px auto; } //the margin is to center this whole block
img{ width: 320px; float:left;} //each image is defined as a fixed 320px
.clear{ clear: both; } //makes sure things don't overlap
HTML:
<div id="content">
<img src="images/image1.png"/>
<img src="images/image2.png"/>
<img src="images/image3.png"/>
<div class="clear">
<!-- SOME OTHER CONTENT HERE -->
</div>
</div>

Floats affecting other divs?

I have a webpage I made here: http://jsfiddle.net/KM9HJ/
<!DOCTYPE html />
<head>
<title>Home</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="logo">
<img style="width:50; height:50; float:left;" src="Content/Portal%20Layered.png"/>
<img style="width:50; height:50; position:relative; left:-50px; z-index:2;" src="Content/Blank.png"/>
<div><h2 id="headerh2">Cody Shearer</h2></div>
</div>
<div id="wrapper">
<div style="background-color:#565656">
<div id="links">HOME</div>
<div id="links">ABOUT ME</div>
<div id="links">GALLERY</div>
</div>
<article id="para">
<p>About This Website</p>
<div id="paraL2"><p>About this page:</p> <div id="paraP">This is</div></div></article>
</div>
</body>
If you look at the div that says "About this page:" you will see that it is positioned to the far right of the div and part of it is cut off (you may have to resize the result area to see this). What I want the words to do is to stay on one line and be aligned to the left. From what I have seen the issue can be fixed by removing the "float:left" from the #links area, or It can be helped a little by removing the "width: 150px;" from #link. The only issue is that I spent a long time trying to get other s
adding clear:left may help you.
#para {
clear:left;
....

twitter-bootstrap .thumbnail/.pull-left and blockquote overlapping

I am sure there is a simple solution to it.. but I have some markup that is overlapping. I have a img.pull-left and a blockquote. The img is currently sitting in between the grey left border and the block quote. Markup is pretty simple:
<div class='container'>
<div class='row'>
<div class="entry-content clearfix">
<a class="pull-left" href="#noop" title="The first post">
<img width="70" height="47" src="logo-lw.png" class="inline attachment-thumbnail wp-post-image" alt="logo-lw"/>
</a>
<blockquote>
<p>Some Quote...</p>
</blockquote>
</div>
</div>
</div>
Here is a fiddle showing the issue
Add inline-block to the blockquote:
blockquote{
display: inline-block;
}
This is also a good use case for the bootstrap media object.

float left query not covered by parent

Following HTML block:
<html>
<body>
<div style="background-color: #fecfff;">
<div style="float:left;">
<div style="height:40px; width:40px; background-color:Red"> </div>
Karl Mac
</div>
<div>
some comments details<br />
<div style="padding-top: 10px">
links
</div>
</div>
</body>
</html>
Produces following:
How can I have Karl Mac too covered with color of parent container in this 2 column layout?
If I add "overflow:auto", it gets fixed in Firefox and Chrome. But issue persists in IE.
thanks!
As you've done for Chrome & Firefox:
overflow: auto;
To make it work in old IE as well:
overflow: auto; zoom: 1;
zoom enables "hasLayout" in old IE, which resolves many CSS bugs. There are also other ways to enable hasLayout, for more info: http://www.satzansatz.de/cssd/onhavinglayout.html
You need to <div style="clear:both;"><div> in the main div.
<html>
<body>
<div style="background-color: #fecfff;">
<div style="float:left;">
<div style="height:40px; width:40px; background-color:Red"> </div>
Karl Mac
</div>
<div>
some comments details<br />
<div style="padding-top: 10px">
links
</div>
<div style="clear:both;"><div>
</div>
</body>
</html>
Code: http://jsfiddle.net/cCuab/

Resources