reactjs - How to style react bootstrap carousel with next js?
问题描述
I am new to next.js and I would like to remove the gradient around the arrows to the left and right of the react bootstrap carousel. I have tried inline CSS for the carousel and I am using styled-components for the rest of my components.
解决方案
react-bootstrap 包的官方文档说它使用 Bootstrap v3 样式:
React-Bootstrap 目前针对 Bootstrap v3。要使用 React-Bootstrap,请包含适用于 Bootstrap v3 而不是 Bootstrap v4 的 CSS。
如果我们查看 bootstrap.css 文件,我们可以看到轮播控件的左右按钮分别具有 .carousel-control.left 和 .carousel-control.right 类名。所以我们可以使用 styled-components 嵌套特性来指定 CarouselWrapper 组件,该组件将覆盖默认控件背景样式(您绝对应该在此处使用 bootstrap 源中的其他类样式属性,为了清楚起见我省略了它们)。
const CarouselWrapper = styled.div`
.carousel-control.left,
.carousel-control.right {
background: none;
}
`;
这有点“猴子修补”的方法,但我找不到另一种方法来为轮播控件背景传递自定义样式。
在此处查看完整的概念验证代码:https ://codesandbox.io/s/pypkzo5kz0
推荐阅读
- node.js - 提供 json 文件时出现意外的令牌
- iis - ASP Web Api 突然无数据返回
- jquery - 如何使用Javascript匹配不同数组中的字符串
- java - 当构造函数中的局部变量和实例变量相同时,调用 clone() 是一个不错的选择
- javascript - 建立一个像素艺术制造商
- python - 根据多个条件比较数据帧的一行
- c# - Twilio,您如何处理会议中的 maxParticipants?
- jquery - WebApi 2 [POST] 方法接收到错误的值
- javascript - 随机生成的数组中的最大数
- spring-boot - 带有 SSO 的 Spring 安全性