Unresponsive alignment of Button and Paragraph in close proximity

On my website, I have a checkbox button and a paragraph displayed side-by-side. It looks great with inline-block styling: https://i.sstatic.net/ZuyIk.jpg

However, when I switch to a responsive view, the elements drop down to separate lines like this: https://i.sstatic.net/d4NJG.jpg. How can I elegantly resolve this issue using CSS without restructuring the code with additional divs or relying on Bootstrap? Thank you for your help!

Regarding the code, both the button and paragraph are in the left column of two columns.

EDITED FOR CODE ADDITION:

    <div class="row no-pad">
            <div class="col-xs-6 left-hand-input">

                <!--FORM BEGIN-->
                <form class="form-control-static" action="leadGen.php" method="post">
                    <p>PERSONAL DETAILS</p>
                    <hr>
                    <label for="firstName">FIRST NAME:</label><br>
                    <input name="firstName" id="firstName" type="text"><br>
                    <label for="email">EMAIL:</label><br>
                    <input name="email" id="email" type="email">

                    <p>SHIPMENT ADDRESS</p>
                    <hr>
                    <label for="address">ADDRESS:</label><br>
                    <input name="address" id="address" type="text"><br>
                    <label for="country">COUNTRY:</label><br>
                    <input name="country" id="country" type="text"><br>
                    <label for="zip">ZIP CODE:</label><br>
                    <input name="zip" id="zip" type="text"><br>
                    <input type="submit" id="submit" value="SEND">

                    <p style="display: inline-block; vertical-align: -10px;">&nbsp;&nbsp;&nbsp;*Required fields</p><br>
<input checked type="checkbox" id="mailingList"/>
<p style="display: inline-block; font-size: 75%;">&nbsp;&nbsp;&nbsp; 
Receive exclusive membership deals and offers.</p>
                </form>
            </div>

            </div>

Answer №1

It is crucial to implement labels for your form elements.

<label><input type="checkbox" value=" id="mailingList">Opt in to receive exclusive membership deals and offers.</label>

You can view a demonstration on jsfiddle here: https://jsfiddle.net/eo9dr1x5/8/

Consider using col-sm-6 instead of col-xs-6 for better display on smaller screens like the iPhone 4.

Answer №2

If you're looking to enhance the functionality of a checkbox or any other input type element, consider utilizing the label tag instead of a paragraph for a more appropriate choice.

Using a label with the for attribute should work seamlessly.

<div id="container">
 <input type="checkbox" id="toggleButton"> check  
  <label for="toggleButton">
     this content will stay fixed
  </label>
</div>

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

Angular Material Design auto-complete textbox with assertive selection

Presently, I am utilizing Angular Material Design and everything is functioning as expected. However, I am now looking to implement autocomplete (Angular Material Design) in a way that forces the user to always choose an option without the ability to manua ...

detecting syntax errors in CSS with @media queries and keyframes

/*general CSS setting for all device types above hd*/ * { margin: 0; padding: 0; } #watchonly { display: none; } ...

Resolving the problem of degrading image quality in HTML Canvas

Recently, I came across an issue while trying to display graphics on an HTML page using canvas. The problem I encountered was that the canvas element was somehow reducing the quality of my images during rendering, especially after some time. Let me visual ...

What is the best way to populate an HTML array using my AWK script?

In my CGI script written in bash and HTML, I am attempting to display information from multiple CSV files in an HTML array. The following is the script I am using: #!/bin/bash echo "Content-type: text/html" echo "" echo ' <html> <he ...

How can I display a loading indicator in an Angular 7 application while waiting for all API responses to complete?

I have multiple API calls on a page, each with different response times. When the first API call finishes and sets the loading indicator to false, I want to keep the indicator active until all five API calls have responded. Can you provide any suggestions ...

The header and footer elements must be included along with a main div to house the content on the webpage

I am currently working on building a website using HTML and CSS. I would like to create an index.php file that calls all the different parts of the page. For example, I want to include the header and footer, and also have the ability to replace content wit ...

Guide on positioning a div to float from bottom left to top right using CSS as the window screen size is reduced

I am wondering if it is possible to float the div using CSS in the following manner. My goal is to have CSS DIV 2 move under CSS DIV 1 to the right when the window size is reduced. Please refer to the screenshot below: On larger window sizes, three DIVs a ...

jQuery offset(coords) behaves inconsistently when called multiple times

I am attempting to position a div using the jQuery offset() function. The goal is to have it placed at a fixed offset from another element within the DOM. This is taking place in a complex environment with nested divs. What's puzzling is that when I ...

Achieving a Side-Along Sidebar with CSS, Fully Embracing

I'm encountering an issue with achieving 100% height using CSS. Despite my extensive search for tutorials and solutions, I haven't been able to achieve the desired results. My layout consists of a sidebar and a main column where the content will ...

The navigation bar is showing my logo in a blurry and small format when viewed on a desktop

Currently, Twitter Bootstrap is being utilized on my website and a high-resolution logo has been successfully uploaded. The dimensions of the logo are 529 x 100 pixels, and here is the relevant CSS: .navbar-brand { float: left; padding: 12px 15p ...

Tips for customizing the default styles of PrimeNG's <p-accordion> tag

Hello, I have encountered an issue with my html code snippet. I am attempting to create a tab with a label-header named "Users", but the accordion tag consistently displays it as underlined. <div class="ui-g"> <p-accordion id="tabsHeader"> ...

What is the best way to showcase the information stored in Firestore documents on HTML elements?

Currently in the process of designing a website to extract data from my firestore collection and exhibit each document alongside its corresponding fields. Below is the code snippet: <html> <!DOCTYPE html> <html lang="en"> <head> ...

Issue with Displaying Background Image

When trying to set my background image on CDM using document.body.style={mainBg}, I am not getting the expected result. Additionally, the console statement below it is printing out an empty string. Can anyone assist me in identifying what mistake I might b ...

Each function in Sass is compiled with a dollar sign preceding it

I'm having trouble using an each loop in Sass because the css is compiling with the variable names instead of their content. $green-1: #9ae200; $green-2: #5ea600; $color-list: green-1 green-2; @each $single-color in $color-list { &.#{$single ...

Tips for positioning a JQuery drop-down correctly

Although I am not well-versed in JQuery and struggle with CSS, I often find myself working with both. Currently, I have encountered a problem: The jquery script I am using involves clicking on an image to reveal a login box that drops down using slideTogg ...

Is there a way to automatically load data whenever a specific inner div on an HTML page is modified?

On my website, I have created a main page with three divs: header, footer, and main. The header div contains buttons that change the content of the main div when clicked. Rather than reloading the entire page, only the main div is updated with a new HTML p ...

What is the best way to align background shapes within a specific section on a webpage using CSS?

I've been attempting to strategically place multiple shapes in the background using CSS, but I'm facing challenges. While I was successful with my hero section at the top of the page, positioning elements in a section halfway down has proven prob ...

Adding a text stroke to the <input type="text"/> element

    Can anyone provide a solution for implementing text stroke in <input type="text"/> that works across all major browsers (Firefox, Google Chrome, Safari, Opera, IE7+)? Is there any method using CSS 2.1 or jQuery to achieve this effect? ...

Add a custom filter to the active route for a stylish look

I am trying to dynamically change the color of elements in my navbar by creating a filter in my typescript code. I have a string with values like 'greyscale(73%) saturate(1400%)'. How can I apply this string to the fa-icon's filter property ...

I am attempting to center an image on a webpage while disregarding the margins set on the

Bar.html: <!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="customStyle.css" /> </head> <body> The text formatting is spot on. Unfortunately, the following image should be centered, but it's off ...