button按钮美化

1,截图
在这里插入图片描述
2,源码
链接:https://pan.baidu.com/s/191Q2QDXbBqP4RK28nOUWag?pwd=qox1
提取码:qox1
–来自百度网盘超级会员V4的分享
3,代码
buttonWl.vue

<template>
<div :style="{'--height':height,'--width':width}">
  <button class="my-button"><span class="iconfont icon-sousuo"></span></button>
</div>
</template>

<script>
import "@/icon/iconfont.css"
export default {
  name: "buttonWl",
  data(){
    return{
    // //  按钮的height
    //   height:'',
    // //  按钮的width
    //   width:''
    }
  },
  props:['height','width']

}
</script>

<style scoped>
:root{
/*  按钮的height*/
  --height:'';
  /*按钮的width*/
  --width:'';
}
.my-button {
  background-color: rgb(236, 245, 255);
  border: none;
  color: rgb(92, 158, 255);
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 5px;
  box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
  height: var(--height);
  width: var(--width);
}

.my-button:hover{
  background-color: rgb(92, 158, 255);
  color: rgb(236, 245, 255);
  transform: scale(0.95);
}

</style>


homeWl.vue

<template>
<div>
<button-wl></button-wl>
</div>
</template>

<script>
import ButtonWl from "@/components/buttonWl/buttonWl";
export default {
  name: "homeWl",
  components: {ButtonWl},
  data(){
    return{
      //  按钮的height
      height:'',
      //  按钮的width
      width:''
    }
  },
  mounted() {
    this.gethomeheight()
    this.gethomewidth()
    window.addEventListener('resize', this.gethomewidth); // 在窗口大小改变时重新获取窗口宽度
    window.addEventListener('resize', this.gethomeheight);
  },

  methods:{
    gethomewidth(){
      // 获取窗口宽度
      var windowwidth = window.innerWidth
      // 按钮的width
      this.width = parseInt(windowwidth/9/4)+'px'
    },
    // 获得窗口height度
    gethomeheight(){

      var windowheight = window.innerHeight
      this.height = parseInt(windowheight/9/3)+'px'

    }
  },
}
</script>

<style scoped>

</style>

4,参数解释
// 按钮的height
height:‘’,
// 按钮的width
width:‘’
5,视频演示
【button按钮美化】 https://www.bilibili.com/video/BV1qP411Q7eW/?share_source=copy_web&vd_source=58607fc67d165b8caff1ed8bfcefd35b

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是梦磊OL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值