React Slick无效

时间:2017-09-16 11:51:06

标签: css reactjs

我刚接触光滑,反应和反应灵敏,我使用react-slick创建了一个新组件。当我实现响应式轮播和CSS(甚至在此之前)时,元素会垂直堆叠,如this image中所示。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

最好添加代码...... 无论如何这里是React Slick的一个例子:

HTML:

<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>

<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

JS:

var ReactSlickDemo = React.createClass({
  render: function() {
    var settings = {
        dots: true
    }
    return (
        <div className='container'>
        <Slider {...settings}>
            <div><img src='http://placekitten.com/g/400/200' /></div>
          <div><img src='http://placekitten.com/g/400/200' /></div>
          <div><img src='http://placekitten.com/g/400/200' /></div>
          <div><img src='http://placekitten.com/g/400/200' /></div>
        </Slider>
      </div>
    );
  }
});

ReactDOM.render(
  <ReactSlickDemo />,
  document.getElementById('container')
);

的CSS:

.container {
  margin: 0 auto;
  padding: 40px;
  width: 80%;
  color: #333;
  background: #419be0;
}

来自here

答案 1 :(得分:1)

尝试连接CSS文件

@import "~slick-carousel/slick/slick.css";
@import "~slick-carousel/slick/slick-theme.css";

<link rel="stylesheet" type="text/css" charset="UTF-8" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />

然后您可以覆盖usig类