html - Center figure in section -


i cant these figures centered. they're inside section, i've tried many variations. should be, float in right way. no matter try sections or figure codes, still not center within sections.

section {    width: 100%;    padding: 1rem;    display: table;    margin: 0 auto;    max-width: none;    background-color: #373b44;    height: 100vh;  }    section:nth-of-type(2n) {    background-color: white;  }    figure.snip1165 {    float: left;    margin: 1rem;    overflow: hidden;    min-width: 150px;    max-width: 300px;    background: #000000;    color: #333;    text-align: left;    box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);  }
<section>      <figure class="snip1165">      <img src="http://test.nationalparkpaws.com/images/camping%20in%20mountains%20with%20ten.jpg" />      <figcaption>        <h3>useful tips</h3>        <p>          think surest sign intelligent life exists elsewhere in universe none of has tried contact us.        </p>        </figcaption>    </figure>      <figure class="snip1165 red">      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample63.jpg" alt="sample63" />      <figcaption>        <h3>caspian<span> bellevedere</span></h3>        <p>          don't need compromise on principles, because don't have slightest bearing on happens me anyway.        </p>        </figcaption>    </figure>    <figure class="snip1165 orange">      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample64.jpg" alt="sample64" />      <figcaption>        <h3>parsley<span> montana</span></h3>        <p>          that's problem nature, something's stinging or oozing mucous on you. hobbes, think time , me when , watched tv.        </p>        </figcaption>    </figure>    </section>

use text-align: center; on section , remove float: left; on figure , use display: inline-block; , vertical-align: top; instead.

should trick, see below snippet :

section {    width: 100%;    padding: 1rem;    display: table;    margin: 0 auto;    max-width: none;    background-color: #373b44;    height: 100vh;    text-align: center;  }    section:nth-of-type(2n) {    background-color: white;  }    figure.snip1165 {    display: inline-block;    vertical-align: top;    margin: 1rem;    overflow: hidden;    min-width: 150px;    max-width: 300px;    background: #000000;    color: #333;    text-align: left;    box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);  }
<section>      <figure class="snip1165">      <img src="http://test.nationalparkpaws.com/images/camping%20in%20mountains%20with%20ten.jpg"/>      <figcaption>        <h3>useful tips</h3>        <p>          think surest sign intelligent life exists elsewhere in universe none of has tried contact us.        </p>      </figcaption>    </figure>      <figure class="snip1165 red">      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample63.jpg" alt="sample63"/>      <figcaption>        <h3>caspian<span> bellevedere</span></h3>        <p>          don't need compromise on principles, because don't have slightest bearing on happens me anyway.        </p>          </figcaption>    </figure>        <figure class="snip1165 orange">      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample64.jpg" alt="sample64"/>      <figcaption>        <h3>parsley<span> montana</span></h3>        <p>          that's problem nature, something's stinging or oozing mucous on you. hobbes, think time , me when , watched tv.        </p>      </figcaption>    </figure>    </section>


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -