果子蓝蓝
侠客
侠客
  • 最后登录2023-01-04
  • 发帖数5
阅读:4882回复:0

[react]antd走马灯设置左右箭头

楼主#
更多 发布于:2022-03-02 11:28
划重点:
在设置了arrows={true}后,左右的icon也要加上去    prevArrow={<leftcircleoutlined />}、    nextArrow={<rightcircleoutlined />},另外还要重写一下样式。
import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Carousel } from "antd";
import { LeftCircleOutlined, RightCircleOutlined } from "@ant-design/icons";

function onChange(a, b, c) {
  console.log(a, b, c);
}

const contentStyle = {
  height: "160px",
  color: "#fff",
  lineHeight: "160px",
  textAlign: "center",
  background: "#364d79"
};

ReactDOM.render(
  <Carousel
    afterChange={onChange}
    arrows={true}
    prevArrow={<LeftCircleOutlined />}
    nextArrow={<RightCircleOutlined />}
  >
    <div>
      <h3 style={contentStyle}>1</h3>
    </div>
    <div>
      <h3 style={contentStyle}>2</h3>
    </div>
    <div>
      <h3 style={contentStyle}>3</h3>
    </div>
    <div>
      <h3 style={contentStyle}>4</h3>
    </div>
  </Carousel>,
  document.getElementById("container")
);





.ant-carousel .slick-prev,
.ant-carousel .slick-next,
.ant-carousel .slick-prev:hover,
.ant-carousel .slick-next:hover,
.ant-carousel .slick-prev:focus,
.ant-carousel .slick-next:focus {
  font-size: inherit;
  color: currentColor !important;
}
游客


返回顶部

公众号

公众号