views:

1334

answers:

6

Strange one here, hoping to get some feedback to point me in the right direction.

If my #wrapper or any of the child divs do not have a background-color applied to them, ie7 changes the normal "pointer" cursor into a "text-select" cursor when mousing around the page (whether mousing over text or not).

I thought I had fixed the problem a while back, but when I remove the background-color from my #wrapper or any of the children divs, the problem reappears.

Just looking for some hints or what I should be checking.

#wrapper {
    overflow: hidden;
    margin: 0 auto;
    width: 960px; /* using 960.gs */
}

#children {
    display: inline;
    float: left;
    margin: 0 10px;
    width: 940px;
}

EDIT:

Seems to be because the divs "hasLayout", but I'm still not sure how to fix it. See this link.

EDIT 2:

I can't find any more info on this "ie7 bug." Anyone who has any ideas, or even if you're aware of this bug and can just let me know so I know I'm not crazy. I'm getting really frustrated with Microsoft again. Already cost me an extra few hours of work this week. Seems like it never ends.

EDIT 3:

Here's another link of someone having the same problem.

EDIT 4:

STACKOVERFLOW.com suffers from this bug! So does mashable.com. I guarantee MANY web devs have this bug on their site and they don't even know it.

Check it out for yourself... hover your cursor around the page of either site. Notice it turns to a text-select cursor when it shouldn't.

Seems like it would be easy to fix with the cursor property, but the problem would be triggering proper text-select-cursor behavior when required.

A: 

Have you tried setting background-color:transparent; explicitly? Does that help?

stephenhay
Yeppers, tried it. Doesn't work. I guess I'm hoping someone can give me something to "Google." Seems strange that not many folks have experienced this before.
Jeff
Too bad: I thought transparent would be enough of a "background" to keep it from happening. I'm assuming you don't want any background? Otherwise, you could add one in a IE7 style sheet via conditional comments. Seems one of those rendering bugs for which there are no decent workarounds. (Javascript?) Sorry I couldn't help.
stephenhay
Yeah, my only idea so far is to muck up my CSS and put a `background-color` that matches the main part of my site -- JUST FOR IE7, Lol.
Jeff
A: 

This may sound like an ugly hack, but have you tried setting a transparent 1x1 px GIF (AKA spacer) as background?

Seb
Haven't tried that, but if it comes to that, I think I'd rather just set a background-color instead. Good suggestion, though.
Jeff
THis sounds good. @Jeff: Did it help?
Pekka
A: 

This is not perfect, but for this little example it seems to work for IE 7.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
</head>
<body>
<div style="overflow: hidden; margin: 0 auto; width: 140px;">
   <div style="position: relative; display: inline;">
      <p>
         Here is some test text that will wrap.
      </p>
   </div>
</div>
</body>
</html>

I have no idea why this seems to work, and it is certainly not ideal. For some reason putting the p element in an inline relatively positioned div makes the mouse cursor behave more like I'd expect.

I'm not sure that this works in a broader sense though when there is a hierarchy of elements.

I realize this is not a perfect answer, but it might spur other ideas.

Nathan
+1  A: 

I'm pretty sure I have encountered it before, but it's probably a bit too subtle to really notice during some superficial browser testing. But I've certainly also had issues fixed by setting a background color.

As far as I can tell, the best way to fix it is to position the element causing the problems, or add a positioned wrapper div around it. You would most likely use position: relative, though absolute and fixed should work too.

Positioning the element itself usually works, but adding a wrapper div might work more consistently.

E.g. adding position: relative to the .post-text class fixes the cursor on the questions and answers on this page.

mercator
Adding `position: relative;` to my #wrapper made no difference for me. As for wrapping my wrapper, well, I guess I'd rather live with the cursor oddity. =)
Jeff
Fair enough. I'm curious, though, does adding the extra positioned wrapper fix it?
mercator
+3  A: 

Is it too hacky to explicitly state what cursor should go where? ;-)

html {
    cursor: default;
}

h1, h2, h3, h4, h5, h6,
p, li, label, td, th {
    cursor: text;
}

a:link, a:visited, a:hover, a:active {
    cursor: pointer;
}

etc..

Zoe
That still doesn't entirely fix it. The text cursor then appears on the entire block, including any padding and blank space on a partly filled last line, for example, instead of just the actual text.
mercator
Agreed. Great idea, one I've already tried, but doesn't cut it for the reason cited by mercator.
Jeff
Hmmm, need it *that* precise, do we? Oh dear.. please see my comment on the question requesting a bit more info on the reasoning.
Zoe
A: 

Delilah's solution, only a little bit simplified works great for me and also solves mercator's issue.

div { cursor: default; }
div * { cursor: auto; }

The problem is you have to create another css file and address it using conditional comments not to brake other browsers.

PS: This issue becomes very annoying with dark background websites.

puijob