css实现表情评分滑动条效果代码

代码语言:html

所属分类:星级评分

代码描述:css实现表情评分滑动条效果代码

代码标签: 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">
  
  
  
<style>
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--hue: 223;
	--bg: hsl(var(--hue),10%,100%);
	--fg: hsl(var(--hue),10%,10%);
	--primary1: hsl(var(--hue),90%,55%);
	--primary2: hsl(var(--hue),90%,65%);
	--trans-dur: 0.3s;
	font-size: calc(16px + (20 - 16) * (100vw - 320px) / (1280 - 320));
}
body,
input {
	font: 1em/1.5 sans-serif;
}
body {
	background-color: var(--bg);
	color: var(--fg);
	height: 100vh;
	display: grid;
	place-items: center;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}

.e-rating,
.e-rating__faces {
	display: flex;
}
.e-rating {
	--animDur: 2s;
	flex-wrap: wrap;
	padding-top: 2em;
	width: 18em;
}
.e-rating__sr {
	clip: rect(1px,1px,1px,1px);
	overflow: hidden;
	position: absolute;
	width: 1px;
	height: 1px;
}
.e-rating__range {
	background-color: hsl(var(--hue),10%,50%,0.5);
	border-radius: 0.25em;
	margin: 0.5em 0.75em;
	order: 1;
	width: 100%;
	height: 0.5em;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}
.e-rating__range:focus {
	outline: transparent;
}
.e-rating__range::-webkit-slider-thumb {
	background-color: var(--primary1);
	border: 0;
	border-radius: 50%;
	width: 1.5em;
	height: 1.5em;
	transition: background-color 0.15s linear;
	-webkit-appearance: none;
	appearance: none;
}
.e-rating__range:focus::-webkit-slider-thumb,
.e-rating__range::-webkit-slider-thumb:hover {
	background-color: var(--primary2);
}
.e-rating__range::-moz-range-thumb {
	background-color: var(--primary1);
	border: 0;
	border-radius: 50%;
	width: 1.5em;
	height: 1.5em;
	transition: background-color 0.15s linear;
}
.e-rating__range:focus::-moz-range-thumb,
.e-rating__range::-moz-range-thumb:hover {
	background-color: var(--primary2);
}
.e-rating__faces {
	justify-content: space-between;
	margin-bottom: 1.5em;
	width: 100%;
}
.e-rating__face,
.e-rating__face:after {
	border-radius: 50%;
	transition:
		background-color var(--trans-dur),
		transform var(--trans-dur) cubic-bezier(0.42,0,0.58,1);
}
.e-rating__face {
	background-color: hsl(50,90%,55%);
	position: relative;
	width: 3em;
	height: 3em;
}
.e-rating__face:after {
	background-color: hsla(0,0%,0%,0.2);
	content: "";
	display: block;
	position: absolute;
	bottom: -0.125em;
	left: calc(50% - 1em);
	width: 2em;
	height: 0.25em;
	transform: translateY(0.........完整代码请登录后点击上方下载按钮下载查看

网友评论0