容器未扩展以覆盖浮动元素

时间:2016-06-29 19:23:20

标签: css css-float clearfix

我有一些浮动元素,容器高度设置为视口大小(min-height:100vh),overflow:hidden。

但是,在响应式视图(480x320)中,我发现div不会扩展以包含保存浮动项目的div。因此,浮动元素完全切断了div:

enter image description here

我尝试添加clearfix但这不起作用。

HTML:

<div class="wrapper">

        <div class="clients" id="clients">

        <h2 class>Clients</h2>

            <div class="clientLogoContainer">
                <div class="clientLogo">
                    <img src="assets/ethiopian.jpg" class="fullSizeLogo">
                </div>
                <div class="clientLogo">
                    <img src="assets/kenya.jpg" class="fullSizeLogo">
                </div>
                <div class="clientLogo">
                    <img src="assets/southafrican.jpg" class="fullSizeLogo">
                </div>
                <div class="clientLogo">
                    <img src="assets/qatar.jpg" class="fullSizeLogo">
                </div>
                <div class="clientLogo">
                    <img src="assets/coalindia.jpg" class="fullSizeLogo">
                </div>
     </div>

CSS:

.clientLogoContainer {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  position: absolute;
  top: 50%;                 /* move the div's top border to the half height of the outer div*/
  transform: translateY(-50%); /* move the inner div up by half its height */
  -webkit-transform: translateY(-50%);
  -o-transform: translateY(-50%);
}

.clearfix { /* used for the navigation bar to prevent li items from crashing into same line as the logo */
  content: " ";
  display: block;
  clear: both;
}

无响应视图 enter image description here

0 个答案:

没有答案