Creating a form that seamlessly integrates with the content using a combination

As I continue to explore the depths of WordPress and delve into learning HTML/CSS, my latest project involves embedding an email signup form on my website using Klaviyo. The basic code provided by their form creator initially had everything condensed into one line, with the addition of a Zip Code form courtesy of yours truly.

<DOCTYPE! html>
<html>
<head>
    <title></title>
    <style type="text/css">
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG,
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG {
          font-family: Arial;
        }
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG label,
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG label {
          color:#222;
        }
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG input[type=text],
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG input[type=email],
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG input[type=text],
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG input[type=email] {
          border-radius: 3px;
        }
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG .klaviyo_submit_button,
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG .klaviyo_submit_button {
          background-color:#F10382;
          border-radius: 3px;
        }
        .klaviyo_styling.klaviyo_condensed_embed_MMaJiG .klaviyo_submit_button:hover,
        .klaviyo_condensed_styling.klaviyo_condensed_embed_MMaJiG .klaviyo_submit_button:hover {
          background-color:#222222;
        }
    </style>
</head>

<body>
    <form id="email_signup" class="klaviyo_condensed_styling klaviyo_condensed_float klaviyo_condensed_embed_MMaJiG" action="//manage.kmail-lists.com/subscriptions/subscribe" data-ajax-submit="//manage.kmail-lists.com/ajax/subscriptions/subscribe" method="GET" target="_blank" novalidate="novalidate" style="margin-left: 50%">
        <input type="hidden" name="g" value="MMaJiG">
        <div class="klaviyo_field_group">
            <label for="k_id_email">Newsletter Sign Up</label>
            <input type="email" value="" name="email" id="k_id_email" placeholder="Your Email"/>
            <input type="number" value="" name="zip" id="k_id_zip_code" placeholder="Your Zip Code"/>
        </div>
        <div class="klaviyo_messages">
            <div class="success_message" style="display:none;"></div>
            <div class="error_message" style="display:none;"></div>
        </div>
        <div class="klaviyo_form_actions">
            <button type="submit" class="klaviyo_submit_button">Subscribe</button>
        </div>
    </form>
    <script type="text/javascript" src="//www.klaviyo.com/media/js/public/klaviyo_subscribe.js"></script>
        <script type="text/javascript">
        KlaviyoSubscribe.attachToForms('#email_signup', {
        hide_form_on_success: true
        });
    </script>
</body>

My goal is to have all form fields (email and zip code) as well as the submit button appear in one neat line.

However, the current predicament has presented me with three different views: On the Klaviyo site, it looks like this (grayed out but visible):

https://i.sstatic.net/VppcT.png When loading the raw HTML, it takes this form:

https://i.sstatic.net/hcget.png

And finally, on my own website:

https://i.sstatic.net/BpKWN.png

Answer №1

The probable cause is that the div elements within the form are set as block elements, causing them to automatically stretch to 100% width and stack vertically.

To address this issue, you can modify all these divs to be inline-blocks using the following CSS rule (allowing them to align horizontally if space allows):

form#email_signup > div {
  display: inline-block;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Show the chosen choice in a select dropdown with custom text using Angular

I successfully implemented this code snippet to display a dropdown list of countries and their phone codes. However, I encountered an issue where I need to only show the selected option's code without the country name. The first screenshot shows how i ...

Enhancing Image Quality in Internet Explorer 10

Here is my current situation: I am working on a web page with a responsive design. The layout of the page consists of two vertical halves, and I intend to display an image (specifically a PDF page converted to PNG or JPG) on the right side. The challenge ...

Tips for aligning elements of varying heights

Currently, I am tackling a responsive web design challenge involving floating multiple items in 4 columns side by side. The issue arises due to the varying heights of these items, causing the floating to behave improperly. Here is the current problem illu ...

Is it possible to directly add a child in HTML from nodejs?

I'm in the process of developing a chat application that requires users to select a room from a list of available rooms stored in <datalist> options, which are fetched from a SQL table on the server. Within my login.html file, users are prompte ...

Enhancing User Interaction with Bootstrap Input Forms

Struggling with a CSS and Bootstrap issue, I am unable to find a solution. The problem I am facing is that the content in a div form is not responsive within its parent div. It always extends beyond the parent div and does not adjust its size when the scre ...

How can I turn off shadows for every component?

Is it feasible to deactivate shadows and elevation on all components using a configuration setting? ...

Enhancing image search functionality through dynamic HTML updates

I need help figuring out how to update the link address for profile pictures on my NHL stats website. Currently, I am using a script to append the image to the body, but I don't know how to properly add the player ID ({{p1_ID}}) to the link and includ ...

Issue with long text in a resizable table using jQuery tablesorter 2.31.1

My issue is that when I try to resize the columns in tablesorter, they snap back into place. The column width set with resizable_widths does not apply correctly until a column is manually resized. Despite setting the width of all cells to 120px, any cells ...

Trouble with jQuery click event on dynamically generated elements

I have a jQuery function that iterates through each element inside a specified div (#container) and triggers a JavaScript alert whenever a span is clicked. Everything functions correctly when the spans are static. However, when I include code like this: ...

What methods can I utilize to transmit Global variable data from a view to a controller?

In my Angular view file, I have the following code snippet. <!DOCTYPE html> <video id="myVideo" class="video-js vjs-default-skin"></video> <script> var dataUri; var videoData; var player = videojs("myVideo", { controls ...

Prevent table headers from scrolling in Bootstrap Vue by following these steps

Just starting out with bootstrap vue and I've been using version 1.4 for my application. I've utilized b-table for displaying my data, but I'm encountering a problem where the table headers also scroll along with the content. I'd like t ...

Generate schemas for form arrays and nested form groups with ease using Yup, Formik, and Material-UI in your React application

I have a yup schema generator that works fine but struggles with handling Form Arrays and Nested Form Groups. Yup Schema Generator const generateYupSchema = (schema, config)=> { if (config.validation) { const { validationType, validations = [] } ...

Customizing the primary CSS style of an element without the need to individually reset every property

Is there a way to reset just one property of a selector that has multiple properties stored in main.css, without listing all the properties and setting them to default values? I always struggle with CSS interference and constantly need to reset properties ...

Child Theme setup in progress! Beware of the error message: "Unable to access file: file_get_contents9(). The specified stream does not exist."

I am currently in the process of developing a child theme based on my existing theme (Tesseract 2). I have carefully followed the guidelines outlined here, but unfortunately, I keep encountering the following error: Warning: file_get_contents(/home/fletch ...

What could be causing the remove attribute API to not function properly only for the "is" attribute?

var divElement = document.createElement("div"); var innerHTMLText = "<div id='issue' is='if'> some content </div>"; divElement.innerHTML = innerHTMLText; document.body.appendChild(divElement); var newDivElement = document.qu ...

In Safari, my layout is disrupted by the mere mention of the word 'City'

There's something strange happening in Safari that I can't quite figure out. Here's how my layout looks in Chrome: https://i.sstatic.net/lPhnP.png But when viewed in Safari, it looks like this: https://i.sstatic.net/IMnQb.png For some r ...

Display additional information in a sidebar when hovering over it

I stumbled upon a sidebar code that caught my interest: #sidebar { position: fixed; z-index: 10; left: 0; top: 0; height: 100%; width: 60px; background: #fff; border-right: 1px solid #ddd; text-align: center; } #sidebar a { text-d ...

CSS descendant selector add style excluding child elements

My issue involves two divs each containing a table. When I apply the CSS class "table" to the first div, the second table in the div is impacted as well. .tbl-generic th:nth-child(-n+2),td:nth-child(-n+2) { background-color:red; width:25px; } ...

Unable to trigger JavaScript function from ASP.NET MVC HTML view

I am encountering an issue with my ASP.NET MVC project where I am attempting to call a JavaScript function to record a user's selection from a listbox. Despite duplicating the JavaScript function in multiple places, it is still not being found. What c ...

Move the option from one box to another in jQuery and retain its value

Hey guys, I need some assistance with a jQuery function. The first set of boxes works perfectly with the left and right buttons, but the second set is not functioning properly and doesn't display its price value. I want to fix it so that when I click ...