现代网页样式与布局 | AI生成和翻译

Home 2025.10

概述

这段代码采用 SCSS (Sass) 语法编写,包含嵌套结构、伪类选择符(&)和 @extend 指令。它定义了基础网页布局、表单、按钮及工具类的样式,呈现简洁现代的美学风格(如圆角、柔和阴影、悬停过渡效果)。无单位数值属性(如 font-size 16px)是 SCSS 的简写形式。下面按模块解析选择器及其作用效果。

全局样式(html, body)

html, body
  font-family Verdana
  font-size 16px
  height 100%
  background-color #D2D2D2

列表与链接样式(ul, a)

ul
  list-style-type none
  padding 0
  margin 0

a
  color #000
  cursor pointer
  text-decoration none

色彩与文本工具类 (.a-blue)

.a-blue
  color #00BDEF

按钮样式 (.btn, .btn-blue, .btn-gray, .btn-gray-2)

.btn
  border-radius 3px
  padding 10px

.btn-blue
  background #00BDEF
  color #fff
  -webkit-box-shadow 0px 1px 0px rgba(255,255,255,0.15) inset,0px 1px 2px rgba(0,0,0,0.15)
  box-shadow 0px 1px 0px rgba(255,255,255,0.15) inset,0px 1px 2px rgba(0,0,0,0.15)
  &:hover
    background #00ABD8
    transition .5s

.btn-gray
  background #eee
  color #333
  border 1px solid #d5d5d5
  border-radius 3px
  -webkit-box-shadow 0px 1px 0px rgba(255,255,255,0.15) inset,0px 1px 2px rgba(0,0,0,0.15)
  box-shadow 0px 1px 0px rgba(255,255,255,0.15) inset,0px 1px 2px rgba(0,0,0,0.15)
  &:hover
    background #ddd
    transition 0.5s

.btn-gray-2
  background #eee
  color #333
  border 1px solid #d5d5d5
  border-radius 3px
  &:hover
    background #ddd
    transition 0.5s

定位工具类 (.absolute-center, .full-space)

.absolute-center
    margin auto
    position absolute
    top 0
    left 0
    bottom 0
    right 0

.full-space
    position absolute
    top 0
    left 0
    bottom 0
    right 0

表单样式 (.base-form, input/textarea/select, button)

.base-form
  @extend .absolute-center
  max-width 350px
  height 400px
  background #fff
  border-radius 20px
  text-align center
  padding 20px 10px

input, textarea, select
  box-sizing border-box
  border none
  outline none
  &:focus
    border none
    outline none
    box-shadow 0px 1px 4px 0px rgba(0,0,0,.06)
    -webkit-box-shadow 0px 1px 4px 0px rgba(0,0,0,.06)

button
  border-style none
  outline none

此代码构建了具有样式化按钮和输入框的响应式居中表单页面。若使用 SCSS 需编译为标准 CSS。自定义时可根据需求调整色彩或尺寸参数。


Back

x-ai/grok-code-fast-1

Donate