M
M
Michael2015-11-12 23:32:01
css
Michael, 2015-11-12 23:32:01

How to horizontally center a rubber block that has max-width?

Is it possible to do this without js and cross browser?
Current Block Styles

.popup {
    background: #fff;
    position: fixed;
    width: 70%;
    z-index: 99999999;
    left: 15%;
    top: 10%;
    max-width: 900px;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Valery Serov, 2015-11-13
@scherbuk

.popup {
    position: fixed;
    width: 70%;
    left: 0;
    right: 0;
    top: 10%;
    max-width: 900px;
    background: #000;
    margin: 0 auto;
}

This is how it works and seems to be cross-browser

D
Denis Ineshin, 2015-11-12
@IonDen

Like this: jsfiddle.net/IonDen/jrqaw5se

.popup {
    position: fixed;
    width: 70%;
    left: 50%;
    top: 10%;
    max-width: 900px;
    transform: translate(-50%, 0);
    background: #000;
}

S
Sanan Yuzb, 2015-11-13
@Sanan07

addmargin: 0 auto;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question