Form design featuring inline radio buttons and text fields arranged horizontally

I am struggling to arrange a radio button with two text fields in a horizontal form using Bootstrap. Unfortunately, I can't embed the image for reference.

Despite my efforts in using Jade markup, I haven't been able to achieve the desired layout:

    .col-sm-4
        .form-group
            label.control-label(for='time') Time Range
            .form-inline
                .form-group
                    input(type='radio', id="from", name='time', value='from', data-toggle='radio')
                    label(for="from") From
                .form-group
                    input(type='text', name='first')
                .form-group
                    input(type='text', name='last')

My current implementation causes everything to be on one line, covers up the "From" label entirely, and places the two text boxes side by side without any spacing. Is this issue something that can be resolved through CSS adjustments, or have I misunderstood how form layouts work in Bootstrap 3? Any guidance would be greatly appreciated.

EDIT: The resulting HTML code is as follows:

<div class="form-group"> 
<label for="time" class="control-label">Time Range</label>
<div class="form-inline">
   <div class="form-group">
       <input type="radio" id="from" name="time" value="from" data-toggle="radio">
       <label for="from">From</label>
   </div>
   <div class="form-group">
         <input type="text" name="first">
   </div>
   <div class="form-group">
        <input type="text" name="last">
   </div>
</div>
</div>

Answer №1

Here is a suggestion for the layout:

<div class="form-inline">
   <label for="time" class="control-label">Select Time Range</label>
   <div class="form-group">
       <input type="radio" id="from" name="time" value="from" data-toggle="radio">
       <label class="control-label" for="from">From</label>
   </div>
   <div class="form-group">
        <input class="form-control" type="text" name="first">
   </div>
   <div class="form-group">
        <label class="control-label">To</label>
        <input class="form-control"  type="text" name="last">
   </div>
</div>

Check out this live demo

I'm unsure how to convert this into Jade markup, but I trust you'll figure it out :)

Update: This is the conversion generated by an online tool:


  .form-inline
      label.control-label(for='time') Select Time Range
      .form-group
        input#from(type='radio', name='time', value='from', data-toggle='radio')
        label.control-label(for='from') From
      .form-group
        input.form-control(type='text', name='first')
      .form-group
        label.control-label To
        input.form-control(type='text', name='last')

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

Guide to importing external CSS styles into Angular 2 using the require method

I'm facing an issue with loading an external css file in different environment files. My setup includes two environments: development and production. Loading the css file locally works fine in development mode, but not in production mode. environment ...

Why has my dropdown menu decided to go horizontal, rather than dropping down as it should?

Hi there! I'm new to css and tried following a tutorial with some tweaks. However, when adding a drop down menu using lists, it ended up going sideways instead of downward. Can anyone help me out? I also would like to have a collapsible menu implemen ...

Ensuring the clickable area of the button aligns perfectly with the button itself and adjusting the arrow position to be

Check out the sandbox here: https://codesandbox.io/s/vigilant-currying-h7c3r?file=/styles.css If you are looking for the classes .line and .arrow, they are what you need. When you create an event, notice how the arrows appear too low, with the clickable a ...

activating a button following the selection of a checkbox

My code includes a submit button that is currently disabled. I am looking to enable it when the user clicks on the "I agree" checkbox using jQuery. Can someone assist me with this? My code is written in HTML, JavaScript, and jQuery. <input id="agree" ...

Maintain consistent sidebar height as content changes dynamically

My website has a two-column layout with a sidebar and content section that are both set to equal height when the window loads and resizes. The page is designed to be responsive. To dynamically arrange blocks within the content area, I am utilizing a jQuer ...

The element is being hidden by the Bootstrap visibility utility even though it should be visible

On smaller screen sizes, I want to hide the "Updated: " text and only display the date, which is currently working correctly. However, the issue arises on larger screen sizes where it hides the date and only shows the "Updated: " part in the span. .u-da ...

What is the best way to incorporate a badge into my Bootstrap site?

I am delving into the world of front-end development, starting with a Bootstrap project. However, I have hit a roadblock. I am trying to incorporate badges similar to those in my design, but every attempt throws off the alignment and messes up the layout o ...

Incorporating CSS Styles into an HTML Page

I'm encountering an issue where the CSS layout doesn't load when I try to view the document. Here's the content: <!DOCTYPE html> <html> <head> <body> <title>Waden B. Greaux Jr.</title> & ...

Customizing a responsive background image within a div using Bootstrap 3

Is there a way to style the background image of my header div like the one featured on Mr. Bill Gates' website at ? I noticed that the height of Mr. Bill Gates' header background image remains consistent, even on smaller screens. I've atte ...

Adjusting the line-height in CSS dynamically based on the length of characters using jQuery

I am facing an issue with the Twitter widget on my website where our company's latest tweet sometimes gets cut off if it exceeds a certain length. I want to dynamically adjust the line-height CSS property of the element based on the tweet's chara ...

Centered flex item with a flexbox grid underneath

Looking to create a layout with an intro section on the left side and a sidebar on the right within a container. Below the intro section, I want four divs evenly spaced like a grid. But I'm struggling with setting up this grid, possibly due to flexbo ...

Ribbon design in LESS/CSS does not maintain its structure when resized in Google

My CSS/LESS ribbon is displaying perfectly in Firefox, but encountering issues in Chrome when resizing the window. At 100% zoom, everything looks good, but adjusting the zoom causes elements to become misaligned. To make it easier to troubleshoot, I' ...

IE11 has issues with properly scaling SVG within flexbox

Within my website, I have incorporated various blocks featuring SVG images and text descriptions. To enhance the visual appeal, I aim to make these blocks flexboxes for easy vertical alignment of text, similar to this example: <div class="decorated-fea ...

Automated line wrapping within a div

My goal is to showcase images within a unique div structure. Currently, the arrangement appears as follows: It seems that the green divs are extending beyond their parent div (the black one). This is how it's structured: <div class="photoView c ...

Preventing Div items from rearranging during size transitions using toggleClass

When I click on an element with the ID "id", I use toggleClass to resize a div from 10px to 500px in width. This is done partly to show/hide content. However, the issue arises when the transition occurs and the contents of the div start rearranging, overfl ...

What are the best practices for implementing media queries in Next.js 13.4?

My media queries are not working in my next.js project. Here is what I have tried so far: I added my queries in "styles.module.css" and "global.css" and imported them in layout.js I included the viewport meta tag under a Head tag in layout.js This is how ...

What techniques can be used to prevent a person from zooming using css or html?

I'm attempting to disable the ability to zoom (in or out) on my website. I've tried adding this meta tag: <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> However, it hasn't worked so far... An ...

Creating a JavaScript-powered multi-department form: A step-by-step guide

Is there a way to maintain the form displayed on a webpage created in HTML5 and JavaScript for logging calls across three different departments? With buttons assigned to each department, clicking on them reveals the respective HTML form. That said, every t ...

Steps to implement a text border in Raphael.js

I have a website dedicated to creating customized football jersey designs. I'm utilizing Raphael.js for customization, and I am looking for a way to add an outline to text using Raphael. My research led me to the suggestion of using the stroke proper ...

When using the overflow:scroll property, the slider gif fails to appear on

I recently added a floating gif along with a slide out form to collect lead information. The setup works perfectly, but I noticed that on lower resolution screens, the form gets cut off. To address this issue, I considered adding a scroll bar. However, whe ...