用CSS制作登录界面

插入图片的方法

在html代码段的style标签中对直接对body元素进行设置,可以直接插入一张图片作为背景,例如:
    body{background-image:url(G:/test.com/bj.jpg);//url中放置图片的位置地址;
    background-repeat:no-repeat;设置背景重复属性为“不重复”;
    background-size:100% 100%;//修改图片大小使其铺满整个网页;
    background-attachment:fixed;//background-attachment 属性设置为 "fixed",保证该属性在 Firefox 和 Opera 中的正常工作;
    background-opacity:0.1;//设置图片透明度属性opacity,它的取值范围为0.0~1.0,其中值越小表示图片越透明;兼容性:IE9, Firefox, Chrome, Opera 和 Safari 都可以使用;
    filter:alpha(opacity=10);//对于IE8及其之前的版本使用此语句定义透明度。
    }
设置body的背景颜色方法同上例。
好的,以下是一个简单的例子: HTML代码: ```html <!DOCTYPE html> <html> <head> <title>个性化登陆界面</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="container"> <h1>欢迎来到我的网站</h1> <form> <label for="username">用户名:</label> <input type="text" id="username" name="username"> <label for="password">密码:</label> <input type="password" id="password" name="password"> <input type="submit" value="登陆"> </form> </div> </body> </html> ``` CSS代码: ```css body { background-color: #f2f2f2; font-family: Arial, sans-serif; } .container { margin: 100px auto; width: 400px; background-color: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.2); } h1 { text-align: center; color: #333; } form { display: flex; flex-direction: column; } label { margin-top: 10px; margin-bottom: 5px; color: #333; } input[type="text"], input[type="password"] { padding: 10px; border-radius: 5px; border: none; background-color: #f2f2f2; } input[type="submit"] { padding: 10px; border-radius: 5px; border: none; background-color: #007bff; color: #fff; cursor: pointer; transition: background-color 0.3s ease-in-out; } input[type="submit"]:hover { background-color: #0062cc; } ``` 你可以将上述代码保存成两个文件,分别为 `index.html` 和 `style.css`,然后在浏览器中打开 `index.html` 文件,就可以看到个性化的登陆界面了。当然,你可以根据自己的需求对代码进行修改和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值