如何在React和Bootstrap 5中删除空白空间

huangapple go评论72阅读模式
英文:

How to remove empty space in React and Bootstrap 5

问题

I'm writing a pet project that needs to be mobile responsive and I have a problem with white space in the Carousel component, I don't know how to remove it, can someone help me?

This is looks like page on PC
https://i.stack.imgur.com/ql0FO.jpg

This is looks like mobile devices https://i.stack.imgur.com/FXR25.jpg

And I want to remove the empty space at the bottom, make the carousel responsive, how can I do that?

Here is my component code

import ... 

export default class CarouselBox extends Component{ 
    render(){ 
        return( 

            <Carousel> 
                <Carousel.Item> 
                    <img className="d-block w-100" 
                    src={edinburghView1} 
                    alt="Edinburgh_Uni" 
                    /> 
                <Carousel.Caption> 
                    <Nav.Link href='/EdinburghCity'> 
                    <h3>Edinburgh city</h3> 
                    <p>Edinburgh city view in 2023</p> 
                    </Nav.Link> 
                </Carousel.Caption> 
                </Carousel.Item> 
        ) 
    } 
}

Here is my Footer component

import { MDBFooter } from 'mdb-react-ui-kit'; 

export default class Footer extends Component { 
    render() { 
        return ( 
            <> 
    <MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom"> 
      <div className='text-center p-3' style={{ 
         backgroundColor: '#f8f9fa', 
         marginTop: '0.5%' }}> 
        © {new Date().getFullYear()} Copyright:{' '} 
        <a className='text-dark' href='https://t.me/koreechdhs'> 
          Boiar Kostiatyn 
        </a> 
      </div> 
    </MDBFooter> 
            </> 
        ) 
    } 
}
英文:

I'm writing a pet project that needs to be mobile responsive and I have a problem with white space in the Carousel component, I don't know how to remove it, can someone help me?

This is looks like page on PC
https://i.stack.imgur.com/ql0FO.jpg

This is looks like mobile devices https://i.stack.imgur.com/FXR25.jpg

And I want to remove the empty space at the bottom, make the carousel responsive, how can I do that?

Here is my component code

import ...

export default class CarouselBox extends Component{
    render(){
        return(
            
                <Carousel>
                    <Carousel.Item>
                        <img className="d-block w-100"
                        src={edinburghView1}
                        alt="Edinburgh_Uni"
                        />
                    <Carousel.Caption>
                        <Nav.Link href='/EdinburghCity'>
                        <h3>Edinburgh city</h3>
                        <p>Edinburgh city view in 2023</p>
                        </Nav.Link>
                    </Carousel.Caption>        
                    </Carousel.Item>
                                
            
        )
    }
}

Here is my Footer component

import { MDBFooter } from 'mdb-react-ui-kit';

export default class Footer extends Component {
    render() {
        return (
            <>
    <MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom">
      <div className='text-center p-3' style={{
         backgroundColor: '#f8f9fa', 
         marginTop: '0.5%' }}>
        © {new Date().getFullYear()} Copyright:{' '}
        <a className='text-dark' href='https://t.me/koreechdhs'>
          Boiar Kostiatyn
        </a>
      </div>
    </MDBFooter>
            </>
        )
    }
}

答案1

得分: 1

我有点困惑您所说的是什么意思:

> 我想要移除底部的空白空间,使轮播图具有响应性,应该如何操作?

我猜您指的是这里的红色区域?

如何在React和Bootstrap 5中删除空白空间

这是因为您在以下代码中使用了:

sticky="bot"

在:

<MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom">

这正是您想要的效果。

如果您想让轮播图占满整个高度,您需要在该视口大小的组件中添加相应的设置,参考sizing

英文:

I'm somewhat confused what you mean by:

> I want to remove the empty space at the bottom, make the carousel responsive, how can I do that?

I'm assuming the red area here you're talking about?

如何在React和Bootstrap 5中删除空白空间

That is because, you have

sticky="bot"

in:

<MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom">

which is doing exactly what you want.

If you want the carousel to be full height you will need to add that in the component at that viewport size, reference sizing

huangapple
  • 本文由 发表于 2023年2月13日 23:30:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75437956.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定