Jump to content

Custom Form CSS Messing up Formatting

Go to solution Solved by tuanphan,

Recommended Posts

Hello!

So I'm working on a form for my website and have used CSS to replace the "required" description with an asterisk (not my own code, I found it on a blog somewhere that I can't remember now). The problem is that now my form entry fields are not in line with one another, and there is a big space between the field title and the asterisk. It's a small thing but it's driving me crazy! How can I fix this?

image.thumb.png.c1ad3fed59eb5162f124d86645d8ea77.png

Here is the code I have right now for the asterisk addition: 

.form-wrapper .react-form-contents .field-list .title .required, .form-wrapper .react-form-contents .field-list .fields .description.required {
  visibility: hidden;  
}
.form-wrapper .react-form-contents .field-list .title .required:before, .form-wrapper .react-form-contents .field-list .fields .description.required:before {
  visibility: visible;  
  content: "*"; 
  font-family: Arial;
  font-size: 1.5em;
  line-height: 0em;
  color: #f46c5e;
}
.form-wrapper .react-form-contents--submitted .required:before {
  visibility: hidden!important;
}

Thanks so much!!!

Link to comment
  • Replies 7
  • Views 294
  • Created
  • Last Reply

Top Posters In This Topic

On 5/12/2024 at 1:11 AM, phiacat said:

Thank you for responding! The site is still under construction so I haven't linked a domain yet, but here is the link: https://halibut-denim-2zw3.squarespace.com/lets-talk

What is password?

image.png.0a839b64c008ae9378ddbeaa6a0a7e34.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

What I'm trying to do is fix the alignment of the top two fields. If you look at this image (red dotted lines), they are not matching up correctly. 

I also would love to get the asterisk to be closer to the name of the field (pink circle). I'd like it to look more like this in terms of spacing, if possible:

Email * 

image.png.14ecd15f4237266cd27ada409a601180.png

Like I said, they are small adjustments but are making me a little crazy. 

Thank you for your responses so far and I'd appreciate any tips you can provide 🙂

 

Link to comment
  • Solution

Try remove your code and use this code to Website > Website Tools > Code Injection > Footer to rename (required) to *

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  window.addEventListener("load", (event) => {
    $("span.description.required").html(function() { 
          return $(this).html().replace("(required)", "*");  
    });
});
</script>
<style>
  span.description.required {
    color: red !important;
    opacity: 1 !important;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.