Element plus .el-textarea__inner 样式重构

Vue样式重构与深度选择器用法

以下有效,使用 >>> 深度选择器

<template>  
  <el-input  
    type="textarea"  
    v-model="inputValue"  
    class="custom-textarea"      
    >  
  </el-input>  
</template>  
<script setup>

import { ref } from 'vue'

const inputValue = ref('')
</script>
  
<style scoped>
 .custom-textarea >>>.el-textarea__inner {
  background-color: #ffffdd;
  height: 300px;
  width: 400px;
  white-space: nowrap;
  } 
</style>
 

去掉scoped 也可以实现样式重构

<template>  
  <el-input  
    type="textarea"  
    v-model="inputValue"  
    class="custom-textarea"      
    >  
  </el-input>  
</template>  
<script setup>

import { ref } from 'vue'

const inputValue = ref('')
</script>
  
<style>
 .custom-textarea .el-textarea__inner {
  background-color: #ffffdd;
  height: 300px;
  width: 400px;
  white-space: nowrap;
  } 
</style>
 

分析scoped的使用用法

style上添加scoped属性,就相当于给当前子组件的结构中都添加上一个data-v-×××自定义属性。

使用深度穿透也可以处理这个问题

深度选择器可以实现样式穿透
原生CSS: >>>
less: /deep/
scss: ::v-deep

<style lang="scss" scoped> .el-date-editor.el-input { width: auto; } .add-update-preview .el-form-item /deep/ .el-form-item__label { padding: 0 10px 0 0; color: #999; font-weight: 600; width: 180px; font-size: 16px; line-height: 40px; text-align: right; } .add-update-preview .el-form-item /deep/ .el-form-item__content { margin-left: 180px; } .add-update-preview .el-input /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; height: 40px; } .add-update-preview .el-select /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; min-width: 50%; height: 40px; } .add-update-preview .el-date-editor /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 10px 0 30px; color: #000; background: #fff; width: 100%; font-size: 16px; height: 40px; } .add-update-preview /deep/ .el-upload--picture-card { background: transparent; border: 0; border-radius: 0; width: auto; height: auto; line-height: initial; vertical-align: middle; } .add-update-preview /deep/ .el-upload-list .el-upload-list__item { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } .add-update-preview /deep/ .el-upload .el-icon-plus { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } .add-update-preview .el-textarea /deep/ .el-textarea__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 12px; color: #666; background: #fff; width: 100%; font-size: 14px; min-width: 400px; height: 120px; } .add-update-preview .btn3 { border: 0px solid #ccc; cursor: pointer; border-radius: 4px; padding: 0 10px; margin: 0 10px 0 0; color: #fff; background: #50adfd; width: auto; font-size: 16px; min-width: 110px; height: 40px; } .add-update-preview .btn3:hover { opacity: 0.8; } </style>
09-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值