How to center figure with max-width defined?

3

I'm trying to center a figure with max-width defined. When centralizing without max-width , that's right. But the background exists in it is 100% non-centered next to figure . For this I used max-width , but when using figure it aligns the left again. Is there any other way?

<figure id="img-home">
                <img src="img/col-1.jpg" alt="Cotação Individual, Familiar, Empresarial">
                <figcaption>
                    <strong>Cotação</strong>
                    <span><a href="#">Individual</a> | <a href="#">Familiar</a> | <a href="#">Empresarial</a></span>
                </figcaption>
            </figure>

#img-home {background: #eed46f; padding: 5px; max-width: 330px; text-align: center;}
    
asked by anonymous 20.06.2014 / 14:24

1 answer

2

You need to add margin 0 auto; to your tag figure

#img-home {
    margin:0 auto;
    background: #eed46f; 
    padding: 5px; 
    max-width: 330px; 
    text-align: center;
}

Example: JSFiddle

    
20.06.2014 / 14:31