【发布时间】:2017-08-08 15:01:27
【问题描述】:
HTML、CSS
为了制作类似下面的图片,我写了一个CSS (result)。
<div id="ulWrapWrap">
<div id="ulWrap">
<ul>
<li>
<div class="imgWraps"><img src="http://i.imgur.com/QW18s8F.png" alt=""></div>
</li>
<li>
<div class="imgWraps"><img src="http://i.imgur.com/QW18s8F.png" alt=""></div>
</li>
</ul>
</div>
</div>
html, body { height: 100%; }
body { background-color: DodgerBlue; }
#ulWrapWrap { display: table; height: 100%; margin: 0 auto; }
#ulWrapWrap #ulWrap { display: table-cell; max-height: 100%; vertical-align: middle; }
#ulWrapWrap #ulWrap ul { max-width: 90%; max-height: 90%; margin: 0 auto; padding: 10% 20%; background-color: HotPink; }
#ulWrapWrap #ulWrap ul:after { display: block; clear: both; content: ''; }
#ulWrapWrap #ulWrap ul li { float: left; display: table; max-width: 45%; height: 100%; margin-right: 10%; }
#ulWrapWrap #ulWrap ul li:last-child { margin-right: 0; }
#ulWrapWrap #ulWrap ul li .imgWraps { display: table-cell; vertical-align: middle; }
#ulWrapWrap #ulWrap ul li .imgWraps img { max-width: 100%; max-height: 100%; }
最佳结果
(1) 当我水平调整窗口大小时。
(2) 当我垂直调整窗口大小时。
当前结果
它适用于 (1),但不适用于 (2)。我怎样才能让它工作? ;)
(1) 当我水平调整窗口大小时。
(2) 当我垂直调整窗口大小时。
【问题讨论】:
标签: html css image center window-resize