HTML+CSS 水滴登录页

2,296 阅读6分钟

效果演示

图片

实现了一个水滴登录页的效果。页面包含一个水滴形状的登录框和两个按钮,登录框包括用户名、密码和登录按钮,按钮分别为忘记密码和注册。整个页面的设计非常有创意,采用了水滴形状和渐变色的设计,使得页面看起来非常美观和舒适。同时,登录框和按钮的动态效果也增强了页面的交互性和视觉效果。

Code

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>水滴登录页</title>
    <link rel="stylesheet" href="./68-水滴登录页.css">
</head>

<body>
    <div class="box">
        <div class="content">
            <h2>登录</h2>
            <div>
                <input type="text" placeholder="请输入用户名">
            </div>
            <div>
                <input type="password" placeholder="请输入密码">
            </div>
            <div>
                <input type="submit" value="登录">
            </div>
        </div>
        <a href="#" class="btns">忘记密码</a>
        <a href="#" class="btns register">注册</a>
    </div>
</body>

</html>
CSS
* {
    margin0;
    padding0;
    box-sizing: border-box;
}

body {
    height100vh;
    background#eff0f4;
    overflow: hidden;
}

.box {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin150px auto;
    width470px;
}

.box .content {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width350px;
    height350px;
    padding60px 20px;
    box-shadow: inset 20px 20px 20px rgba(0000.05),
        25px 35px 20px rgba(0000.05), 25px 30px 30px rgba(0000.05),
        inset -20px -20px 25px rgba(2552552550.9);
}

.box .content {
    border-radius52% 48% 33% 67% / 38% 45% 55% 62%;
    transition0.5s;
}

.box .content:hover {
    border-radius50%;
}

.box .content::before {
    content"";
    position: absolute;
    top50px;
    left85px;
    width35px;
    height35px;
    border-radius50%;
    background#fff;
    opacity0.9;
}

.box .content::after {
    content"";
    position: absolute;
    top90px;
    left110px;
    width15px;
    height15px;
    border-radius50%;
    background#fff;
    opacity0.9;
}

.box .content div {
    position: relative;
    width225px;
    border-radius25px;
    box-shadow: inset 2px 5px 10px rgba(0000.1),
        inset -2px -5px 10px rgba(2552552551),
        15px 15px 10px rgba(0000.05), 15px 10px 15px rgba(0000.025);
}

.box .content div::before {
    content"";
    position: absolute;
    top8px;
    left50%;
    transformtranslateX(-50%);
    width65%;
    height5px;
    backgroundrgba(2552552550.5);
    border-radius5px;
}

.box .content input {
    width100%;
    border: none;
    outline: none;
    background: transparent;
    font-size16px;
    padding10px 15px;
}

.box .content input[type="submit"] {
    color#fff;
    cursor: pointer;
}

.box .content div:last-child {
    width120px;
    background#ff0f5b;
    box-shadow: inset 2px 5px 10px rgba(0000.1),
        15px 15px 10px rgba(0000.05), 15px 10px 15px rgba(0000.025);
    transition0.5s;
}

.box .content div:last-child:hover {
    width150px;
}

.btns {
    position: absolute;
    right0;
    bottom0;
    width120px;
    height120px;
    background#c61dff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    color#fff;
    font-size14px;
    box-shadow: inset 10px 10px 10px rgba(19012540.05),
        15px 25px 10px rgba(19012540.1), 15px 20px 20px rgba(19012540.1),
        inset -10px -10px 15px rgba(2552552550.5);
    border-radius44% 56% 65% 35% / 57% 58% 42% 43%;
}

.register {
    bottom150px;
    right0px;
    width80px;
    height80px;
    border-radius49% 51% 52% 48% / 63% 59% 41% 37%;
    background#01b4ff;
    box-shadow: inset 10px 10px 10px rgba(11802550.05),
        15px 25px 10px rgba(11802550.1), 15px 20px 20px rgba(11802550.1),
        inset -10px -10px 15px rgba(2552552550.5);
}

.btns::before {
    content"";
    position: absolute;
    top15px;
    left30px;
    width20px;
    height20px;
    border-radius50%;
    background#fff;
    opacity0.45;
}

.register::before {
    left20px;
    width15px;
    height15px;
}

.btns {
    transition0.25s;
}

.btns:hover {
    border-radius50%;
}

实现思路拆分

* {
    margin0;
    padding0;
    box-sizing: border-box;
}

重置所有元素的默认样式。

body {
    height100vh;
    background#eff0f4;
    overflow: hidden;
}

设置页面的背景颜色和尺寸。

.box {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin150px auto;
    width470px;
}

设置登录表单容器的布局、位置和尺寸。

.box .content {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width350px;
    height350px;
    padding60px 20px;
    box-shadow: inset 20px 20px 20px rgba(0000.05),
        25px 35px 20px rgba(0000.05), 25px 30px 30px rgba(0000.05),
        inset -20px -20px 25px rgba(2552552550.9);
}

设置登录表单内容的样式,包括3D效果和过渡动画。

.box .content::before {
    content"";
    position: absolute;
    top50px;
    left85px;
    width35px;
    height35px;
    border-radius50%;
    background#fff;
    opacity0.9;
}

.box .content::after {
    content"";
    position: absolute;
    top90px;
    left110px;
    width15px;
    height15px;
    border-radius50%;
    background#fff;
    opacity0.9;
}

创建伪元素以增强水滴效果。

.box .content div {
    position: relative;
    width225px;
    border-radius25px;
    box-shadow: inset 2px 5px 10px rgba(0000.1),
        inset -2px -5px 10px rgba(2552552551),
        15px 15px 10px rgba(0000.05), 15px 10px 15px rgba(0000.025);
}

设置输入框容器的样式,包括阴影和边框圆角。

.box .content input {
    width100%;
    border: none;
    outline: none;
    background: transparent;
    font-size16px;
    padding10px 15px;
}

设置输入框的基本样式。

.box .content input[type="submit"] {
    color#fff;
    cursor: pointer;
}

为提交按钮设置特定的样式。

.btns {
    position: absolute;
    right0;
    bottom0;
    width120px;
    height120px;
    background#c61dff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    color#fff;
    font-size14px;
    box-shadow: inset 10px 10px 10px rgba(19012540.05),
        15px 25px 10px rgba(19012540.1), 15px 20px 20px rgba(19012540.1),
        inset -10px -10px 15px rgba(2552552550.5);
    border-radius44% 56% 65% 35% / 57% 58% 42% 43%;
}

设置忘记密码和注册按钮的样式,包括3D效果、阴影和过渡动画。

.register {
    bottom150px;
    right0px;
    width80px;
    height80px;
    border-radius49% 51% 52% 48% / 63% 59% 41% 37%;
    background#01b4ff;
    box-shadow: inset 10px 10px 10px rgba(11802550.05),
        15px 25px 10px rgba(11802550.1), 15px 20px 20px rgba(11802550.1),
        inset -10px -10px 15px rgba(2552552550.5);
}

为注册按钮设置特定的样式。

.btns::before {
    content"";
    position: absolute;
    top15px;
    left30px;
    width20px;
    height20px;
    border-radius50%;
    background#fff;
    opacity0.45;
}

.register::before {
    left20px;
    width15px;
    height15px;
}

.btns {
    transition0.25s;
}

.btns:hover {
    border-radius50%;
}

为按钮添加悬停效果和装饰性伪元素。