HTML5+CSS3炫酷登录页

下面是一个使用CSS3制作炫酷登录页的示例代码:

HTML部分:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>CSS3炫酷登录页</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <form>
            <h1>Login</h1>
            <input type="text" placeholder="Username">
            <input type="password" placeholder="Password">
            <button type="submit">Login</button>
        </form>
    </div>
</body>
</html>

CSS部分:

* {
    
    
    box-sizing: border-box;
}
body {
    
    
    margin: 0;
    padding: 0;
    background: #333;
    font-family: 'Open Sans', sans-serif;
}
.container {
    
    
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}
form {
    
    
    width: 400px;
    padding: 40px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    position: relative;
}
h1 {
    
    
    font-size: 2em;
    text-align: center;
    margin-bottom: 40px;
    color: #333;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}
input {
    
    
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: none;
    border-radius: 5px;
    background: #f2f2f2;
    font-size: 1em;
    color: #333;
}
button[type="submit"] {
    
    
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: #2980b9;
    font-size: 1.2em;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    position: relative;
    z-index: 1;
    overflow: hidden;
}
button[type="submit"]:before {
    
    
    content: "";
    width: 0;
    height: 100%;
    background: #3498db;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: -1;
    transition: all 0.3s ease-in-out;
}
button[type="submit"]:hover:before {
    
    
    width: 100%;
}

在上面的代码中,我们使用了CSS3的box-shadow属性来添加阴影效果,使得登录框看起来更加立体。同时,我们使用了background属性、border-radius属性和text-shadow属性来美化页面元素。最关键的是,我们使用了CSS3的::before伪元素来创建一个悬浮的蓝色背景,通过动态修改其宽度来实现炫酷的登录按钮效果。

效果如下:

炫酷登录页

猜你喜欢

转载自blog.csdn.net/dica54dica/article/details/130191860