我正在学习前端,我正在尝试从前端发起挑战,它还包括一些表单验证。因此,每当用户提交表单时,如果任何输入字段为空,输入中应出现一个小错误图像,并且输入下方还应有一行说明输入字段不应为空。
因此,当出现错误时,会出现图像和线条,但我的表格高度会增加。我给了 body 和封闭的容器一个最小高度,但它仍然不工作..
挑战链接 挑战链接
代码笔链接代码笔
代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<title>Frontend Mentor | Intro component with sign up form</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
</head>
<body>
<div class="container">
<div class="left">
<h1> Learn to code by watching others</h1>
<p>See how experienced developers solve problems in real-time. Watching scripted tutorials is great,
but understanding how developers think is invaluable. </p>
</div>
<div class="right">
<div class="heading">
<p>Try it free 7 days <span>then $20/mo. thereafter</span></p>
</div>
<form action="#">
<div>
<input type="text" placeholder="First Name">
<img class="error-image" src="images/icon-error.svg" alt="">
<p class="error-text">First Name cannot be empty</p>
</div>
<div>
<input type="text" placeholder="Last Name">
<img class="error-image" src="images/icon-error.svg" alt="">
<p class="error-text">Last Name cannot be empty</p>
</div>
<div>
<input type="text" placeholder="Email Address">
<img class="error-image" src="images/icon-error.svg" alt="">
<p class="error-text">Looks like this is not an email</p>
</div>
</form>
</div>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
相关分类