Web表单美化CSS框架Topcoat

简介:
Topcoat同样是一款简洁的Web表单构建应用,和 Semantic UIBootMetro等CSS框架不同的是,Topcoat主要用于构建美化的Web表单,包括提交按钮、输入框、单选框/复选框、滑动杆、搜索框等表单元素。

Topcoat的特点

  • 小巧、简单、易用

  • 专注表单元素设计,每一个表单元素都非常精美

  • 支持移动化,让这些表单元素在移动端同样有着不错的效果

Topcoat相关组件实例

按钮

以蓝色按钮为例,相关代码如下:

HTML

 
 
  1. <button class="topcoat-button--large--cta" >Button</button> 
  2. <button class="topcoat-button--large--cta" disabled>Button</button> 
  3.  
  4. CSS 
  5.  
  6. .topcoat-button--large--cta { 
  7.   font-size: 0.875rem; 
  8.   font-weight: 600
  9.   line-height: 1.688rem; 
  10.   padding: 0 0.875rem; 
  11.  
  12. input[type="checkbox"] { 
  13.   position: absolute; 
  14.   overflow: hidden; 
  15.   padding: 0
  16.   border: 0
  17.   opacity: 0.001
  18.   z-index: 1
  19.   vertical-align: top; 
  20.   outline: none; 
  21.  
  22. .checkbox { 
  23.   -moz-box-sizing: border-box; 
  24.   box-sizing: border-box; 
  25.   background-clip: padding-box; 
  26.   position: relative; 
  27.   display: inline-block; 
  28.   vertical-align: top; 
  29.   cursor: default
  30.   -webkit-user-select: none; 
  31.   -moz-user-select: none; 
  32.   -ms-user-select: none; 
  33.   user-select: none; 
  34.  
  35. .checkbox__label { 
  36.   position: relative; 
  37.   display: inline-block; 
  38.   vertical-align: top; 
  39.   cursor: default
  40.   -webkit-user-select: none; 
  41.   -moz-user-select: none; 
  42.   -ms-user-select: none; 
  43.   user-select: none; 
  44.  
  45. .checkbox--disabled { 
  46.   opacity: 0.3
  47.   cursor: default
  48.   pointer-events: none; 
  49.  
  50. .checkbox:before, 
  51. .checkbox:after { 
  52.   content: ''
  53.   position: absolute; 
  54.  
  55. .checkbox:before { 
  56.   -moz-box-sizing: border-box; 
  57.   box-sizing: border-box; 
  58.   background-clip: padding-box; 
  59.  
  60. input[type="checkbox"] { 
  61.   position: absolute; 
  62.   overflow: hidden; 
  63.   padding: 0
  64.   border: 0
  65.   opacity: 0.001
  66.   z-index: 1
  67.   vertical-align: top; 
  68.   outline: none; 
  69.  
  70. .checkbox, 
  71. .topcoat-checkbox__checkmark { 
  72.   -moz-box-sizing: border-box; 
  73.   box-sizing: border-box; 
  74.   background-clip: padding-box; 
  75.   position: relative; 
  76.   display: inline-block; 
  77.   vertical-align: top; 
  78.   cursor: default
  79.   -webkit-user-select: none; 
  80.   -moz-user-select: none; 
  81.   -ms-user-select: none; 
  82.   user-select: none; 
  83.  
  84. .checkbox__label, 
  85. .topcoat-checkbox { 
  86.   position: relative; 
  87.   display: inline-block; 
  88.   vertical-align: top; 
  89.   cursor: default
  90.   -webkit-user-select: none; 
  91.   -moz-user-select: none; 
  92.   -ms-user-select: none; 
  93.   user-select: none; 
  94.  
  95. .checkbox--disabled, 
  96. input[type="checkbox"]:disabled + .topcoat-checkbox__checkmark { 
  97.   opacity: 0.3
  98.   cursor: default
  99.   pointer-events: none; 
  100.  
  101. .checkbox:before, 
  102. .checkbox:after, 
  103. .topcoat-checkbox__checkmark:before, 
  104. .topcoat-checkbox__checkmark:after { 
  105.   content: ''
  106.   position: absolute; 
  107.  
  108. .checkbox:before, 
  109. .topcoat-checkbox__checkmark:before { 
  110.   -moz-box-sizing: border-box; 
  111.   box-sizing: border-box; 
  112.   background-clip: padding-box; 

单选框/复选框

以单选框为例,相关代码如下:

 
 
  1. HTML 
  2.  
  3. <!-- NO LABEL --> 
  4. <label class="topcoat-radio-button"
  5.   <input type="radio" name="topcoat"
  6.   <div class="topcoat-radio-button__checkmark"></div> 
  7. </label> 
  8. <br> 
  9. <br> 
  10. <!-- LEFT LABEL --> 
  11. <label class="topcoat-radio-button"
  12.   Left label 
  13.   <input type="radio" name="topcoat"
  14.   <div class="topcoat-radio-button__checkmark"></div> 
  15. </label> 
  16. <br> 
  17. <br> 
  18. <!-- RIGHT LABEL --> 
  19. <label class="topcoat-radio-button"
  20.   <input type="radio" name="topcoat"
  21.   <div class="topcoat-radio-button__checkmark"></div> 
  22.   Right label 
  23. </label> 
  24. <br> 
  25. <br> 
  26. <!-- DISABLED --> 
  27. <label class="topcoat-radio-button"
  28.   <input type="radio" name="topcoat" Disabled> 
  29.   <div class="topcoat-radio-button__checkmark"></div> 
  30.   Disabled 
  31. </label> 
  32.  
  33. CSS: 
  34.  
  35. input[type="radio"] { 
  36.   height1.063rem; 
  37.   width1.063rem; 
  38.   margin-top0
  39.   margin-right-1.063rem; 
  40.   margin-bottom-1.063rem; 
  41.   margin-left0
  42.  
  43. input[type="radio"]:checked + .topcoat-radio-button__checkmark:after { 
  44.   opacity: 1
  45.  
  46. .topcoat-radio-button { 
  47.   color#c6c8c8
  48.   line-height1.063rem; 
  49.  
  50. .topcoat-radio-button__checkmark:before { 
  51.   width1.063rem; 
  52.   height1.063rem; 
  53.   background#595b5b
  54.   border1px solid #333434
  55.   box-shadow: inset 0 1px #737373
  56.  
  57. .topcoat-radio-button__checkmark { 
  58.   positionrelative
  59.   width1.063rem; 
  60.   height1.063rem; 
  61.  
  62. .topcoat-radio-button__checkmark:after { 
  63.   opacity: 0
  64.   width0.313rem; 
  65.   height0.313rem; 
  66.   background#c6c8c8
  67.   border1px solid rgba(0,0,0,0.05); 
  68.   box-shadow: 0 1px rgba(255,255,255,0.1); 
  69.   -webkit-transform: none
  70.   -ms-transform: none
  71.   transform: none
  72.   top: 0.313rem; 
  73.   left: 0.313rem; 
  74.  
  75. input[type="radio"]:focus + .topcoat-radio-button__checkmark:before { 
  76.   border1px solid #0036ff
  77.   box-shadow: inset 0 1px rgba(255,255,255,0.36), 0 0 0 2px #6fb5f1
  78.  
  79. input[type="radio"]:active + .topcoat-radio-button__checkmark:before { 
  80.   border1px solid #333434
  81.   background-color#3f4041
  82.   box-shadow: inset 0 1px rgba(0,0,0,0.05); 
  83.  
  84. input[type="radio"]:disabled:active + .topcoat-radio-button__checkmark:before { 
  85.   border1px solid #333434
  86.   background#595b5b
  87.   box-shadow: inset 0 1px #737373
  88.  
  89. .range { 
  90.   padding0
  91.   margin0
  92.   font: inherit; 
  93.   color: inherit; 
  94.   backgroundtransparent
  95.   bordernone
  96.   -moz-box-sizing: border-box; 
  97.   box-sizing: border-box; 
  98.   background-clip: padding-box; 
  99.   vertical-aligntop
  100.   outlinenone
  101.   -webkit-appearance: none
  102.  
  103. .range__thumb { 
  104.   cursorpointer
  105.  
  106. .range__thumb--webkit { 
  107.   cursorpointer
  108.   -webkit-appearance: none
  109.  
  110. .range:disabled { 
  111.   opacity: 0.3
  112.   cursordefault
  113.   pointer-events: none
  114.  
  115. .range, 
  116. .topcoat-range { 
  117.   padding0
  118.   margin0
  119.   font: inherit; 
  120.   color: inherit; 
  121.   backgroundtransparent
  122.   bordernone
  123.   -moz-box-sizing: border-box; 
  124.   box-sizing: border-box; 
  125.   background-clip: padding-box; 
  126.   vertical-aligntop
  127.   outlinenone
  128.   -webkit-appearance: none
  129.  
  130. .range__thumb, 
  131. .topcoat-range::-moz-range-thumb { 
  132.   cursorpointer
  133.  
  134. .range__thumb--webkit, 
  135. .topcoat-range::-webkit-slider-thumb { 
  136.   cursorpointer
  137.   -webkit-appearance: none
  138.  
  139. .range:disabled, 
  140. .topcoat-range:disabled { 
  141.   opacity: 0.3
  142.   cursordefault
  143.   pointer-events: none

更多关于Topcoat的组件,大家可以前往其官方网站进行学习。


作者:佚名

来源:51CTO

相关文章
|
17天前
|
安全 数据库 C++
Python Web框架比较:Django vs Flask vs Pyramid
【4月更文挑战第9天】本文对比了Python三大Web框架Django、Flask和Pyramid。Django功能全面,适合快速开发,但学习曲线较陡;Flask轻量灵活,易于入门,但默认配置简单,需自行添加功能;Pyramid兼顾灵活性和可扩展性,适合不同规模项目,但社区及资源相对较少。选择框架应考虑项目需求和开发者偏好。
|
1天前
|
存储 中间件 Go
探索Gin框架:快速构建高性能的Golang Web应用
探索Gin框架:快速构建高性能的Golang Web应用
|
2天前
|
开发框架 前端开发 数据库
Python从入门到精通:3.3.2 深入学习Python库和框架:Web开发框架的探索与实践
Python从入门到精通:3.3.2 深入学习Python库和框架:Web开发框架的探索与实践
|
11天前
|
前端开发 搜索推荐 数据安全/隐私保护
HTML标签详解 HTML5+CSS3+移动web 前端开发入门笔记(四)
HTML标签详解 HTML5+CSS3+移动web 前端开发入门笔记(四)
18 1
|
11天前
|
PHP
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
|
11天前
|
前端开发 数据挖掘 API
使用Python中的Flask框架进行Web应用开发
【4月更文挑战第15天】在Python的Web开发领域,Flask是一个备受欢迎的轻量级Web框架。它简洁、灵活且易于扩展,使得开发者能够快速地构建出高质量的Web应用。本文将深入探讨Flask框架的核心特性、使用方法以及在实际开发中的应用。
|
14天前
|
前端开发 JavaScript 搜索推荐
CSS框架是前端开发中不可或缺的工具
【4月更文挑战第12天】CSS框架是前端开发中不可或缺的工具
18 2
|
23天前
|
前端开发 安全 Java
使用Java Web框架:Spring MVC的全面指南
【4月更文挑战第3天】Spring MVC是Spring框架的一部分,用于构建高效、模块化的Web应用。它基于MVC模式,支持多种视图技术。核心概念包括DispatcherServlet(前端控制器)、HandlerMapping(请求映射)、Controller(处理请求)、ViewResolver(视图解析)和ModelAndView(模型和视图容器)。开发流程涉及配置DispatcherServlet、定义Controller、创建View、处理数据、绑定模型和异常处理。
使用Java Web框架:Spring MVC的全面指南
|
27天前
|
前端开发 JavaScript 数据管理
描述一个使用Python开发Web应用程序的实际项目经验,包括所使用的框架和技术栈。
使用Flask开发Web应用,结合SQLite、Flask-SQLAlchemy进行数据管理,HTML/CSS/JS(Bootstrap和jQuery)构建前端。通过Flask路由处理用户请求,模块化代码提高可维护性。unittest进行测试,开发阶段用内置服务器,生产环境可选WSGI服务器或容器化部署。实现了用户注册登录和数据管理功能,展示Python Web开发的灵活性和效率。
15 4
|
1月前
|
数据库
最全三大框架整合(使用映射)——struts.xml和web.xml配置
最全三大框架整合(使用映射)——数据库资源文件jdbc.properties
10 0