美化表单

美化表单

新的伪类

  1. :focus:元素聚焦
    所有元素都有聚焦,可通过元素的tabindex属性的大小,设置tab键元素聚焦时的顺序
	.box:focus{
		outline: none;
		outline-offset: 0;
	}
  1. :checked:表示单选框或多选框被选中的样式(很少样式可设置)
	input:checked + label{
		color: #ccc;
	}

常见用法

  1. 重置表单元素样式
	input, textareat, button, select{
		border: none;
	}
	input:focus, 
	textareat:focus, 
	button:focus, 
	select:focus{
		outline: none;
		outline-offset: 0;
	}
	input[type="text"]{
		border: 1px solid #ccc;
	}
	input[type="text"]:focus{
		border: 1px solid #008c8c;
	}
  1. 设置textarea是否可调整尺寸
    resize属性
  • both:默认值,两个方向上均可调整
  • none:均不可调整
  • horizontal:水平方向上可以调整
  • vertical:垂直方向上可以调整
	textarea{
		resize: 
	}
  1. 文本框内容到边框的距离
    (1)padding
    (2)text-indent
	input[type="text"]{
		padding: 2px 3px;
	}
  1. 控制单选和多选的样式
    自己做单选框
	.radio{
		...
	}
	input:checked + .radio{
		...
	}
	input:checked + .radio::after{
		content: "";
		display: inline-block;
		width: 8px;
		height: 8px;
		border-radius: 50%;
		margin: 4px;
	}
	input[type="radio"]{
		display: none;
	}
	<label>
		<input name="sex" type="radio">
		<span class="radio"></span>
		<span >male</span>
	</label>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值