CSS实战 - 奇Y技巧之box-shadow属性

本文详细介绍了CSS box-shadow属性的四个值使用方法,通过实例演示了如何为按钮添加阴影效果,并展示了其在交互中的动态变化。重点讲解了激活状态下的阴影调整和过渡效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考1: 博客
box-shadow属性四个值_css中的boxshadow属性详解

参考2:
box-shadow属性四个值_boxshadow的妙用

效果:
在这里插入图片描述

实例:


<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>CSS实战 -按钮</title>
 
	<style type="text/css">
		html,body{
  /*box-sizing:border-box;*/
  margin:0;
  height:100%;
  /*background:#000000;*/
}

.button {  
  border-radius: 8px;
	display: inline-block;
	color: #eff6ec;
	text-decoration: none;
	cursor: pointer;
  border-radius: 8px;
	box-shadow: 0 8px 0 #004d2f, 0 10px 15px rgba(0,0,0,.35);
	transition: box-shadow 0.2s ease-in-out;
}

.button span {
  text-align: center;
  border-radius: 8px;
  display: inline-block;
  font-size: 15px;
  font-family: arial;
  background: #008752;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(#008752, #007849);

  border-top: 1px solid rgba(255,255,255,.2);
  border-bottom: 1px solid rgba(0,0,0,.2);
  border-radius: 8 px;  transition: transform 0.2s ease-in-out;
 }
 .button:active {
   box-shadow: 0 8px 0 #004d2f, 0 7px 10px rgba(0,0,0,.25);
 }
 .button:active span {
   transform: translateY(4px);
}
.p{ font-size:12px; width:100px; height:40px; line-height:40px;}
</style>
</head>
<body>
  <div style="margin-top: 100px;margin-left: 100px;background: #a09a47;width: 300px;height: 300px;">
    <div class="button" style="width: 180px;height: 58px;line-height: 58px;">
      <span>发射炮弹</span>
    </div>
  </div>
</body>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

我先来一碗

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

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

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

打赏作者

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

抵扣说明:

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

余额充值