[英]Contact Form Not Working Correct - HTML/CSS
I got it to work the way I wanted once, but cant seem to make it work again.我让它以我想要的方式工作一次,但似乎无法让它再次工作。 This image shows my desired result, and then what's happening.
这张图片显示了我想要的结果,然后是发生了什么。
https://i.stack.imgur.com/QUCuN.png https://i.stack.imgur.com/QUCuN.png
Why is this happening?为什么会这样?
This is the code that's working for me:这是对我有用的代码:
<div class="form">
<input type="name" name="name" autocomplete="off" required />
<label for="name" class="label-name">
<span class="content-name"> Name </span>
And the CSS styling: CSS 造型:
.content-name {
position: absolute;
bottom: 5px;
left: 0px;
transition: all 0.3s ease;
}
.form input:focus + .label-name .content-name,
.form input:valid + .label-name .content-name {
transform: translateY(-150%);
color: #5fa8d3;
}
.form input:focus + .label-name::after,
.form input:valid + .label-name::after {
transform: translateX(0%);
}
Code that isn't working:不工作的代码:
<div class="form">
<input type="email" name="email" autocomplete="off" required />
<label for="name" class="label-email">
<span class="content-email"> Email </span>
</div>
And the CSS: CSS:
.content-email {
position: absolute;
bottom: 5px;
left: 0px;
transition: all 0.3s ease;
}
.form input:focus + .label-email .content-email,
.form input:valid + .label-email .content-email {
transform: translateY(-150%);
color: #5fa8d3;
}
.form input:focus + .label-email::after,
.form input:valid + .label-email::after {
transform: translateX(0%);
}
I'm not sure why this worked, I changed "email" to "emailaddress" in the div and its working fine now.我不确定为什么会这样,我在 div 中将“电子邮件”更改为“电子邮件地址”,现在它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.