Forum Moderators: not2easy
I have a really frustrating problem.
I have an image, and I want text to wrap around it. Everything works fin in Firefox.. but ie ..
Here's how the code looks:
HTML:<div id="picture">
<img src="images/floatme.jpg" class="pic" />
</div>
Lorem ipsum
CSS:#picture
{
width: 101px;
height: 92px;
background: url('images/pic_bg.jpg');
float: left;
margin-right:5px;
margin-bottom:5px;
}
img.pic
{
left: 8px;
top: 8px;
position: relative;
}
the picture div is a shadow, and the img.pic property centers my image inside the shadow container.
The problem is, that in IE the image and the shadow div don't even show up, I just get text without an image.
Everything works fine in Firefox, the image shows up, the text wraps perfectly, but this issue with IE is killing me :/
Does anyone know a solution for this?
Also I assume there is a container div in which div #picture is being floated?
If was my problem I would debug it by taking out everything but the essentials, check that worked, then add the next element. For example take out all the images, set a background-color on the div, and make sure that showed up. The add in the background image, etc.
Well that's what I did, the debugging. The problem is the same with or without the images. it happens when I add the float element.
One other option if you want to retain the img.pic class, is remove the position:relative and add display:block;
And the floated <div> should come before the text in the html that is to wrap it:
<div>floated division</div>
<p>text to wrap</p>
Marshall
The other thing I would check for is typos. For example if you have a missing semicolon in your css above one of your styles, then that style could be being ignored. Also a typo in the html can throw things.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>v2</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<div id="content">
<div id="logo_container">
<div id="logo1"></div>
<div id="logo2"></div>
</div>
<div id="menu">
Links
</div>
<div id="lcontent">
<h2>Welcome</h2>
<div id="dots"></div><br />
<div id="pic"> <img src="images/floatme.jpg" class="pic" /> </div>Lorem Ipsum
</div>
</div>
</div></body>
</html>
CSS:
body
{
margin: 0;
padding: 0;
background: #f2f2f2;
font-family: Tahoma;
font-size: 12px;
letter-spacing: 1pt;
line-height: 13pt;
}#main
{
width: 742px;
height: 829px;
min-height: 829px;
height: auto;
background: url('images/mainshaddow.jpg') repeat;
left: 50%;
margin-left: -380px;
position: absolute;
}
#content
{
width: 684px;
height: auto;
position: relative;
left: 29px;
}
#logo_container
{
width: 684px;
height: 133px;
top: 18px;
position: absolute;
}
#logo1
{
width: 245px;
height: 133px;
background: url('images/logo.jpg');
position: absolute;
}
#logo2
{
width: 430px;
height: 133px;
background: url('images/logo2.jpg');
left: 253px;
position: absolute;
}
#menu
{
width: 684px;
height: 34px;
background: url('images/menu_bg.jpg') repeat;
top: 156px;
position: absolute;
}
#lcontent
{
width: 482px;
height: 200px;
top: 200px;
position: absolute;
}
h2
{
font-size: 18px;
color: #252525;
letter-spacing: 0.1pt;
}
#dots
{
width: 100%;
height: 1px;
background: #252525 url('images/dot.jpg') repeat-x;
margin-top: 0px;
position: inherit;
}
#pic
{
width: 101px;
height: 92px;
background: url('images/pic_bg.jpg');
margin-right:5px;
margin-bottom:5px;
}
img.pic
{
left: 8px;
top: 8px;
position: relative;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>the picture div is a shadow</title>
<style type="text/css">
#picture
{
width: 101px;
height: 92px;
background: url('images/pic_bg.jpg');
float: left;
margin-right:5px;
margin-bottom:5px;
}
img.pic
{
left: 8px;
top: 8px;
position: relative;
}
</style>
</head>
<body>
<div id="picture">
<img src="images/floatme.jpg" class="pic" />
</div>
<p>the picture div is a shadow, and the img.pic property centers my image inside the shadow container.
The problem is, that in IE the image and the shadow div don't even show up, I just get text without an image.
Everything works fine in Firefox, the image shows up, the text wraps perfectly, but this issue with IE is killing me :/
Does anyone know a solution for this? </p>
</body>
</html>
Marshall