scss几种基本用法

1.变量

 $base-radius:10px;
    .radius {
        border-radius:$base-radius;
    }


  2.嵌套
  

  ul{
        color: #fff;
        li{
            width: 100px;
        }
    }


    3.引入scss的@import则会直接将这些引入的片段合并至当前CSS文件,并且不会产生新的HTTP请求。
  


    @import 'reset';
    body {
      font: 100% Helvetica, sans-serif;
      background-color: #efefef;
    }


    4.混合Mixin传递变量
    

    @mixin border-radius($value:$base-radius) {
        border-radius: $value;
        [data-theme="theme1"] & {
            border-radius: 50px;
        }
    }
    .radius{
        @include border-radius(40px)
    }


        
    5.继承@extend,可以让选择器继承css属性
    

    %flex-center {
      
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在uni-app中同时使用SCSS和scoped样式修改uni-ui件库的样式,有以下几种方法: 方法一:使用::v-deep选择器 在有scoped样式的组件中,可以使用::v-deep选择器来穿透scoped样式,以修改uni-ui组件的样式。例如,修改按钮组件的文字颜色和背景色: ```vue <template> <view> <uni-button>按钮</uni-button> </view> </template> <script> export default { // 组件逻辑部分 } </script> <style scoped lang="scss"> /* 使用::v-deep选择器修改按钮组件样式 */ ::v-deep .uni-button { color: red; background-color: yellow; } </style> ``` 方法二:使用全局样式文件 创建一个全局样式文件,在该文件中引入uni-ui的样式,并对组件进行样式修改。然后在需要使用uni-ui组件的页面或组件中引入全局样式文件。 1. 创建一个全局样式文件,例如`global.scss`。 ```scss // global.scss // 导入uni-ui的样式文件 @import '~@dcloudio/uni-ui/lib/theme.scss'; // 修改按钮组件样式 .uni-button { color: red; background-color: yellow; } // 其他组件样式的修改... ``` 2. 在需要使用uni-ui组件的页面或组件中引入全局样式文件。 ```vue <template> <view> <uni-button>按钮</uni-button> </view> </template> <script> export default { // 组件逻辑部分 } </script> <style lang="scss"> /* 引入全局样式文件 */ @import '@/global.scss'; /* 组件样式 */ </style> ``` 方法三:使用CSS Modules 如果你的uni-app项目使用了CSS Modules,你可以在组件中使用CSS Modules来修改uni-ui组件的样式。 1. 在需要使用uni-ui组件的页面或组件中,开启CSS Modules。 ```vue <template> <view> <uni-button>按钮</uni-button> </view> </template> <script> export default { // 开启CSS Modules styleIsolation: 'scoped', } </script> <style module> /* 修改按钮组件样式 */ .uni-button { color: red; background-color: yellow; } </style> ``` 通过以上方法,你可以在uni-app中同时使用SCSS和scoped样式修改uni-ui组件库的样式。选择适合你项目需求的方法,并根据需要对uni-ui组件的样式进行相应的修改。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值