简体   繁体   English

如何在antd(ant design)中为Carousel制作大箭头?

[英]How to make large arrows for Carousel in antd (ant design)?

I'm developing a reactjs project with ant-design (antd).我正在使用 ant-design (antd) 开发 reactjs 项目。 I'm using Carousel component with auto scrolling through some photos.我正在使用带有自动滚动浏览一些照片的 Carousel 组件。 I also want to add some arrows to change photos manually.我还想添加一些箭头来手动更改照片。

I found a way to make small buttons to the left and to the right of my Carousel.我找到了一种在我的 Carousel 左侧和右侧制作小按钮的方法。 But I don't get how to make them bigger (with the same height as the photos for example), move on the photos or make visible any time (now they stay hidden until the mouse cursor is exactly on them).但是我不知道如何使它们变大(例如与照片具有相同的高度),移动照片或随时显示(现在它们一直隐藏,直到鼠标 cursor 正好在它们上面)。

Here's some code:这是一些代码:

const RightArrow = () => {
    return (
        <Button icon={<RightCircleOutlined/>} size="middle"/>
    )
}

const LeftArrow = () => {
    return (
        <Button icon={<LeftCircleOutlined/>} size="middle"/>
    )
}

const SSOverview = () => {

    return (
        <Content style={{width: "100%", padding: '0 30px', fontSize: 16}}>
            <Col><Title level={1}> My Title </Title></Col>
            <Carousel autoplay autoplaySpeed={7000}
                      draggable={true} arrows={true}
                      prevArrow={LeftArrow()}
                      nextArrow={RightArrow()}>
                <div><img src={Slide2} style={{width: '100%'}} alt="Photo 1"/></div>
                <div><img src={Slide1} style={{width: '100%'}} alt="Photo 2"/></div>
                <div><img src={Slide3} style={{width: '100%'}} alt="Photo 3"/></div>
                <div><img src={Slide4} style={{width: '100%'}} alt="Photo 4"/></div>
                <div><img src={Slide5} style={{width: '100%'}} alt="Photo 5"/></div>
            </Carousel>
        //the rest of the page
        </Content>
     )
 };

You can override antd default styling with custom CSS styling.您可以使用自定义 CSS 样式覆盖 antd 默认样式。 To make the buttons bigger, just add style property (or add className property and style inside CSS file).要使按钮更大,只需添加style属性(或在 CSS 文件中添加className属性和样式)。 For example, you could do something like this:例如,您可以执行以下操作:

<Button
    style={{padding: "1rem", height: "auto", width: "auto"}}
    icon={<RightCircleOutlined style={{fontSize: 60}} />}
/>

Here's a pen: https://codepen.io/jaycodist/pen/mdPyqNW这是一支笔: https://codepen.io/jaycodist/pen/mdPyqNW

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM