css--按钮

基本按钮

rgba:rgba(255,255,255,0.5);//实现透明度,0.5为透明度

<style>
    .button {
        background-color:red;//按钮颜色
        border:none;
        color:white;//字体颜色
        padding:10px 15px;
        text-align:center;//字体居中
        text-decoration:none;//链接去除下划线
        cursor:pointer;//鼠标光标
        font-size:10px;按钮大小 
        border-radius:4px;//按钮圆角
        border:1px solid red;//边框颜色
        transition-duration:0.4s;//过渡效果持续0.4s
        box-shadow:0 8px 10px 0 rgba(0,0,0,0.2),0 6px 10px 0 rgba(0,0,0,0.2);//按钮阴影
        //设置禁用按钮
        opacity:0.6;//透明度
        cursor:not-allowed;//鼠标光标设置为禁用
    }
    .button :hover {
        background-color:red;//鼠标悬停后按钮背景色改变
        color:white;//鼠标悬停后按钮内字体颜色改变
        box-shadow:0 8px 10px 0 rgba(0,0,0,0.2),0 6px 10px 0 rgba(0,0,0,0.2);//鼠标悬停后添加按钮阴影
    }
</style>


<button>默认按钮</button>
<a href="#" class="button">链接按钮</a>
<button class="button">按钮</button>
<input type="button" class="button" value="输入框按钮">

按钮动画

鼠标移动到按钮添加标记

<style>
.button {
  display: inline-block;
  border-radius: 4px;
  background-color: #f4511e;
  border: none;
  color: #FFFFFF;
  text-align: center;
  font-size: 28px;
  padding: 20px;
  width: 200px;
  transition: all 0.5s;
  cursor: pointer;
  margin: 5px;
}

.button span {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: 0.5s;
}

<!-- 在span后插入样式 -->
.button span:after {
  content: '»';
  position: absolute;
  opacity: 0;
  top: 0;
  right: -20px;
  transition: 0.5s;
}

<!-- 鼠标悬停后改变样式 -->
.button:hover span {
  padding-right: 25px;
}

<!-- 鼠标悬停后,在span后插入样式 -->
.button:hover span:after {
  opacity: 1;
  right: 0;
}
</style>

<button class="button" style="vertical-align:middle"><span>Hover </span></button>

波纹效果

在CSS定义中,:active必须位于:hover之后!!

<style>
.button {
    position: relative;
    background-color: #4CAF50;
    border: none;
    font-size: 28px;
    color: #FFFFFF;
    padding: 20px;
    width: 200px;
    text-align: center;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    text-decoration: none;
    overflow: hidden;
    cursor: pointer;
}

.button:after {
    content: "";
    background: #90EE90;
    display: block;
    position: absolute;
    padding-top: 300%;
    padding-left: 350%;
    margin-left: -20px!important;
    margin-top: -120%;
    opacity: 0;
    transition: all 0.8s
}

<!-- 按下按钮后改变样式 -->
.button:active:after {
    padding: 0;
    margin: 0;
    opacity: 1;
    transition: 0s
}
</style>

<button class="button">Click Me</button>

压下效果

<style>
.button {
  display: inline-block;
  padding: 15px 25px;
  font-size: 24px;
  cursor: pointer;
  text-align: center;   
  text-decoration: none;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

.button:hover {background-color: #3e8e41}<!-- 鼠标悬停改变颜色 -->

<!-- 按下按钮后改变样式 -->
<!-- 只用Y轴值,Y轴4px -->
.button:active {
  background-color: #3e8e41;
  box-shadow: 0 5px #666;
  transform: translateY(4px);
}
</style>


<button class="button">Click Me</button>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值