html - Bootstrap 4 裁剪的修复

标签 html css bootstrap-4

我有一个滑动覆盖动画,它在没有导入 Bootstrap 的情况下工作得很好,但是当我导入 Bootstrap 4(将它用于我正在开发的网页)时,动画的幻灯片从右侧被裁剪,并且不完全见面。

https://codepen.io/AdenMuhammad097/pen/YQPwJo

#body1 {
  margin-top: 50px;
  font-family: 'Open Sans', arial, sans-serif;
  background: white;
}

* {
  margin: 0;
  padding: 0;
}

#categories {
  overflow: hidden;
  width: 90%;
  margin: 0 auto;
}

.clr:after {
  content: "";
  display: block;
  clear: both;
}

#categories li {
  position: relative;
  list-style-type: none;
  width: 27.85714285714286%;
  /* = (100-2.5) / 3.5 */
  padding-bottom: 32.16760145166612%;
  /* =  width /0.866 */
  float: left;
  overflow: hidden;
  visibility: hidden;
  -webkit-transform: rotate(-60deg) skewY(30deg);
  -ms-transform: rotate(-60deg) skewY(30deg);
  transform: rotate(-60deg) skewY(30deg);
}

#categories li:nth-child(3n+2) {
  margin: 0 1%;
}

#categories li:nth-child(6n+4) {
  margin-left: 0.5%;
}

#categories li:nth-child(6n+4),
#categories li:nth-child(6n+5),
#categories li:nth-child(6n+6) {
  margin-top: -6.9285714285%;
  margin-bottom: -6.9285714285%;
  -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  transform: translateX(50%) rotate(-60deg) skewY(30deg);
}

#categories li:nth-child(6n+4):last-child,
#categories li:nth-child(6n+5):last-child,
#categories li:nth-child(6n+6):last-child {
  margin-bottom: 0%;
}

#categories li * {
  position: absolute;
  visibility: visible;
}

#categories li>div {
  width: 100%;
  height: 100%;
  text-align: center;
  color: #fff;
  overflow: hidden;
  -webkit-transform: skewY(-30deg) rotate(60deg);
  -ms-transform: skewY(-30deg) rotate(60deg);
  transform: skewY(-30deg) rotate(60deg);
  -webkit-backface-visibility: hidden;
}


/* HEX CONTENT */

#categories li img {
  left: -100%;
  right: -100%;
  width: auto;
  height: 100%;
  margin: 0 auto;
}

#categories div h1,
#categories div p {
  width: 90%;
  padding: 0 5%;
  background-color: #008080;
  background-color: rgba(0, 128, 128, 0.8);
  font-family: 'Raleway', sans-serif;
  -webkit-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  -ms-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
}

#categories li h1 {
  bottom: 110%;
  font-style: italic;
  font-weight: normal;
  font-size: 1.5em;
  padding-top: 100%;
  padding-bottom: 100%;
}

#categories li h1:after {
  content: '';
  display: block;
  position: absolute;
  bottom: -1px;
  left: 45%;
  width: 10%;
  text-align: center;
  z-index: 1;
  border-bottom: 2px solid #fff;
}

#categories li p {
  padding-top: 50%;
  top: 110%;
  padding-bottom: 50%;
}


/* HOVER EFFECT  */

#categories li div:hover h1 {
  bottom: 50%;
  padding-bottom: 10%;
}

#categories li div:hover p {
  top: 50%;
  padding-top: 10%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">


<div id='body1'>
  <ul id="categories" class="clr">
    <li class="pusher"></li>
    <li>
      <!--This is the Bright Hex-->
      <div>
        <img src="https://c1.staticflickr.com/4/3156/2871027448_789b8d0552_b.jpg" alt="" />
        <h1>Bright C.S. Building</h1>
        <p>Working problem sets, building out a new project, or (most likely) screwing around online...</p>
      </div>
    </li>
  </ul>
</div>

最佳答案

我想你和我的 codepen 一样期待.

网址:https://codepen.io/Ashish9342/full/YvqLzw

我已将宽度更改为 100%,将 h1 边距更改为 0。

默认值: h1-h6 有默认边距。您需要删除它。

//Added margin and width 100% 

#categories div h1, #categories div p{
  width:100%;
  margin: 0;
  padding:0 5%;
  background-color:#008080; background-color: rgba(0, 128, 128, 0.8);
  font-family: 'Raleway', sans-serif;
  
  -webkit-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  -ms-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
}

关于html - Bootstrap 4 裁剪的修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44362426/

相关文章:

javascript - 如果内部元素太小,自动调整容器大小

html - 当视口(viewport)顶部有固定的分隔线时,Chrome滚动太多

html - 如何调整html中的部分?

html - slider 上方的导航栏

Javascript var 向下计数失败

html - 如何使用 CSS 向上移动此文本?

css - 如何计算 SVG 图像像素大小

html - 元素利润率最高的问题

laravel - Laravel 返回错误后如何显示 Bootstrap 通知/toast (MDBootstrap)

javascript - 根据接受 2 个复选框条件启用/禁用按钮