0

I have a div which is centered in parent div, it working on all browser but not in ie, can you help me out with this.

JSFIDDLE

enter image description here

span.qbg3 {
    display: block;
    text-align: center;
    background: url(http://powerblanket.com/may2014/wp-content/uploads/2014/05/qbg3.png) no-repeat center center;
    background-size:cover;
    padding: 50px 20px;
    color: #fff;
    font-weight: 400;
    font-size: 30px;
    position: relative;
    margin-top: -20px;
    min-height: 350px;
}
span.inqbg3 {
    max-height: 100px;
    display: block;
    text-align: center;
    color: #fff;
    font-weight: 400;
    font-size: 40px;
    position: absolute;
    margin: auto;
    top: 0px;
    right: 0;
    left: 0;
    bottom: 0px;
    background: rgba(0, 0, 0, 0.5);
    max-width: 700px;
    padding: 35px 0;
}
span.inqbg3 a {
    color: #fff;
}
Vikas Ghodke
  • 6,602
  • 5
  • 27
  • 38
  • 1
    Hey i think this should help you http://stackoverflow.com/questions/662341/using-margin-0-auto-in-internet-explorer-8 i think looking at your code you dont want to hardcode top and left values ??? am i right ? – codefreaK Jun 07 '14 at 09:14
  • @VikasGhodke: That's information you should edit into the question. – T.J. Crowder Jun 07 '14 at 09:18

3 Answers3

1

You need to change your css

Need to remove right: 0 and bottom: 0

and change left: 0 and top: 0 to left: 50% and top: 50% and half minus height and width margin to bring it in center.

CSS

span.inqbg3 {
    max-height: 100px;
    display: block;
    text-align: center;
    color: #fff;
    font-weight: 400;
    font-size: 40px;
position: absolute;
margin:  -85px 0 0 -267px;
top: 50%;
/* right: 0; */
left: 50%;
/* bottom: 0px; */
    background: rgba(0,0,0,0.5);
    max-width: 700px;
    padding: 35px;
}

Here is the demo

Tushar
  • 4,280
  • 5
  • 24
  • 39
1

Demo

You need to set width of the span.inqbg3 as

width: 100% /* Set your own height: percents, ems, whatever! */

CSS

span.inqbg3 {
    height: 100%; /* Set your own height: percents, ems, whatever! */
    max-height: 100px;
    display: block;
    text-align: center;
    color: #fff;
    font-weight: 400;
    font-size: 40px;
    position: absolute;
    margin: auto;
    top: 0px;
    right: 0;
    left: 0;
    bottom: 0px;
    background: rgba(0, 0, 0, 0.5);
    width: 100%; /* Set your own width: percents, ems, whatever! */
    max-width: 700px;
    padding: 35px 0;
}

enter image description here

4dgaurav
  • 11,360
  • 4
  • 32
  • 59
0

Remove position: absolute; from span.inqbg3 .

Prashant Tapase
  • 2,132
  • 2
  • 25
  • 34