初学html,任务2:写一个简单的登陆/注册界面

先在body中把最基础的标签写出来

现在页面运行出来是这样的

就是一个没有任何样式的基础界面:

接下来我们为这些标签加上样式

首先还是让页面所有元素的padding和margin都设置为0,

清除浏览器本身对界面的影响:

然后加上背景图,并且将字体设置为微软雅黑

接下来给整个登陆框设置样式

并且让登陆框绝对居中,会使用到绝对位置属性

给h1标签加上样式

给两个输入框设置样式,border给输入框设置边框线样式、粗细和颜色;

border-radius属性给边框设置圆角角度,像素越接近10,弧度越大

给登陆和注册按钮设置样式,

样式设置完,界面就是这样的

 

代码实现如下

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>登录</title>
<style>
*{margin:0;
padding:0;
box-sizing:border-box;
}
body {
    background: url(./img/timg.jpg) no-repeat center 0px fixed;
    background-size: cover;
    font-family: "微软雅黑", sans-serif;
}
.login { 
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -150px 0 0 -150px;
    width:300px;
    height:300px;
}
.login h1 { 
    color:#555555;
    text-shadow: 0px 10px 10px #CDC673;
    letter-spacing:2px;text-align:center;
    margin-bottom:20px;
}
input{
    padding:10px;
    width:100%;
    color:white;
    margin-bottom:10px;
    background-color:#555555;
    border: 1px solid black;
    border-radius:5px;
    letter-spacing:2px;
}
form button{
    width:100%;
    padding:10px;
    margin-bottom:10px;
    background-color:#CDC673;
    border:1px solid black;
    border-radius:5px;
    cursor:pointer; 
}                                                                                                                                       
</style>
</head>
<body>
<div class="headtop"></div>
<div class="login">
  <h1>Login</h1>
    <form action="" method="post">
    <input type="text" name="user" placeholder="用户名" required="required">
    <input type="password" name="password" placeholder="密  码" required="required">
    <button type="submit">登录</button>
    <button type="submit" onclick="location='zhuce.html'">注册</button>
  </form>
</div>
</body>
</html>

若要实现页面跳转可以加入a标签,使跳转到注册界面。

 

转载于:https://www.cnblogs.com/SiminL0708/p/9115012.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值