js+css实现圆圈搜索类别切换旋转带清除的搜索框代码

代码语言:html

所属分类:搜索

代码描述:js+css实现圆圈搜索类别切换旋转带清除的搜索框代码

代码标签: js css 圆圈 搜索 类别 切换 旋转 清除 搜索框 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  


  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  
  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=DM+Sans&amp;display=swap'>
  
<style>
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--hue: 223;
	--bg: hsl(var(--hue),90%,90%);
	--fg: hsl(var(--hue),90%,10%);
	--primary: hsl(var(--hue),90%,50%);
	--trans-dur: 0.3s;
	--trans-timing: cubic-bezier(0.65,0,0.35,1);
	font-size: calc(16px + (32 - 16) * (100vw - 320px) / (2560 - 320));
}
body,
button,
input {
	color: var(--fg);
	font: 1em/1.5 "DM Sans", sans-serif;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}
body {
	background-color: var(--primary);
	display: flex;
	height: 100vh;
}
.search__button,
.search__input,
.search__wrapper {
	border-radius: 0.375em;
}
.search {
	margin: auto;
	position: relative;
	width: 100%;
	max-width: 18em;
	height: 2.25em;
}
.search:before {
	box-shadow: 0 0 0.5em hsla(var(--hue),10%,10%,0.2);
	content: "";
	display: block;
	position: absolute;
	width: inherit;
	height: inherit;
}
.search__button,
.search__label,
.search__placeholder,
.search__placeholders,
.search__wrapper {
	position: absolute;
}
.search__button,
.search__input,
.search__wrapper {
	border-radius: 0.375em;
}
.search__button,
.search__input {
	background-color: transparent;
	outline: transparent;
}
.search__button,
.search__placeholders {
	width: 2.25em;
	height: 2.25em;
	z-index: 1;
}
.search__button {
	cursor: pointer;
}
.search__button-icon,
.search__placeholders {
	opacity: 0.4;
	pointer-events: none;
}
.search__button-icon {
	display: block;
	margin: auto;
	position: relative;
	width: 1.5em;
	height: 1.5em;
	transition: opacity calc(var(--trans-dur) / 2) var(--trans-timing);
}
.search__button:focus-visible .search__button-icon,
.search__button:hover .search__button-icon {
	opacity: 1;
}
.search__input {
	padding: 0 0.75em 0 2.75em;
	width: 100%;
	height: inherit;
	-webkit-appearance: none;
	appearance: none;
}
.search__input::-webkit-search-cancel-button {
	background: url("//repo.bfw.wiki/bfwrepo/icon/5ffd0e43aeff2.png") no-repeat 0 0 / 100% auto;
	width: 0.75em;
	height: 0.75em;
	-webkit-appearance: none;
}
.search__label {
	overflow: hidden;
	width: 1px;
	height: 1px;
}
.search__placeholder {
	top: calc(50% - 0.75em);
	left: 50%;
	transform: translateX(1.625em);
	transform-origin: 0 50%;
}
.search__placeholder:nth-child(2) {
	transform: rotate(-60deg) translateX(1.625em);
}
.search__placeholder:nth-child(3) {
	transform: rotate(-120deg) translateX(1.625em);
}
.search__placeholder:nth-child(4) {
	transform: rotate(-180deg) translateX(1.625em);
}
.search__placeholder:nth-child(5) {
	transform: rotate(-240deg) translateX(1.625em);
}
.search__placeholder:nth-child(6) {
	transform: rotate(-300deg) translateX(1.625em);
}
.search__placeholders {
	top: 0;
	left: 0;
}
.search__wrapper {
	background-color: hsl(0,0%,100%);
	overflow: hidden;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transition: background-color var(--trans-dur);
}
.search__button:not([data-type="0"]) .search__label:nth-child(2) {
	display: none;
}
.search__button[data-type="1"] .search__label:nth-child(3),
.search__button[data-type="2"] .search__label:nth-child(4),
.search__button[data-type="3"] .search__label:nth-child(5),
.search__button[data-type="4"] .search__label:nth-child(6),
.search__button[data-type="5"] .search__label:nth-child(7) {
	display: inherit;
}
.search__button[data-type="1"] .search__button-icon,
.search__button[data-type="1"] ~ .search__placeholders {
	transform: rotate(60deg);
}
.search__button[data-type="2"] .search__button-icon,
.search__button[data-type="2"] ~ .search__placeholders {
	transform: rotate(120deg);
}
.search__button[data-type="3"] .search__button-icon,
.search__button[data-type="3"] ~ .search__plac.........完整代码请登录后点击上方下载按钮下载查看

网友评论0