光滑的滑块在 flex 容器中不起作用

émi*_*le. 7 html javascript css flexbox slick.js

我试图在一个列中垂直居中一个光滑的旋转木马(http://kenwheeler.github.io/slick/)。所以我display: flex; align-items: center;在列(光滑滑块的容器)上使用,但它破坏了滑块。

所以我尝试使用绝对位置或使用 flexbox 将旋转木马居中,但它们都破坏了光滑的滑块。

我希望有人有针对这个问题的 css/js/jquery 解决方案:)

这里有一个问题:https : //jsfiddle.net/victor_allegret/g3dsd78w/

(抱歉,我在向堆栈溢出代码段添加光滑代码时遇到问题)

HTML :

<div class='flex-container'>

 <div class='single-item'>

  <div><h3>1</h3></div>
  <div><h3>2</h3></div>
  <div><h3>3</h3></div>
  <div><h3>4</h3></div>
  <div><h3>5</h3></div>
  <div><h3>6</h3></div>

 </div>

</div>
Run Code Online (Sandbox Code Playgroud)

CSS :

.flex-container {
 /* Using flexbox */
 display: flex;
 align-items: center;
 /*----*/
 margin: 0 auto;
 padding: 40px;
 height: 500px;
 width: 80%;
 color: #333;
 background: #419be0;
}

.slick-slide {
 text-align: center;
 color: #419be0;
 background: white;
}
Run Code Online (Sandbox Code Playgroud)

JS:

$(".single-item").slick({
 dots: true
});
Run Code Online (Sandbox Code Playgroud)

Bar*_*aro 5

像这样 ?具有绝对位置。

.abs-container {
  position:absolute;

  height:140px;
  width:300px;
  top:50%;
  left:50%;
  margin:-70px 0 0 -150px;

  color: #333;
  background: #419be0;
}
Run Code Online (Sandbox Code Playgroud)

这与 FlexBox。

.flex-container {
    position:absolute;
    top:0px;
    bottom:0px;
    width:100%;
    height:100%;

  /* Using flexbox */
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-content: stretch;
    align-items: center;
  /*----*/

  color: #333;
  background: #419be0;
}
.flex-child {
    width: 300px;
    order: 0;
    flex: 0 1 auto;
    align-self: center;
}
Run Code Online (Sandbox Code Playgroud)

HTML

<div class='flex-container'>
    <div class='flex-child'>
      <div class='single-item'>
      .
      .
      .
Run Code Online (Sandbox Code Playgroud)