Creating a visually appealing line design with customizable column widths using CSS

Currently, I am working on designing a user registration page for a testing application and facing some challenges with the layout. CSS has never been my strong suit, but I can manage to style most of the elements except for one - the birthday field. My form design is simple and nothing extravagant.

After trying several approaches, including using tables to structure the input fields, I realized that the day, month, and year fields tend to align incorrectly or disrupt the overall layout. Despite my attempts to control their size and alignment, they always end up causing issues.

I'm avoiding JavaScript or the date field type as they have compatibility limitations across different browsers. Instead, I am opting for a flexible width approach where the user can adjust the page according to their preference.

If anyone could provide guidance or suggestions on how to achieve the desired layout without compromising alignment and spacing, I would greatly appreciate it. Thank you for your assistance.

EDIT

In the system I'm working on (Java EE), I've simplified the code to only HTML and CSS for clarity:

HTML:

<div class="folha">
    <table>
        <tr>
            <td>SEX</td>
            <td>BIRTHDAY</td>
        </tr>
        <tr>
            <td><input type="text" name="sex" placeholder="sex"/></td>
            <td id="date">
                <input type="text" name="day" placeholder="day"/>
                <span>/</span>
                <input type="text" name="month" placeholder="month"/>
                <span>/</span>
                <input type="text" name="year" placeholder="year"/>
            </td>
        </tr>
    </table>
</div>

CSS:

.folha table,
.folha td
{
    border: 1px black solid;    
}

.folha table
{
    width: 92.5%;
    margin: 0px auto;

    border-spacing: 60px 0px;
}

.folha table input[type="text"]
{
    width: 100%;
    height: 30px;

    text-align: center;

    border: 1px red solid;      
}

.folha table tr:nth-child(odd) td
{
    padding: 16px 0px;
}

.folha #date input
{
    width: 20%;
}

Despite these efforts, achieving the desired alignment as shown in the first image remains a challenge for me. As someone still learning CSS, any alternative suggestions on how to tackle this issue are welcomed.

Answer №1

Revised now that the source code is accessible:

If you desire both columns to have equal width, it's essential to specify that in the .folha td section.

It appears that the date inputs' percentage width is dependent on their parent cell, which can cause them to wrap to a new line if set too high. This is due to the three inputs (along with spacers) not fitting well in the given space.

To ensure the date inputs occupy precisely 100% of the space, adjusting the spacer widths using percentages alongside setting a max and min width for the table itself might be necessary to prevent unexpected layout changes at extreme browser sizes.

I trust this information proves useful :)

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

Adjust the height of the Accordion component in Material UI

I am currently in the process of migrating a JavaFx HMI to a web application that utilizes React.js. To display graphical widgets, I am also working with Material.ui. In order to maintain consistency with the original HMI layout, I need to adjust the layo ...

When using CSS float:left and overflow:visible, the text may get cropped-off at

I'm currently experimenting with creating a color gradient in javascript using numerical values within some of the divs to indicate scale. However, I've run into an issue where as the values get larger, they are cut off due to the float:left prop ...

Utilizing Card Images in a Slider with Bootstrap 4

Is there a way to turn the card-image-top section into a slider, especially for mobile use? I want to showcase multiple product images in this section for my customers to see. Any simple solutions for achieving this? <div class="card" style= ...

Having trouble with AngularJS and NodeJS routing integration?

After deciding to dive into the world of application development using the MEAN Stack, I encountered a major roadblock. For the past hour, I've been struggling to set up a basic route, only to face failure at every turn. Whenever I try to access my ...

Tips on utilizing setInterval in a Vue component

When defining the timer in each individual my-progress, I use it to update the value of view. However, the console shows that the value of the constant changes while the value of the view remains unchanged. How can I modify the timer to successfully change ...

What is the process for using the GitHub API to access a repository's README document?

For my project, I'm utilizing the GitHub API to access the raw README.md file using /repos/{owner}/{repo}/readme. I've successfully executed the call using Thunderclient in VSCode and retrieved the raw file. https://i.sstatic.net/FtkfW.png Howev ...

Different Ways to Customize Button Click Events in Angular 9 Based on Specific Situations

In my Angular 9 web application development, I frequently need to integrate Bootstrap Modals like the example below: <div class="modal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="do ...

Tips for transferring parameters between AJAX requests

Struggling to pass parameters between two different ajax calls, I've noticed that the params only exist within the ajax scope and not outside of it. Is there another way to achieve this without calling from one ajax success section to another ajax? He ...

The global variable is inaccessible when invoked within a dynamically generated function

The variable selected is a global one and accessed using this.selected, which reliably returns the correct value. However, when called from a dynamically created function, it returns unknown. onClick: function(val){ for (i = 0; i < positi ...

Creating dynamic button names and detecting the pressed button in PHP

Right now, I am experimenting with PHP to create a unique project. This experiment is just a small part of a larger file that I am working on. Essentially, the aim is for the program to generate a series of submit buttons within a form, each assigned a dis ...

Personalizing the structure of a joomla template

Having some trouble customizing my Helix Framework template. I'm trying to adjust the width of the page to be 1140 px. When I make changes in the framework menu, it only adjusts the text field width and not the graphics. How can I achieve the layout s ...

Implementing dynamic ID routes in React Router using JSON data

As a beginner in React, I have been working hard to improve my skills every day. However, I am currently facing a challenge with creating dynamic routes using JSON characters (specifically from Dragon Ball Z). Although my routes are set up correctly, I wo ...

Customizing the sizes of HTML components (h1, h2, h3, etc.) with Tailwindcss for both desktop and mobile platforms

Currently, I am working on a project using Tailwind CSS and Next.js. I want to customize the font size of h1 element from 40px to 46px for desktop screens (1440px) and then adjust it to 30px for mobile web (375px). I attempted to add a new property in the ...

ReactJS tweet screenshot capture

Currently seeking a solution to capture a tweet screenshot, store it in a PostgreSQL database, and display it on my ReactJS webpage using Typescript. I have been utilizing react-tweet-embed for displaying the tweet, but now I require a method to save the i ...

What is the best way to remove empty elements from an Array?

Having an issue with my API post request. If no values are entered in the pricing form fields, I want to send an empty array. I attempted to use the filter method to achieve this but it still sends an array with an empty object (i.e. [{}]) when making the ...

Passing multiple checkbox values with JavaScript's DOM Event

I am working on a form that contains multiple checkbox options. Users have the ability to select one or more options. Here is the HTML code: <div id="container"> <h1 id="title">RGB Color</h1> <div id=" ...

Is it possible to add additional text to an input field without modifying its existing value?

I have a numerical input field labeled "days" that I want to add the text " days" to without altering the actual numerical value displayed. <input type="number" class="days" (keyup)="valueChanged($event)"/> Users should only be able to edit the num ...

Create a PDF document with a custom header and footer by converting an HTML template using itext7

I attempted to utilize the following HTML template in an effort to convert it to a PDF using iText7, however, I am facing an issue where both the header and footer are not aligning to their designated positions. You can view the example I used here. I am s ...

Issue with the Bootstrap navbar dropdown menu functionality not functioning as expected

<head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24464b4b50575056455464110a150a17">[email protected]</a>/dist/css/bootstrap.min.css" rel=&q ...

The JSON output displayed my HTML `<br />` as unicode `u003cbr /u003e`, resulting in the `<br />` being shown as text instead of creating a line break

Utilizing ASP.net MVC3, I have retrieved a model in Json format using Jquery.AJAX and am passing it into a Jquery template for rendering. For instance, the Json returned by the server is {"Key":2,"Content":"I'm Jason\u003cbr /\u003ehow are ...