【无标题】

1 篇文章 0 订阅
1 篇文章 0 订阅

关于react里css样式权重出现的问题(求助,>为什么没有定位到右边)

最近我在用react写一个轮播图,可是在写css样式的过程中却发现样式权重并不如我作料

Swipper.jsx里:

import './index.css'
export default class Swipper extends Component {
    state={
        index:1
    }
    render(){
        let {index} = this.state;
        return(
            <div className='wrapper'>
                <img width={500} src={require(`../assets/images/${index}.webp`)} />
                <span onClick={()=>{
                    index--;
                    if(index<1){
                        index=4
                    }
                    this.setState({index});
                }}>&lt;</span>
                <span onClick={()=>{
                    index++;
                    if(index>4){
                        index=1
                    }
                    this.setState({index});
                }} className='right'>&gt;</span>
            </div>
        )
    }
}

index.css里.wrapper{

   width:500px;
   margin:100px auto;
   border:1px solid red;
}
.wrapper img {
   width:500px;
}

.wrapper span {
   position: absolute;
   top:63px;
   display: block;
   width:44px;
   height:60px;
   line-height: 60px;
   background-color: azure;
   text-align: center;
   cursor: pointer;
   user-select: none;
   left: 0px;
}
.wrapper .right {
   right:10px;
}

根组件App.jsx里

import Swipper from './Swipper/Swipper'
import './App.css'
export default class App extends Component {
    render() {
        return (
            <>
                <Swipper/>
            </>
        )
    }
}

代码目录结构:

在这里插入图片描述

浏览器界面:

在这里插入图片描述
面对面聊也行,Q:2395914242

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值