CSS Help

KingKaeru

Supreme [H]ardness
Joined
Jul 16, 2000
Messages
6,465
Hi Guys,

I'm running into some problems creating a clip area in css for Internet Explorer.

The markup and styling works perfectly in Mozilla Firefox but doesnt in IE.

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <style type="text/css">
      .clip {
        width:400px;
        height:200px;
        background-color:#000;
        overflow:hidden;
        border:1px solid red;
        margin-top:100px;
      }

      .content {
        background-color:#000080;
        color:#FFF;
        position:relative;
        top:-50px;
      }
    </style>
  </head>
  <body style="background-color:#222222;">
    <div class="clip">
      <div class="content">
        HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum HardForum 
      </div>
    </div>
  </body>
</html>

clipproblem.gif


If you remove the doctype to have the page render in quirks mode, the clipping area gets rendered correctly in both IE and firefox.

Anyone know how I can get IE to properly clip the content div in XHTML 1.0 Strict?

I know that if I used a table rather than a div for the clipping rectangle that it'll work in both browsers but I would like to avoid doing so.

Thanks! :)
--KK
 
w00t! figured it out. I've been wrestling with this since last week and I can't believe the solution was right in front of me :p.

for those who care:

HTML:
        width:400px;
        height:200px;
        background-color:#000;
        color: #FFF;
        overflow:hidden;
        border:1px solid red;
        margin-top:100px;
        display:block;
      }

      .content {
        background-color:#000080;
        color:#FFF;
        margin-top:-50px;
      }

Rather than positioning the content div relative to the parent with a negative top position. Using a negative top margin on the content div caused it to clip properly.


--KK
 
Back
Top