Toni Michel Caubet
Toni Michel Caubet

Reputation: 20183

solve this style problem for IE6 and IE7

First i will show you the problem, wich only happens on IE6/IE7

enter image description here

As you can see, when the length of the innerHtml it's not long, no problem; but when it's 'longer' the sprite set as bg image gets repeated and the text jumps to the next line...

now, the CSS

.contButton {
    list-style: none;
    float: right;
}


.contButton p {
    float: left;
    display: inline; /*For ignore double margin in IE6*/
    margin: 0 0 0 10px !important;
}
.contButton a {
    text-decoration: none !important;
    float: left;
    color: #FFF;
    cursor: pointer;
    font-size: 14px !important;
    line-height: 21px;
    font-weight: bold !important;
}
.contButton span {
    margin: 0px 10px 0 -10px;
    padding: 3px 8px 5px 18px;
    position: relative; /*To fix IE6 problem (not displaying)*/
    float:left;
}
/*ESTADO NORMAL AZUL*/
.contButton p a {
    background: url(../nImg/spriteBotones.png) no-repeat right -214px;
    _background: url(../nImg/spriteBotones.gif) no-repeat right -214px;
    color: #FFF;    
}


.contButton p a span {
    background: url(../nImg/spriteBotones.png) no-repeat left -214px;
    _background: url(../nImg/spriteBotones.gif) no-repeat left -214px;
}

And the Html:

<div class="">
....
<div class="contButton mt10">
   <p><a tabindex="" title="acceder" href="#"><span>ver disponibilidad</span></a></p>
</div> 
...
</div>

This is the bg Image. ![the sprite][2]

Tried with:

<!--[if IE lte 7]>



<style type="text/css"> 
/*
.contNombrePrecioHtl .contButton p a{ height:20px;  }
.contNombrePrecioHtl .contButton p a span{ height:20px; width:auto; }  */
</style>
<![endif]-->

But that didn't solve the problem...

PS: class="mt10" it's only a margin-top:10px;

Any idea how to solve this for the glorious IE6/7?

Upvotes: 0

Views: 182

Answers (5)

mkk
mkk

Reputation: 7693

  1. can you try to add overflow: hidden to each parent of element with float: left? in this case you will have to add it to each div, p and a. I am not sure whether your actual code is optimal.
  2. Moreover, float: left; and display: inline together make no sense. This might be the reason of the strange behaviour. Delete display: inline (remember about adding overflow: hidden to its parent) and it should work. Haven't tested though.

UPDATE:

apparently as the author of the question mentions float:left + display: inline fixes IE6 double margin bug for floating elements.

Upvotes: 0

Wallace Sidhr&#233;e
Wallace Sidhr&#233;e

Reputation: 11617

I don't think it is a problem with either IE versions, it's probably just the newer browsers being less strict about this particular thing. I haven't tested anything, but "display:inline-block" has helped me sometimes. Still it doesn't seem like the most effective solution. The width seems to be limiting here, you shouldn't give the thing a fixed width if you don't want the text to "jump" into a second line...

Upvotes: 0

Jayne Mast
Jayne Mast

Reputation: 1487

change this:

.contButton span {
  margin: 0px 10px 0 -10px;
  padding: 3px 8px 5px 18px;
  position: relative; /*To fix IE6 problem (not displaying)*/
  float:left;
  white-space: nowrap;
}

Upvotes: 1

HBublitz
HBublitz

Reputation: 680

defining dimensions for elements like p oder span is always somewhere between tricky and impossible, because they are inline elements. I'd recommend modifying the surrounding block element div.contButton.

In addition to height you should set overflow to hidden:

.contButton { 
    height:20px; 
    width:219px; 
    overflow: hidden;
}

Upvotes: -1

thirtydot
thirtydot

Reputation: 228302

Try adding white-space: nowrap to .contButton.

Upvotes: 1

Related Questions