div+css实现胶囊形状效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现胶囊形状效果代码

代码标签: div css 胶囊 形状

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

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

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


  
  
  
  
<style>
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --width: 6.875rem;
    --height: 25rem;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(
        45deg,
        hsl(289 100% 80% / 0.65),
        hsl(230 60% 50% / 0.65)
    );
}

.pill {
    display: grid;
    place-content: center;
    place-items: center;
    width: var(--width);
    height: var(--height);
    border-radius: 100vh;
    outline: 1px solid hsl(188 6% 70% / 0.6);
    background: linear-gradient(
            to right,
            #00000013 5%,
            #0000 40% 70%,
            #fff1 98%
        )
        hsl(200 40% 95% / 0.7);

    box-shadow: hsla(180, 7%, 40%, 0.3) 0.5em 1.125em 1.25em -0.625em,
        hsla(187, 15%, 36%, 0.38) 0.625em 1.75em 2.5em -0.75em;

    position: relative;
    overflow: hidden;
    isolation: isolate;
}

svg {
    border-radius: inherit;
    position: absolute;
    width: 100%;
    height: 100%;
    mix-blend-mode: difference;
    filter: blur(0.75rem);
}

.pill::after,
.pill::before {
    content: "";
    position: absolute;
    align-self: center;
    width: var(--width);
    border-radius: inherit;
}

.pill::before {
    left: -4rem;
    height: calc(var(--height) * 0.875);
    background: linear-gradient(to left, #0001, #0000 6% 30%, #fff4);
}

.pill::after {
    left: -1rem;
    height: calc.........完整代码请登录后点击上方下载按钮下载查看

网友评论0