Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How to resize and center an email form and thankyou page?

Solved by Delon View solution

Started by Delon 6 years ago · 2 replies · 978 views
6 years ago

Hi all

I'm trying to add an email from to my page. I think I've most of it setup correctly.

I wanted to ask, how can I make it center to the page with limited length rather than spanning the entire lengh of the screen?

Also, how can I customise the thank you screen. I've created the thankyou folder with the formdata.mp page in it but I not sure how to customise it. Also, it's spans the length of the screen and is not centered, please could you advice here on how to do this?

Thanks.

6 years ago

@daredevil, The following is only a rough example on how you can make a form narrower and centered in your screen. There are more roads that lead to Rome and this is just one of them...

And the result might not be entirely to your liking, but it should give you some idea of how to proceed.

Assumptions:

  • Your form is called 'contact'
  • Your inherited theme is called 'mytheme'

In your inherited theme, do the following:

  • Add the following to /user/themes/mytheme/css/custom.css

    CSS
    #contact, .thankyou {
    margin: 0 auto;    /* this will center the element */
    /* by default element will take the full width of the grid */
    }
    
    @media screen and (min-width: 768px) {
    /* When width of screen is >= 768px */
    #contact, .thankyou {
       max-width: 66%;   /* the element will occupy 2/3 of grid */
    }
    }
    @media screen and (min-width: 1024px) {
    /* When width of screeen is >= 1024px */
    #contact, .thankyou {
        max-width: 50%;  /*    /* the element will occupy 1/2 of grid */
    }
    }
    
  • Copy file /user/plugins/forms/templates/formdata.html.twig to folder /user/themes/mytheme/templates/
  • In formdata.html.twig wrap the content of {% block content %} in a <div>. The wrapper is needed to resize and center the output of the 'thankyou ' page.

    TWIG
    {% block content %}
     <div class="thankyou">  
        {{ content|raw }}
    
        {% if form %}
           {% include 'partials/form-messages.html.twig' %}
    
           <p>{{ 'PLUGIN_FORM.DATA_SUMMARY'|t }}</p>
    
           {% include "forms/data.html.twig" %}
       {% else %}
          <div class="notices warning yellow">
             <p>{{ 'PLUGIN_FORM.NO_FORM_DATA'|t }}</p>
          </div>
       {% endif %}
    
     </div>
    {% endblock %}
    

Tweak the above css to your own liking and have fun with it!

👍 1
6 years ago Solution

@pamtbaau:

CSS
#contact, .thankyou {
  margin: 0 auto;    /* this will center the element */
  /* by default element will take the full width of the grid */
}

@media screen and (min-width: 768px) {
  /* When width of screen is >= 768px */
  #contact, .thankyou {
     max-width: 66%;   /* the element will occupy 2/3 of grid */
  }
}
@media screen and (min-width: 1024px) {
  /* When width of screeen is >= 1024px */
  #contact, .thankyou {
      max-width: 50%;  /*    /* the element will occupy 1/2 of grid */
  }
}

Thanks very much, I'll give it a go, you really are helping me, hopefully soon I'll have a good grip on all this.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 101 17 hours ago
General · by pamtbaau, 22 hours ago
1 68 22 hours ago
General · by Andy Miller, 1 day ago
0 53 1 day ago
General · by Marcel, 12 months ago
6 361 5 days ago
General · by Duc , 6 days ago
3 49 6 days ago