Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

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

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:

.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:

.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%);
}
question from:https://stackoverflow.com/questions/65649274/contact-form-not-working-correct-html-css

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm not sure why this worked, I changed "email" to "emailaddress" in the div and its working fine now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...