Disarray in the form elements

I'm having trouble positioning my form elements as desired.

I want the recurrence_interval input field to be below the select (recurrence) input field.

My two radio buttons for 'never' and 'on' should be stacked on top of each other, with the input field for ends_on_date below the 'On' checkbox.

Here is my HTML code:

    <div id="dialog" title="Create new appointment">
        <form id="df">
            <label class="align" for="title">Title</label>
            <input type="text" name="title" id="title">
            <label class="align" for="when">When</label>
            <input type="text" name="when" id="when">

            <input id="repeat" type="checkbox">
            <label id="repeat_text" for="repeat">Repeat...</label>
            <div id="repeat_properties">
                <label class="align" for="recurrence">Repeats</label>
                <select id="recurrence">
                    <option value="1">Daily</option>
                    <option value="7">Weekly</option>
                    <option value="repeat-x-days">Every x day</option>
                </select>
                <input id="recurrence_interval" type="text">

                <label class="align" for="ends_never">Ends</label>
                <input id="ends_never" name="endson" type="radio" title="Ends never" checked="checked">
                <label for="ends_never" title="Ends never">Never</label>
                <input id="ends_on" name="endson" type="radio" title="Ends never">
                <label for="ends_never" title="Ends never">On</label>
                <input class="align" id="ends_on_date" type="text">
            </div>
        </form>
    </div>

Here is my CSS code:

.align {
    display: inline-block;
    float: left;
    clear: left;
    width: 30%;
    text-align: left;
}

input[type="text"], input[type="radio"], select {
    display: inline-block;
    float: left;
    clear: right;
}

#repeat
{
    display: inline-block;
    float: left;
    text-align: left;
    clear: left;
}
#repeat_text
{
    float: left;
}

Any suggestions on how I can achieve the desired layout?

Edit: View the issue here, especially in Chrome where the fields appear misaligned.

Answer №1

Revamp your HTML radio structure with this updated code snippet.

<label for="ends_never" title="Ends never"><input id="ends_never" name="endson" type="radio" title="Ends never" checked="checked"> Never</label>
<label for="ends_never" title="Ends never"><input id="ends_on" name="endson" type="radio" title="Ends never"> On</label>
                

edited

Enhance the visual presentation by adding the following styling: label { float: left; }

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

The dropdown menu is currently activated, but not the individual items within it

Is there a way to make the dropdown menu active when I click on an item, specifically making the word Services active? How can this be achieved? <nav class="navbar navbar-light navbar-expand-xl"> <a class="navbar-brand" hre ...

Utilizing jQuery to attach events to dynamically inserted elements in the DOM

I am having an issue with dynamically adding elements to the DOM and then trying to manipulate their behavior using jQuery's .on() function. However, for some reason, the DOM is not triggering the .on() event for these dynamically added elements. You ...

Clipped Words & Silhouettes

I'm having trouble ensuring the text in this particular example displays correctly. I am experiencing challenges with the clipping of text and shadows on certain letters, and I'm struggling to identify the root cause as well as the solution. In ...

node index of data that has been posted

My HTML file is quite straightforward: <form method="post" action="http://localhost:3000/post"> <input name="name" type="text"/><br /> <input name="last_name" type="text"/><br /> <button id="submit" type="submit"& ...

Tips on displaying an avatar above and outside the boundaries of a background element using Chakra UI

They say a picture is worth more than a thousand words, and in this case, it holds true. The best way to illustrate what I'm trying to accomplish is through the image linked below. https://i.stack.imgur.com/5WvkV.png I envision having the avatar po ...

Tips for eliminating any default white space visible between tags:

What is the best way to eliminate white space gaps between div tags and adjust pixel differences between them in HTML code? My current alignment is off and there are noticeable white spaces between div tags. I have tried using a reset link but it didn&apo ...

Scroll up and down to witness the enchanting interplay of fading in and out

Looking to expand upon the solution given in this response. The existing code effectively fades in an element while scrolling down and fades out an image when scrolling up; however, it lacks the functionality to fade out when scrolling down. I am aiming ...

Having trouble with the Jquery animate() function?

I recently developed a jQuery animation where clicking on specific buttons triggers a hidden div to slide from left: -650px; to left: 0px;. You can see an example by clicking here. However, I've noticed that when another button is clicked to reveal a ...

What could be causing my jQuery to only toggle the first arrow in my HTML?

I am facing an issue with a series of divs generated from data, each containing an arrow that should toggle an expandable section. Strangely, only the first div is functioning properly: toggling the arrow icon and revealing the content upon click. When th ...

Enhancing Time Precision in CakePHP: Introducing Quarter-Accurate Time Input

I'm currently implementing time inputs using the following code snippet: $form->input("time") However, the select boxes generated have minute-accuracy, which is unnecessary for my project. Is there a way to restrict the options in the select lis ...

PHP MySQL query is causing multiple rows to be updated in the database

My goal is to update the quantity and price in two tables: Invoice and Order_Table. The updates should only apply to a specific OrderID. Here's my attempt: $UpdateQuant = "UPDATE Order_Table SET Quantity = '$NewQuant' WHERE OrderID = ' ...

When calling canvas.getContext('2D'), the function returns a null value

After creating a canvas and calling its getContext() method, I was confused when it returned null for the context. Below is the code snippet that I used: <script> window.onload = initializeCanvas; function initializeCanvas(){ ...

Updating dynamic content in IBM Worklight V6.1 with jQuery Mobile v1.4.3 requires waiting for the DOM to load

I need to dynamically update the content of a div within my HTML page structure. <!DOCTYPE HTML> <html> ... <body> <div data-role="page"> <div data-role="header"> //Image </div> <!-- Th ...

Footnote fiascos

I am currently in the process of creating a footer for my webpage and have implemented the following CSS styling: #footer { height: 100px; background-color: #F3F3F3; position: absolute; bottom: 0; } Although the footer is displaying at th ...

Is there a Firefox extension for optimizing absolute CSS positioning for faster web development?

When it comes to working with CSS, I prefer using Firebug and adjusting the top and left values with the up and down arrow keys. Has anyone found a Firefox add-on that allows me to drag elements around and then easily copy and paste the top and left value ...

Utilizing different levels of `<div>` within the card-body component in Bootstrap5

While following a web application tutorial on YouTube, I encountered a question. The code snippet is shown below: <div class="card card-body"> ... </div> The resulting output is displayed in this image: https://i.sstatic.net/D3iBL.p ...

Calculate the total sum of input values using jQuery

Here is the HTML I've been working with: I am trying to create a script where one textbox will display the total amount, and another textbox will display the following data: "name": [{ "id": 3, "qty": 2 }, { "id": 4, "qty": 5 }] Here's ...

What steps can I take to prevent a css-generated svg file from occupying more space than the original image? My wave appears to be 239px tall, while the svg file is a massive 1500px in height

I utilized an online tool to generate custom SVG CSS at this link: Upon implementing it on my webpage, the rendering seems correct in terms of height and width. However, upon inspecting the page, I noticed that the SVG file dimensions are 1512px by 1512px ...

when a div contains another div and is then followed by another div, apply the following style

Is there a way to create a rule that functions like the following: .container .unit:first-child(if it contains div.box1.extra) + .box2 { top: 50px;} <div class="container"> <div class="unit"> <div class="box1 extra"><!-- co ...

Article that fills the entire screen

I am currently in the process of developing a mobile application. The issue I am facing is that the text is not aligning properly and the images are not displaying fullscreen. Additionally, I want the images to adjust automatically based on whether you are ...