Creating a form with a background

Hi community,

I have a very little experience with HTML and CSS, however I have been working in HubSpot enviroment for a little while, so I know something from trial and fail. So I want to create a form with an image as a background that spreads across the width of the page. The question would you approach this by creating a custom module with an embed form? If so, can anybody provide me with HTML and CSS of something similiar so I can go from there?

Here is a picture how it should look


How it should look

Hi!
Are you using the design tools to create this element or Local Development?
I can send you the HTML and CSS for this module but the fields are just as important.

Hi Teun

Could you elaborate on the design tools and Local Developement, because I have no clue honestly. I kind of understand that the fields in a custom module are for changing/personalizing stuff in the website manager later on if I am not mistaken. As I said, I have no experience with this but I took on this task at work to see if I could do it.

Hi!
Here is a quick read on the structure of a module:

And here a quick explanation on how to create a module in the Design Tools:

And here about Local Development:

For this module, I would start with creating a module through the Design Tools and invest in Local Development later on.
If you need help with the HTML and CSS, please let me know.

Hi @borkacer ,

So I’ll describe below how I would create this module. I’ll leave out any advanced options or styling, but this should get you going.
Step 1
Create a module in the ‘Design Tools’ (Marketing > Files and templates > Design tools) by clicking on the ‘File’ dropdown on the left side of the screen.

Select ‘Module’ in the popup that shows when you click ‘New file’.
Step 2

Decide what templates you want to use your module in, and give it a recognizable name. You can set it as a ‘global’ module if you want the content to be the same for all pages. If not, select ‘local’ module.

Step 3
Determine the fields you need for this module. Based on your screenshot, I think we need the following:
- Image (for the background, we will set this in the ‘Style Fields’ below the default ‘Fields’)
- Form (for the form, duh)
- Rich text (for the content)
- Choice (for the position of the content (optional)) (Options: left / right)
On the right side of the screen, click on the ‘Add field’ button and select the field types you need. Give them a recognizable name, so you can use that in the code.

You should now have the following fields:

Step 4

Write the necessary HTML for this module. Below is a code snippet that gives you same basic HTML which should help you to create your module:

{% require_css %}
<style>
 {% scope_css %}
 .form-with-content {
 {{ module.style.background.css }}
 }
 {% end_scope_css %} 
</style>
{% end_require_css %}

<section class="form-with-content">
 <div class="form-with-content__container">
 <div class="form-with-content__content form-with-content__content--{{module.position}}">
 {{ module.content }} <!-- this will contain the content set through your 'Content' field -->
 </div>
 <div class="form-with-content__form">
 <!-- Below is the necessary HuBL for the form to show -->
 {% form
 form_to_use="{{ module.form.form_id }}"
 response_response_type="{{ module.form.response_type }}"
 response_message="{{ module.form.message }}"
 response_redirect_id="{{ module.form.redirect_id }}"
 response_redirect_url="{{module.form.redirect_url}}"
 %}
 </div>
 </div>
</section>

Step 5
Write the necessary CSS for the module. I used the Style fields to generate some basic inline styling for the background image. If you want to style the background image yourself, please let me know. Below is some basic styling:

.form-with-content {
 padding: 3rem 0; /* Change this if needed */
}

.form-with-content__container {
 display: flex;
 flex-wrap: wrap;
 align-items: flex-start;
 max-width: 1200px; /* Change this */
 margin: 0 auto;
}

.form-with-content__content,
.form-with-content__form {
 display: block;
 box-sizing: border-box;
 width: 50%;
}

.form-with-content__content {
 padding-right: 3rem; /* Change this */
 /* Add some more styling for the typography if needed */
}

.form-with-content__content--right {
 order: 2; /* Styling based on the 'position' field */
 padding-right: 0;
 padding-left: 3rem; /* Change this if needed */
}

/* styling for mobile, change the pixels if needed */
@media screen and max-width(767px) {
 .form-with-content__content,
 .form-with-content__form {
 width: 100%;
 }

 .form-with-content__content {
 padding-right: 0;
 padding-left: 0;
 padding-bottom: 2rem; /* Change this if needed */
 }

 .form-with-content__content--right {
 padding-bottom: 0;
 padding-top: 2rem; /* Assuming the content is at the bottom on mobile devices */
 }
}

Ofcourse this needs some more work, but this should get you going.