返回

rgb滑块

发布时间:2022-11-15 17:33:38 349
# javascript# css# java# java
 
<template>
  <div>
    <div class="bac" :style="`background:rgb${rgb}`">
      RGB颜色: rgb({{red}},{{green}},{{blue}})
    </div>
    <div class="box">
      <div class="block">
        <span class="demonstration">RED</span>
        <el-slider 
          v-model="red"
          :max=255
          @input="redChange">
        </el-slider>
      </div>
      <div class="block">
        <span class="demonstration">GREEN</span>
        <el-slider 
          v-model="green"
          :max=255
          @input="greenChange">
        </el-slider>
      </div>
      <div class="block">
        <span class="demonstration">BLUE</span>
        <el-slider 
          v-model="blue"
          :max=255
          @input="blueChange">
        </el-slider>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  data(){
    return {
      red: 49,
      green: 120,
      blue: 200,
      rgb: `(0,0,0)`
    }
  },
  methods:{
    redChange(newValue){
      this.rgb = `(${newValue},${this.green},${this.blue})`
    },
    greenChange(newValue){
      this.rgb = `(${this.red},${newValue},${this.blue})`
    },
    blueChange(newValue){
      this.rgb = `(${this.red},${this.green},${newValue})`
    }
  },
  mounted(){
  }
};
</script>
 
<style lang="scss" scoped>
.bac {
  height: 200px;
  background: rgb(0, 0, 0);
  margin-bottom: 50px;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 20px;
}
.box {
  width: 700px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.block {
  width: 150px;
  .demonstration {
    font-weight: 700;
  }
}
</style>
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线