【问题标题】:why css bottom is not working in carousel?为什么css底部不能在轮播中工作?
【发布时间】:2022-11-02 16:44:34
【问题描述】:

我正在使用这个插件来创建轮播 https://www.npmjs.com/package/react-responsive-carousel

但我的药片显示在图像上。见电流输出(背景红色)。药丸在图像上

这是我的代码 https://codesandbox.io/s/react-responsive-carousel-forked-8c3x7s?file=/src/index.js

预期产出

我试过这样

.control-dots {
  background-color: red;
  position: absolute;
  bottom: 0;
}

还是行不通。预计将药丸移动到图像的底部而不是图像上方。

【问题讨论】:

  • 相对定位的.carousel.carousel-slider 是此处绝对定位的参考点——这与幻灯片的要求一样高。所以添加一点填充底部。
  • 你能改一下codesandbox吗

标签: javascript html css reactjs react-responsive-carousel


【解决方案1】:

您需要将padding-bottom 添加到容器元素中:

.carousel.carousel-slider {
  padding-bottom: 30px;
}

.control-dots {
  background-color: red;
}

https://codesandbox.io/s/react-responsive-carousel-forked-ztfpeu?file=/src/index.css

【讨论】:

    猜你喜欢
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2010-10-29
    • 2014-09-28
    相关资源
    最近更新 更多