css3 使用box-shadow实现浮雕风格按钮效果

  发布时间:2024-08-19 17:05:11   作者:hackchen   我要评论
这篇文章主要介绍了css3 使用box-shadow实现浮雕风格按钮效果,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧

利用 box-shadow 实现浮雕风格的按钮。

HTML:

<form>
  <div class="segment">
    <h1>Sign up</h1>
  </div>
  <label>
    <input type="text" placeholder="Email Address" />
  </label>
  <label>
    <input type="password" placeholder="Password" />
  </label>
  <button class="red" type="button"><i class="icon ion-md-lock"></i> Log in</button>
  <div class="segment">
    <button class="unit" type="button"><i class="icon ion-md-arrow-back"></i></button>
    <button class="unit" type="button"><i class="icon ion-md-bookmark"></i></button>
    <button class="unit" type="button"><i class="icon ion-md-settings"></i></button>
  </div>
  <div class="input-group">
    <label>
      <input type="text" placeholder="Email Address" />
    </label>
    <button class="unit" type="button"><i class="icon ion-md-search"></i></button>
  </div>
</form>

SCSS:

$ruler: 16px;
$color-red: #ae1100;
$color-bg: #ebecf0;
$color-shadow: #babecc;
$color-white: #fff;
body,
html {
  background-color: $color-bg;
}
h1 {
  margin: 0;
}
body,
p,
input,
select,
textarea,
button {
  font-family: "Montserrat", sans-serif;
  letter-spacing: -0.2px;
  font-size: $ruler;
}
div,
p {
  color: $color-shadow;
  text-shadow: 1px 1px 1px $color-white;
}
form {
  padding: $ruler;
  width: $ruler * 20;
  margin: 0 auto;
}
.segment {
  padding: $ruler * 2 0;
  text-align: center;
}
button,
input {
  border: 0;
  outline: 0;
  font-size: $ruler;
  border-radius: $ruler * 20;
  padding: $ruler;
  background-color: $color-bg;
  text-shadow: 1px 1px 0 $color-white;
}
label {
  display: block;
  margin-bottom: $ruler * 1.5;
  width: 100%;
}
input {
  margin-right: $ruler/2;
  box-shadow: inset 2px 2px 5px $color-shadow, inset -5px -5px 10px $color-white;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  appearance: none;
  -webkit-appearance: none;
  &:focus {
    box-shadow: inset 1px 1px 2px $color-shadow,
      inset -1px -1px 2px $color-white;
  }
}
button {
  color: #61677c;
  font-weight: bold;
  box-shadow: -5px -5px 20px $color-white, 5px 5px 20px $color-shadow;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  font-weight: 600;
  &:hover {
    box-shadow: -2px -2px 5px $color-white, 2px 2px 5px $color-shadow;
  }
  &:active {
    box-shadow: inset 1px 1px 2px $color-shadow,
      inset -1px -1px 2px $color-white;
  }
  .icon {
    margin-right: $ruler/2;
  }
  &.unit {
    border-radius: $ruler/2;
    line-height: 0;
    width: $ruler * 3;
    height: $ruler * 3;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0 $ruler/2;
    font-size: $ruler * 1.2;
    .icon {
      margin-right: 0;
    }
  }
  &.red {
    display: block;
    width: 100%;
    color: $color-red;
  }
}
.input-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  label {
    margin: 0;
    flex: 1;
  }
}

到此这篇关于css3 box-shadow 浮雕风格按钮的文章就介绍到这了,更多相关css3 box-shadow浮雕按钮内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

相关文章

  • CSS3中的字体及相关属性详解

    这篇文章主要介绍了CSS3中的字体及相关属性,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2025-06-12
  • CSS3实现的账号密码输入框提示效果

    本文详细解析了CSS3中实现账号密码输入框提示特效的原理和方法,包括HTML5的placeholder属性与CSS3新特性如伪类选择器、动态效果和过渡动画的结合使用,感兴趣的朋友跟随小
    2025-05-14
  • CSS3 布局样式及其应用举例

    CSS3的布局特性为前端开发者提供了无限可能,无论是Flexbox的一维布局还是Grid的二维布局,它们都能够帮助开发者以更清晰、简洁的方式实现复杂的网页布局,本文给大家介绍C
    2025-05-14
  • CSS3 Facebook-style Buttons 项目常见问题及最新解决方案

    CSS3 Facebook-style Buttons 是一个开源项目,旨在通过简单的 CSS 代码来重现 Facebook 按钮和工具栏的外观,本文给大家介绍CSS3 Facebook-style Buttons 项目常见问题及
    2025-05-14
  • 使用animation.css库快速实现CSS3旋转动画效果

    随着Web技术的不断发展,动画效果已经成为了网页设计中不可或缺的一部分,本文将深入探讨animation.css的工作原理,如何使用以及其在实际项目中的应用,感兴趣的朋友一起看
    2025-05-14
  • CSS3 最强二维布局系统之Grid 网格布局

    CS3的Grid网格布局是目前最强的二维布局系统,可以同时对列和行进行处理,将网页划分成一个个网格,可以任意组合不同的网格,做出各种各样的布局,本文介绍CSS3 最强二维布局系
    2025-02-27
  • 如何使用CSS3实现波浪式图片墙

    本文介绍了如何使用CSS3的transform属性和动画技巧实现波浪式图片墙,通过设置图片的垂直偏移量,并使用动画使其周期性地改变位置,可以创建出动态且具有波浪效果的图片墙,同
    2025-02-27
  • CSS3模拟实现一个雷达探测扫描动画特效(最新推荐)

    文章介绍了如何使用CSS3实现一个雷达探测扫描的效果,包括夜色背景、蜘蛛网盘、扫描体的转动效果、尾巴阴影以及被扫描到的光点,通过HTML和CSS的配合,实现了丰富的动画效果,
    2025-02-21
  • css3 display:flex 弹性盒模型的使用方法

    CSS3的Flexbox是一种强大的布局模式,通过设置display:flex可以轻松实现对齐、排列和分布网页元素,它解决了传统布局方法中的对齐、间距分配和自适应布局等问题,接下来通过本
    2025-02-19
  • css3 实现icon刷新转动效果

    本文给大家介绍css3 实现icon刷新转动效果,文章开头给大家介绍了webkit-transform、animation、@keyframes这三个属性,结合实例代码给大家介绍的非常详细,感兴趣的朋友一
    2025-02-19

最新评论