1 2 3 |
<div class="sample1"> Lorem ipsum dolor sit amet. </div> |
1 2 3 4 5 |
.sample1{ background: #ccc; padding: 20px 0; text-align: center; } |
1 2 3 |
<div class="sample2Wrap"> <div class="sample2">Lorem ipsum dolor sit amet.</div> </div> |
1 2 3 4 5 6 7 8 9 10 11 |
.sample2Wrap{ width: 100%; height: 100px; background: #ccc; } .sample2{ width: 100px; height: 100px; background: #888; margin: 0 auto; } |
1 2 3 |
<div class="sample3"> Lorem ipsum dolor sit amet. </div> |
1 2 3 4 5 6 7 |
.sample3{ width: 300px; height: 200px; background: #ccc; display: table-cell; vertical-align: middle; } |
1 2 3 |
<div class="sample4Wrap"> <div class="sample4">Lorem ipsum dolor sit amet.</div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
.sample4Wrap{ width: 300px; height: 300px; background: #ccc; position: relative; } .sample4{ position: absolute; top: 0; bottom: 0; margin: auto; width: 100px; height: 100px; background: #888; } |
1 2 3 |
<div class="sample5"> Lorem ipsum dolor sit amet. </div> |
1 2 3 4 5 6 7 8 |
.sample5{ width: 300px; height: 200px; background: #ccc; display: table-cell; vertical-align: middle; text-align: center; } |
1 2 3 |
<div class="sample6Wrap"> <div class="sample6">Lorem ipsum dolor sit amet.</div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
.sample6Wrap{ width: 300px; height: 300px; background: #ccc; position: relative; } .sample6{ position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; width: 100px; height: 100px; background: #888; } |