css使用radio与has实现星级评分效果代码

代码语言:html

所属分类:星级评分

代码描述:css使用radio与has实现星级评分效果代码

代码标签: css radio has 星级 评分

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">




    <style>
        @import url("https://fonts.googleapis.com/css2?family=Poppins&display=swap:400,100,500,300italic,500italic,700italic,900,300");
        body {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 100vw;
          height: 100vh;
          margin: 0;
          padding: 0;
          font-family: "Poppins";
          background: gray;
        }
        
        fieldset {
          display: flex;
          justify-content: space-around;
          align-items: center;
          border-style: solid;
          border-color: black;
          border-width: 10px 25px;
          border-radius: 15px;
          position: relative;
          font-size: 2rem;
          padding: 0;
          margin: 0;
          width: 180px;
          height: 50px;
          background: black;
        }
        
        fieldset:before,
        fieldset:after {
          content: '★★★★★';
          position: absolute;
          left: 0;
          display: flex;
          letter-spacing: 0.25rem;
          color: white;
        }
        
        fieldset:after {
          content: '★';
          color: gold;
          mix-blend-mode: multiply;
        }
        
        fieldset:has(input[value='1']:checked):after {
          content: '★';
        }
        
        fieldset:has(input[value='2']:checked):after {
          content: '★★';
        }
        
        fieldset:has(input[value='3']:checked):after {
          content: '★★★'.........完整代码请登录后点击上方下载按钮下载查看

网友评论0