微信小程序按钮巧妙用法
作者:热爱编程的小白白
这篇文章主要介绍了微信小程序按钮巧妙用法,按钮组件功能比 HTML 中的 button 按钮丰富,通过 open-type 属性可以调用微信提供的各种功能(客服、转发、获取用户授权、获取用户信息等),需要的朋友可以参考下
🍓button 按钮的基本使用
按钮组件
功能比 HTML 中的 button 按钮丰富
通过 open-type 属性可以调用微信提供的各种功能(客服、转发、获取用户授权、获取用户信息等)
通过type属性指定按钮颜色类型

WXML:
<!-- 通过type属性指定按钮颜色类型 --> <button>普通按钮</button> <button type="primary">主色调</button> <button type=warn">警告</button>
注:后期会对按钮添加事件,现在只是给大家演示一下按钮的类型
小尺寸按钮

<button size="mini">普通按钮</button> <button type="primary" size="mini">主色调</button> <button type=warn" size="mini">警告</button>
plain镂空按钮

<button plain>普通按钮</button> <button type="primary" plain>主色调</button> <button type=warn" plain>警告</button>
🍉各种神奇的按钮
去这里找按钮的样式,然后复制:
Buttons - copy CSS & HTML! (uiverse.io)


WXML:(大家到时候需要改一改,因为我直接复制上面 按钮样式 里面的代码)
<button>
<span>Button</span>
<view class="liquid"></view>
</button>
WXSS:
/* From www.lingdaima.com */
button {
  position: relative;
  padding: 19px 36px;
  display: block;
  text-decoration: none;
  text-transform: uppercase;
  overflow: hidden;
  border-radius: 40px;
  border: none;
 }
 
 button span {
  position: relative;
  color: #fff;
  font-family: Arial;
  letter-spacing: 8px;
  z-index: 1;
 }
 
 button .liquid {
  position: absolute;
  top: -80px;
  left: 0;
  width: 100%;
  height: 200px;
  background: #4973ff;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .5);
  transition: .5s;
 }
 
 button .liquid::after,
 button .liquid::before {
  content: '';
  width: 200%;
  height: 200%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -75%);
  background: #fff;
 }
 
 button .liquid::before {
  border-radius: 45%;
  background: rgba(20, 20, 20, 1);
  animation: animate 5s linear infinite;
 }
 
 button .liquid::after {
  border-radius: 40%;
  background: rgba(20, 20, 20, .5);
  animation: animate 10s linear infinite;
 }
 
 button:hover .liquid {
  top: -120px;
 }
 
 @keyframes animate {
  0% {
   transform: translate(-50%, -75%) rotate(0deg);
  }
 
  100% {
   transform: translate(-50%, -75%) rotate(360deg);
  }
 }

WXML:
<button> Button </button>
WXSS:
/* From uiverse.io by @adamgiebl */
button {
  background: #FBCA1F;
  font-family: inherit;
  padding: 0.6em 1.3em;
  font-weight: 900;
  font-size: 18px;
  border: 3px solid black;
  border-radius: 0.4em;
  box-shadow: 0.1em 0.1em;
 }
 
 button:hover {
  transform: translate(-0.05em, -0.05em);
  box-shadow: 0.15em 0.15em;
 }
 
 button:active {
  transform: translate(0.05em, 0.05em);
  box-shadow: 0.05em 0.05em;
 }
下期预告:image 组件的基本使用
到此这篇关于微信小程序按钮巧妙用法的文章就介绍到这了,更多相关微信小程序按钮内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
- 微信小程序实现可拖动悬浮图标(包括按钮角标的实现)
 - 微信小程序将页面按钮悬浮固定在底部的实现代码
 - 微信小程序点击按钮动态切换input的disabled禁用/启用状态功能
 - 微信小程序中的video视频实现 自定义播放按钮、封面图、视频封面上文案
 - 微信小程序实现单个卡片左滑显示按钮并防止上下滑动干扰功能
 - 微信小程序批量监听输入框对按钮样式进行控制的实现代码
 - 微信小程序 多行文本显示...+显示更多按钮和收起更多按钮功能
 - 微信小程序按钮点击动画效果的实现
 - 操作按钮悬浮固定在微信小程序底部的实现代码
 - 详解微信小程序胶囊按钮返回|首页自定义导航栏功能
 - 微信小程序mpvue点击按钮获取button值的方法
 - 微信小程序单选radio及多选checkbox按钮用法示例
 - 微信小程序开发之点击按钮退出小程序的实现方法
 
