gpt4 book ai didi

html - 格式化登录屏幕

转载 作者:太空宇宙 更新时间:2023-11-04 08:47:47 25 4
gpt4 key购买 nike

我是 HTML 和 CSS 的新手。我也知道这是一个非常基本的问题。我正在尝试创建一个登录前端,我正在使用的代码如下所示。代码仅使用 HTML 和 css 编写

<!DOCTYPE html>
<html>
<head>
<style>
form {
border: 6px solid #f1f1f1;
}

input[type=text]{
width: 100%;
padding: 12px 12px;
margin: 16px 0;
display: inline-block;
border: 2px solid #ccc;
box-sizing: border-box;
}

input[type=password] {
width: 100%;
padding: 12px 12px;
margin: 16px 0;
display: inline-block;
border: 2px solid #ccc;
box-sizing: border-box;
}

button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 10%;
}

button:hover {
opacity: 0.8;
}

.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}

.imgcontainer {
text-align: center;
margin: 12px 40px 12px 0;
}

.container {
padding: 20px;
}

span.psw {
float: right;
padding-top: 16px;
}

</style>
</head>
<body>
<center>
<h2>Inventory Update Interface Login</h2>
</center>
<form method="post">
<div class="container">
<label>
<b>Username</b>
</label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label>
<b>Password</b>
</label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
</div>
</form>
</body>
</html>

但问题是我想让屏幕中央的框和文本字段的长度稍微小一些。提前致谢!

最佳答案

添加这个 CSS

.container{
max-width:600px;
border: 6px solid #f1f1f1;
margin:0 auto;
}

form {}

.container {
max-width: 600px;
border: 6px solid #f1f1f1;
margin: 0 auto;
}

input[type=text] {
width: 100%;
padding: 12px 12px;
margin: 16px 0;
display: inline-block;
border: 2px solid #ccc;
box-sizing: border-box;
}

input[type=password] {
width: 100%;
padding: 12px 12px;
margin: 16px 0;
display: inline-block;
border: 2px solid #ccc;
box-sizing: border-box;
}

button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 10%;
}

button:hover {
opacity: 0.8;
}

.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}

.imgcontainer {
text-align: center;
margin: 12px 40px 12px 0;
}

.container {
padding: 20px;
}

span.psw {
float: right;
padding-top: 16px;
}
<center>
<h2>Inventory Update Interface Login</h2>
</center>
<form method="post">
<div class="container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
</div>
</form>

关于html - 格式化登录屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43655341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com