CSS自学框架之表单

首先我们看一下表单样式,下面共有5张截图
表单样式,组合
表单样式—数字、颜色选择、单文件选择、多文件选择、滚动条、进度条样式
表单样式—日期选择器
表单样式—多选框、单选框、下拉框
表单样式—文本、多行文本、只读文本

一、CSS代码

/*表单*/
		fieldset{
		    border: none;
		    margin-bottom: 2em;
		}
		fieldset > *{ margin-bottom: 1em }
		fieldset:last-child{ margin-bottom: 0 }
		fieldset legend{ margin: 0 0 1em }/* legend标签是CSS中用于定义各种列表样式的重要标签之一 */
		fieldset input:not([type="checkbox"]):not([type="radio"]), fieldset select, fieldset textarea{ width: 100% }
		fieldset label{display: block; user-select: none;}
		fieldset label > span:first-child{opacity: .6;white-space: nowrap;margin-bottom: .5rem;display: inline-block;}
		/* :required 选择器在表单元素是必填项时设置指定样式。 */
		fieldset label.required > span:first-child:after{color: red;content: "*";margin-left: .25em;}
		input[disabled], textarea[disabled]{cursor: no-drop !important;}
		
		input, select, textarea{margin: 0;outline: none;font: inherit;max-width: 100%;background: none;vertical-align: middle;}
		input[disabled], textarea[disabled]{cursor: no-drop !important;}
		input[type*="date"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"],select, textarea{padding: .5em;color: inherit;border-radius: var(--radius);border: var(--border-width) var(--gray) solid;}input.invalid, input:out-of-range{border-color: #c40b00;background: rgba(255, 0, 0, .1);}
		/* 文件选择 */
		input[type="file"]:not([hidden]){display: flex;align-items: center;}			
		input[type="file"]::-webkit-file-upload-button{color: #fff;border: none;outline: none;padding: .5em 1em;font-size: inherit;margin-right: .5em;display: inline-block;border-radius: var(--radius);background-color: var(--primary);}
		/* 颜色选择器 */
		input[type="color"]{width: 3em !important;height: 3em !important;border: none;padding: 0;}
		input[type="color"]::-webkit-color-swatch-wrapper{padding: 0;}
		input[type="color"]::-moz-color-swatch{border: none;}
		input[type="color"]::-webkit-color-swatch{border: none;border-radius: var(--radius);}
		/* 滑动条 */
		input[type="range"]{margin: 0;height: 100%;-webkit-appearance: none;-moz-appearance: none;cursor: ew-resize;cursor: grab;overflow: hidden;min-height: 1.5rem;}			
		input[type="range"]:focus{outline: none;box-shadow: none;}			
		input[type="range"]:active::-webkit-slider-thumb{border-color: var(--primary);background-color: var(--primary);}
		input[type="range"]:active::-moz-range-thumb{border-color: var(--primary);background-color: var(--primary);}		
		input[type="range"]:focus::-ms-thumb{border-color: var(--primary); background-color: var(--primary);}			
		input[type="range"]::-moz-focus-outer{ border: 0 }
		input[type="range"]::-webkit-slider-runnable-track{content: '';height: calc(var(--border-width) * 2);pointer-events: none;background-color: var(--primary);}			
		input[type="range"]::-webkit-slider-thumb{width: 1em;height: 1em;-webkit-appearance: none;appearance: none;background: #fff;border-radius: 5em;margin-top: calc(-.5em + var(--border-width));border: var(--border-width) solid rgba(0, 0, 0, .15);transition: .3s border-color, .3s background-color;}			
		input[type="range"]::-moz-range-track{height: 2px;background: rgba(0, 50, 126, .12);}			
		input[type="range"]::-moz-range-thumb{width: 1em;height: 1em;background: #fff;border-radius: 5em;margin-top: calc(-.5em + var(--border-width));border: var(--border-width) solid rgba(0, 0, 0, .15);transition: .3s border-color, .3s background-color;}		
		input[type="range"]::-moz-range-progress{border: 0;height: 2px;margin-top: 0;background-color: var(--primary);}				/* 进度条 */
		progress{overflow: auto;border-radius: 50px;}			
		progress::-webkit-progress-bar{background-color: #eee;}
		/* 多选框 */
		input[type="checkbox"], input[type="radio"]{float: left;width: 1.5em;height: 1.5em;cursor: pointer;position: relative;margin: 0 .5em 0 0;-moz-appearance: none;-webkit-appearance: none;}			
		input[type="checkbox"]:before, input[type="radio"]:before{content: '';width: 100%;height: 100%;display: block;box-shadow: 0 0 0 var(--border-width) var(--gray) inset;transition: background-color .3s, box-shadow .3s;}			
		input[type="checkbox"]:after{top: 10%;left: 10%;width: 30%; height: 60%;content: '';position: absolute;transition: transform .3s;transform-origin: 100% 100%;border-right: .15em solid #fff;border-bottom: .15em solid #fff;transform: rotate(45deg) scale(0);}
		input[type="radio"], input[type="radio"]:before{ border-radius: 100% }
		input[type="checkbox"], input[type="checkbox"]:before{ border-radius: .2em }			
		input[type="radio"]:checked:before{background-color: var(--primary);border: var(--border-width) solid var(--primary);box-shadow: 0 0 0 .2em #fff inset;}			
		input[type="checkbox"]:checked:before{box-shadow: none;background-color: var(--primary);}			
		input[type="checkbox"]:checked:after{transform: rotate(45deg) scale(1);}
		/* -- 开关按钮 */
		input[type="checkbox"].switch{width: 4em;height: 2em;float: none;cursor: pointer;position: relative;box-sizing: content-box;border-radius: calc(var(--radius) * 10);border: var(--border-width) solid var(--gray);background-color: var(--lighter-gray);transition: border .3s, background-color .3s;}			
		input[type="checkbox"].switch:before{margin: 0;border: 0;width: 2em;height: 2em;content: '';display: block;box-shadow: none;background: #fff;position: absolute;transition: transform .3s;border-radius: calc(var(--radius) * 10);}			
		input[type="checkbox"].switch:after{ content: normal }			
		input[type="checkbox"].switch:checked{box-shadow: none;border-color: var(--primary);background-color: var(--primary);}
		input.switch:checked:before{background: #fff;transform: translateX(2em);}
		/* 一行表单 */
		form .inline label, fieldset.inline label{display: inline-block;vertical-align: bottom;margin: 0 .75em .75em 0;}
		</style>
	 <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1"/>

二、html代码

<div class="mythBox mid">
		<fieldset>
		  <label class="required">
		    <span>单行文本框:</span>
		    <input type="text" value="我的爱好广泛" />
		  </label>
		  <label>
		    <span>禁用的文本框:</span>
		    <input type="text" value="我的年龄" disabled="">
		  </label>
		  <label>
		    <span>只读的文本框:</span>
		    <input type="text" value="我是只读的" readonly="">
		  </label>
		  <label>
		    <span>多行文本框:</span>
		    <textarea>假如生活欺骗了你,不要悲伤,不要心急!忧郁的日子里须要镇静:相信吧,快乐的日子将会来临!心儿永远向往着未来;现在却常是忧郁:一切都是瞬息,一切都将会过去;而那过去了的,就会成为亲切的怀恋。</textarea>
		  </label>
		  <label>
		    <span>数字:</span>
		    <input type="number" value="5678" />
		  </label>
		  <label>
		    <span>超出数字的文本框:</span>
		    <input type="number" min="1" max="100" value="101">
		  </label>
		  <label>
		    <span>选择颜色:</span>
		    <input type="color">
		  </label>
		  <label>
		    <span>单文件:</span>
		    <input type="file">
		  </label>
		  <label>
		  <span>上传多文件:</span>
		  <input type="file" multiple="">
		  </label>
		  <label>
		    <span>滑动条:</span>
		    <input type="range">
		  </label>
		  <label>
		    <span>进度条:</span>
		    <progress value="10" max="50"></progress>
		  </label>
		  <label>
		    <span>日期形文本框:</span>
		     <input type="date">
		  </label>
		  <label>
		    <span>日期 + 时间形文本框:</span>
		    <input type="datetime-local">
		  </label>
		  
		  <label>
		    <input type="checkbox">多选选项
		  </label>
		  <label>
			<span>性别:</span>
		    <span style="display:inline-block;"><input type="radio" name="xingbie" value=0"">女</span>
			<span style="display:inline-block;"><input type="radio" name="xingbie" value="1"></span>
			
		  </label>
		  <label>
             <span>下来单选框:</span>
            <select>
			<option>张三</option>
            <option>李四</option>
            <option>王五</option>
            </select>
           </label>
		  <label>
		     <span>下来多选框:</span>
		    <select multiple>
		  	<option>张三</option>
		    <option>李四</option>
		    <option>王五</option>
		    </select>
		   </label>
		  <label>
            <span>开关按钮:</span>
            <input type="checkbox" class="switch">
          </label>
		</fieldset>	  <br/>
		<br/>
		<form>
		  <fieldset>
		    <legend>多行:</legend>
		    <label><input type="checkbox" />多选选项 1</label>
		    <label><input type="checkbox" />多选选项 2</label>
		    <label><input type="checkbox" />多选选项 3</label>
		  </fieldset>
		  <fieldset class="inline">
		    <legend>单行:</legend>
		    <label><input type="radio" name="radio" />单选选项 1</label>
		    <label><input type="radio" name="radio" />单选选项 2</label>
		    <label><input type="radio" name="radio" />单选选项 3</label>
		  </fieldset>
		  <fieldset>
		    <legend>混搭:</legend>
		    <div class="row">
		      <div class="col-4">
		        <label>
		          <input type="text" placeholder="名字:" />
		        </label>
		      </div>
		      <div class="col-4">
		        <label>
		          <input type="text" placeholder="邮箱:" />
		        </label>
		      </div>
		      <div class="col-4">
		        <label>
		          <input type="text" placeholder="网站:" />
		        </label>
		      </div>
		      <div class="col-12">
		        <label>
		          <textarea placeholder="在这里留言吧"></textarea>
		        </label>
		      </div>
		      <div class="col-12">
		        <button class="btn yellow" type="submit">提交</button>
		      </div>
		    </div>
		  </fieldset>
		</form>
	</div>		  

这一小节里,我学习了一些表单元素的样式定,收货颇丰,主要实现了单行文本框输入、多行文本框、数字输入框、开关、单选框、多选框、下拉框、进度条、互动条等一些列表单元素的css样式。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/74753.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【数据结构】树和二叉树

一、树的概念及结构 1、树的概念 树 是一种非线性的数据结构&#xff0c;它是由n&#xff08;n>0&#xff09;个有限结点组成一个具有层次关系的集合。把它叫做树是因 为它看起来像一棵倒挂的树&#xff0c;也就是说它是根朝上&#xff0c;而叶朝下的。 有一个特殊的结点&a…

机器学习笔记值优化算法(十四)梯度下降法在凸函数上的收敛性

机器学习笔记之优化算法——梯度下降法在凸函数上的收敛性 引言回顾&#xff1a;收敛速度&#xff1a;次线性收敛二次上界引理 梯度下降法在凸函数上的收敛性收敛性定理介绍证明过程 引言 本节将介绍梯度下降法在凸函数上的收敛性。 回顾&#xff1a; 收敛速度&#xff1a;次…

Jay17 2023.8.14日报 即 留校集训阶段性总结

8.14 打了moeCTF&#xff0c;还剩一题ak Web。 Jay17-集训结束阶段性总结&#xff1a; 集训产出&#xff1a; 自集训开始以来一个半月&#xff0c;最主要做的事情有三。 一是跟课程&#xff0c;复习学过的知识&#xff0c;学习新的知识&#xff1b;目前课程已大体听完&…

问道管理:缩量小幅上涨说明什么?

股市里面&#xff0c;股票价格上涨或跌落都是常见现象。可是关于那些在商场上寻求收益的出资者来说&#xff0c;他们需要对每一个股市中的价格动摇有深化的了解&#xff0c;以便做出更正确的出资决策。最近&#xff0c;出资者们发现商场缩量小幅上涨的现象时有发生&#xff0c;…

word 应用 打不开 显示一直是正在启动中

word打开来显示一直正在启动中&#xff0c;其他调用word的应用也打不开&#xff0c;网上查了下以后进程关闭spoolsv.exe,就可以正常打开word了

redis的三种集群方式

redis有三种集群方式&#xff1a;主从复制&#xff0c;哨兵模式和集群。 1.主从复制 主从复制原理&#xff1a; 从服务器连接主服务器&#xff0c;发送SYNC命令&#xff1b; 主服务器接收到SYNC命名后&#xff0c;开始执行BGSAVE命令生成RDB文件并使用缓冲区记录此后执行的所…

C++入门篇8---vector

vecctor是动态顺序表 一、了解vector的相关接口及其功能 1.构造函数相关接口 函数声明功能介绍vector()无参构造vector(size_type n,const value_type& valvalue_type())构造并初始化n个valvector(const value& x)拷贝构造vector(InputIterator first, InputIterato…

【Git】本地搭建Gitee、Github环境

本地 &#xff08;Local&#xff09; 1、使用命令生成公钥&#xff08;pub文件&#xff09; 1. $ ssh-keygen -t rsa -C "xxxxxxxemail.com" -f "github_id_rsa" 2. $ ssh-keygen -t rsa -C "xxxxxxxemail.com" -f "gitee_id_rsa" …

解读spring中@Value 如何将配置转自定义的bean

实现方式 着急寻求解决方式的猿友先看这块 定义配置转化类 public class UserConverter implements Converter<String, List<User>> {Overridepublic List<User> convert(String config) {if (StringUtils.isEmpty(config)) {return Collections.emptyLis…

数组的详述(1)

1、一维数组的创建和初始化&#xff1a; 数组是一组相同类型元素的集合。 &#xff08;1)创建方式&#xff1a; type_t 是指数组的元素类型 arr_name 数组名 [const_n] 一个常量表达式&#xff0c;用来指定数组的大小 //在c99标准之前&#xff0c;数组的大小必须是常…

普通上班族学Python有用吗?

普通上班族学Python有用吗&#xff1f;对于广大上班族而言&#xff0c;时间和精力主要问题&#xff0c;学习Python编程语言为了能提高工作效率。学Python不是单纯的为了增加知识储备&#xff0c;Python本质上是一个工具和手段&#xff0c;最终目的是要通过它来帮我们解决实际工…

Falco操作系统安全威胁监测利器

原理简介 Falco是一个开源的云原生安全工具&#xff0c;用于检测和防御容器和云原生环境中的安全威胁。它基于Linux内核的eBPF技术&#xff0c;通过监控系统调用和内核事件来实现安全检测和响应。 具体来说&#xff0c;Falco的实现原理如下&#xff1a; 1. 内核模块&#xf…

并发编程系列-Semaphore

Semaphore&#xff0c;如今通常被翻译为"信号量"&#xff0c;过去也曾被翻译为"信号灯"&#xff0c;因为类似于现实生活中的红绿灯&#xff0c;车辆是否能通行取决于是否是绿灯。同样&#xff0c;在编程世界中&#xff0c;线程是否能执行取决于信号量是否允…

添加vue devtools扩展工具+添加后F12不显示Vue图标

前言&#xff1a;在开启Vue学习之旅时&#xff0c;遇到问题两个问题&#xff0c;第一添加不上vue devtools扩展工具&#xff0c;第二添加完成后&#xff0c;F12不显示Vue图标。查阅了很多博客&#xff0c;自己解决了问题&#xff0c;故写此博客记录。如果你遇到和我一样的问题&…

item_get_sales-获取商品销量详情

一、接口参数说明&#xff1a; item_get_sales-获取商品销量详情&#xff0c;点击更多API调试&#xff0c;请移步注册API账号点击获取测试key和secret 公共参数 请求地址: https://api-gw.onebound.cn/taobao/item_get_sales 名称类型必须描述keyString是调用key&#xff08…

算法通过村第三关-数组青铜笔记|单调数组

文章目录 前言单调数组问题搜索插入位置&#xff1a;数组合并问题&#xff1a;总结 前言 提示&#xff1a;本份真诚面对自己、坦然无碍面对他人&#xff0c;就是优雅。 数组中的比较经典性问题: 单调数组问题数组合并问题 单调数组问题 参考例子&#xff1a;896. 单调数列…

vue3+element-plus表格默认排序default-sort失效问题

场景 在使用动态数据渲染的场景&#xff0c;el-table设置默认属性default-sort失效。 原因 el-table的default-sort属性是针对静态数据的&#xff0c;如果是动态数据&#xff0c;default-sort则无法监听到。 案例&#xff1a;静态数据 <template><el-table:data&…

全面拥抱AI时刻来临?基于AI技术助力养猪产仔是否可行?

这两天看到一篇论文&#xff0c;蛮有意思的&#xff0c;技术层面倒没有什么新颖的点&#xff0c;主要是落地应用场景比较贴近现实&#xff0c;文章主要就是应用yolov5来开发构建了一套母猪产仔智能化检测预警模型&#xff0c;从而来降低大型养殖场中人工成本。一起来简单看下吧…

比例电磁铁控制放大器

GP63系列比例电磁铁应用于电液比例控制系统中&#xff0c;与比例控制放大器配套使用共同控制力士(REXROTH)型十通径螺纹比例阀。在额定行程及额定电流范围内&#xff0c;其输出力与输入电流成比例&#xff0c;通过内置反力弹簧&#xff0c;改变了输出力的特性&#xff0c;使系统…

leetcode358周赛

2815. 数组中的最大数对和 核心思想&#xff1a;维护每一个最大的数字的最大值&#xff0c;然后一边更新最大值&#xff0c;一边统计结果。其中求nums中的每一个数的数位最大值可以用map的方法&#xff0c;我自己做的时候是用的%10&#xff0c;感觉map这种方法很巧妙。 2816. …
最新文章