html选择按键点击后锁死输入框_纯CSS锁定的输入框

css

@import url("https://fonts.googleapis.com/css?family=Fira+Sans:300&display=swap");

html {

box-sizing: border-box;

}

*,

*:before,

*:after {

box-sizing: inherit;

}

html,

body {

height: 100vh;

}

body {

display: flex;

align-items: center;

background: #252525;

color: #4a5568;

height: 100%;

font-size: 16px;

font-family: "Fira Sans", sans-serif;

}

div {

--field-size: 50px;

--field-border-color: #ccc;

margin: 0 auto;

font-size: 1rem;

box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

background: #ffffff;

border-radius: 5px;

position: relative;

width: 400px;

overflow: hidden;

display: flex;

background: white;

}

div input[type="checkbox"] {

position: absolute;

opacity: 0;

width: var(--field-size);

height: var(--field-size);

cursor: pointer;

padding: 0;

margin: 0;

}

div input[type="checkbox"]:hover + span {

background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233fc079' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 9.9-1'%3E%3C/path%3E%3C/svg%3E");

background-repeat: no-repeat;

background-position: center center;

background-size: 50%;

}

div input[type="checkbox"]:checked + span {

background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233fc079' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 9.9-1'%3E%3C/path%3E%3C/svg%3E");

background-repeat: no-repeat;

background-position: center center;

background-size: 50%;

}

div input[type="checkbox"]:checked + span::before, div input[type="checkbox"]:checked + span::after {

pointer-events: none;

}

div input[type="checkbox"]:checked + span::after {

-webkit-transform: translateY(-100%);

transform: translateY(-100%);

}

div input[type="checkbox"]:checked + span::before {

-webkit-transform: translateY(100%);

transform: translateY(100%);

}

div input[type="checkbox"] + span {

width: var(--field-size);

height: var(--field-size);

border-right: 1px solid var(--field-border-color);

background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23909090' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-lock'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");

background-repeat: no-repeat;

background-position: center center;

background-size: 50%;

cursor: pointer;

}

div input[type="checkbox"] + span::after, div input[type="checkbox"] + span::before {

content: "";

position: absolute;

right: 0;

height: 50%;

left: var(--field-size);

transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);

background: rgba(0, 0, 0, 0.075);

z-index: 2;

cursor: not-allowed;

}

div input[type="checkbox"] + span::after {

top: 0;

}

div input[type="checkbox"] + span::before {

bottom: 0;

}

div input[type="text"] {

padding: 1em;

border: 0;

flex: 1;

font-size: 1rem;

--placeholder-color: #ababab;

font-family: inherit;

}

div input[type="text"]::-webkit-input-placeholder {

color: var(--placeholder-color);

}

div input[type="text"]:-ms-input-placeholder {

color: var(--placeholder-color);

}

div input[type="text"]::-moz-placeholder {

color: var(--placeholder-color);

}

div input[type="text"]:-moz-placeholder {

color: var(--placeholder-color);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值