web前端:按钮转化变色,阴影box-shadow使用,动画属性transform:translate(-x,-y)居中样式

1.less

* {
    margin: 0;
    padding: 0;
    body {
        a {
            //a标签不可以设置宽高,需要display:inline-block
            display: inline-block;
            //未知宽高下居中使用trnasform:translate(x,y)
            width: 100px;
            height: 30px;
            //原本装饰样式decoration为none
            text-decoration: none;
            position: absolute;
            background: skyblue;
            text-align: center;
            font: 20px/30px "微软雅黑";
            font-weight: bold;
            color: white;
            border: 1px solid darkcyan;
            //阴影:box-shadow:x-px , y-px ,模糊程度?px #color 
            box-shadow: 2px 2px 5px #4682B4;
            /**
                                        新居中方法
             1. top、height:百分比参照包含块的高度
             2. lefe、margin、padding、width:百分比参照包含块的宽度
             3. translate(-50%,-50%):百分比参照自身元素的宽高
             4. background、position:百分比参照,图片区域--》图片位图的像素值
             */
            top: 50%;
            left: 50%;
            //定位点在元素自身的宽高--》兼容性不高
            transform: translate(-50%, -50%);
            margin: auto;
            transition: 1.5s;
        }
        &:hover a {
            color: white;
            background: steelblue;
        }
    }
}

2.css

* {
  margin: 0;
  padding: 0;
}
* body a {
  display: inline-block;
  width: 100px;
  height: 30px;
  text-decoration: none;
  position: absolute;
  background: skyblue;
  text-align: center;
  font: 20px/30px "微软雅黑";
  font-weight: bold;
  color: white;
  border: 1px solid darkcyan;
  box-shadow: 2px 2px 5px #4682B4;
  /**
                                        新居中方法
             1. top、height:百分比参照包含块的高度
             2. lefe、margin、padding、width:百分比参照包含块的宽度
             3. translate(-50%,-50%):百分比参照自身元素的宽高
             4. background、position:百分比参照,图片区域--》图片位图的像素值
             */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: auto;
  transition: 1.5s;
}
* body:hover a {
  color: white;
  background: steelblue;
}

3.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>light button高亮按钮</title>
	</head>
	<body>
		<a href="javascript:;">Home</a>
	</body>
	<link rel="stylesheet" href="css/less024.css" />
</html>

4.效果图

cevent

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值