请耐心等待,因为我是学习PHP的新手。我正在尝试制作一张如下图所示的注册表格:
到目前为止,我所做的就是:
我不知道如何在左侧添加该图片。这是我的代码:
<?php require_once 'indexheader.php'; ?>
<!DOCTYPE html>
<html>
<head>
<title>Leafnote | Register</title>
<link rel="stylesheet" type="text/css" href="styles.css" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 m-auto">
<div class="card bg-white mt-5">
<div class="card-title text-black">
<h5 class="text-center py-2 font-weight-bold mb-0 mt-2">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
<a href="signup.php" class="alert-link">Login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
您可以在卡上使用Bootstrap网格
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="col-lg-6 m-auto">
<div class="card bg-white mt-5 p-2">
<div class="row">
<div class="col-4 my-auto mx-auto"> <img src="https://www.w3schools.com/bootstrap/la.jpg" class="img-fluid"></div>
<div class="col-8 mx-auto my-auto">
<div class="card-title text-black">
<h5 class="text-center py-2 font-weight-bold mb-0 mt-2">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
<a href="signup.php" class="alert-link">Login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
尝试使用Bootstrap中可用的display: flex;
,它比在列中添加更多的CSS样式来对齐,从而提供了更大的灵活性来对齐中心的项目。希望此示例代码有帮助
<div class="container">
<div class="row">
<div class="col-lg-4 m-auto">
<div class="card d-flex flex-row align-items-center justify-content-center bg-white mt-5">
<img class="mx-4" src="https://via.placeholder.com/150">
<div class="d-flex flex-column flex-grow-1">
<div class="card-title text-black align-self-baseline">
<h5 class="text-center py-2 font-weight-bold mb-0 mt-2">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
<a href="signup.php" class="alert-link">Login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
答案 2 :(得分:0)
您需要在此处执行的操作是,在您现有的旁边添加另一个col(umn)。
它看起来像这样:
<div class="container">
<div class="row">
<div class="col">
<img width='100%' src='https://upload.wikimedia.org/wikipedia/commons/c/c0/Nicolas_Cage_Deauville_2013.jpg'/>
</div>
<div class="col">
<div class="card bg-white mt-5">
<div class="card-title text-black">
<h5 class="text-center py-2 font-weight-bold mb-0 mt-2">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
<a href="signup.php" class="alert-link">Login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
您可能需要稍微使用CSS才能使图像看起来不错。 请参阅文档以了解有关Bootstrap网格系统的详细信息:https://getbootstrap.com/docs/4.0/layout/grid/
答案 3 :(得分:0)
我认为您需要带有左侧图像的引导卡代码。
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 m-auto">
<div class="card flex-row flex-wrap">
<div class="card-header border-0">
<img src="https://www.placehold.it/200" alt="">
</div>
<div class="card-block px-2">
<h4 class="card-title">Title</h4>
<p class="card-text">Description</p>
<a href="#" class="btn btn-primary">BUTTON</a>
</div>
<div class="w-100"></div>
<div class="card-footer w-100 text-muted">
Footer stating cats are CUTE little animals
</div>
</div>
</div>
<div class="col-lg-6 m-auto">
<div class="card bg-white mt-5">
<div class="card-title text-black">
<h5 class="text-center py-2 font-weight-bold mb-0 mt-2">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
<a href="signup.php" class="alert-link">Login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>