How can you make the second block element in a pair stretch to fill the parent element?

I'm currently struggling to make the "rightcol" in the "wrapper" of my data-entry form fill the remaining space next to the second column. Despite successfully displaying the child elements properly, whenever I use the border-bottom attribute, the border extends across the entire width of the wrapper.

Is there a way to ensure that "rightcol" fills out the empty space on the right when the columns are positioned side by side?

Below is a simplified version of my form. You can access the code on jsFiddler here.

<style type="text/css">
    ul { margin: 0; padding: 0; }
    li { list-style-type: none; list-style-position: outside; }
    #row { border-bottom: solid 1px #F00; }
    #wrapper { width: 100%; display: inline-block; }
    #leftcol { vertical-align: top; width: 350px; float: left; margin-right: 10px; }
    #rightcol { vertical-align: top; float: left; }
</style>

<ul>
    <li id="row">Row 1: <input type="text"></input></li>
    <li id="wrapper">
        <ul id="leftcol">
            <li id="row">Column A Row 1: <input type="text"></input></li>
            <li id="row">Column A Row 2: <input type="text"></input></li>
        </ul>
        <ul id="rightcol">
            <li id="row">Column B Row 1: <input type="text"></input><br />Here's another line in this row.</li>
            <li id="row">Column B Row 2: <input type="text"></input></li>
            <li id="row">Column B Row 3: <input type="text"></input></li>
        </ul>
    </ul>
    <li id="row">Row 3: <input type="text"></input></li>
    <li id="row">Row 4: <input type="text"></input></li>
    <li id="row">Row 5: <input type="text"></input></li>
</ul>

Answer №1

To achieve this effect, you can eliminate the float from the right column and instead provide it with a left margin that matches the width of the left column.

<style type="text/css">
    ul { margin: 0; padding: 0; }
    li { list-style-type: none; list-style-position: outside; }
    #row { border-bottom: solid 1px #F00; }
    #wrapper { width: 100%; display: inline-block; }
    #leftcol { vertical-align: top; width: 350px; float: left; margin-right: 10px; }
    #rightcol { margin-left: 350px; vertical-align: top; }
</style>

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

Interactive Table - Enhance Your Searching Experience with jQuery

Recently, I've been tackling a Live Search solution for my data table. Success! When searching for Jim, everything works flawlessly. ...

Subclass Pseudoclass in JavaFX is a powerful feature that

I wanted to create two different styles of buttons in one css file. To achieve this, I added a class to the second button using: close.getStyleClass().add("close-button"); Now, I can reference this button in the css by: .button.close-button However, I ...

Solving the enigma of CSS positioning: mastering floats, margin-left/right, and auto

Hey there, I'm having trouble posting an image but here is the link: I believe this explanation will be clearer, D2, D3 & D4 need to be aligned next to each other and centered on the screen at all times. (960px)      & ...

Is this the correct method for constructing a class in CSS?

What is the correct way to style a class with CSS and write HTML code? .first{ color:red; } Here is an example of HTML code: <class id=first> <p> some text </p> <p> some other text </p> ...

Issues with javascript and php carousel functionality not performing correctly

I am currently in the process of creating a slideshow/carousel for a website. Recently, I implemented a PHP for-loop to iterate through a folder of images, allowing me to use the slideshow with an unspecified number of images. However, after making this ch ...

"Retrieve data from an Excel file and either present it in a textarea or store it as an array

Is it possible to use JavaScript to read an Excel file and convert a single column (identified by name or index) into an array in JavaScript? ...

Steps to update the bootstrap version in an existing project

My current project was built using Bootstrap 3.3.6 classes, but now I want to take advantage of the features offered by Bootstrap 5.2. However, simply changing the version of Bootstrap isn't as easy as it sounds. What is the most effective way to upgr ...

How can I exclude specific lines from an XML file using filters?

Let's say I have the following data: <div class="info"><p><b>Orange</b>, <b>One</b>, ... <div class="info"><p><b>Blue</b>, <b>Two</b>, ... <div class="info"><p><b& ...

Is it possible to have multiple forms on a master page?

Regarding the limitation of having only 1 runat="server" and <form> per master page, I am facing a dilemma with placing my login form on my website. Should I include it all on the master page or distribute some elements to the .aspx form? Currently, ...

Determine the byte size of the ImageData Object

Snippet: // Generate a blank canvas let canvas = document.createElement('canvas'); canvas.width = 100; canvas.height = 100; document.body.appendChild(canvas); // Access the drawing context let ctx = canvas.getContext('2d'); // Extrac ...

JS client-side form validation involves communicating with the server to verify user input

I currently have an HTML form that is being validated on the client side. Below is a snippet of the code: <form id='myForm' onsubmit='return myFormValidation()'> ... </form> Now, I want to incorporate server-side valida ...

Uncheck all boxes except for the required or disabled boxes in Angular

HTML: <mat-selection-list #selectedColumns [(ngModel)] ="selectedOptions"> <div class= "content-section"> <mat-expansion-panel> <mat-expansion-panel-header> ...

What is the best way to create a full-width gallery display?

I've been having some trouble making my image gallery full-width at any resolution. Oddly enough, the gallery only goes full screen when I click on the maximize button in the browser window. I can't seem to figure out what the issue is so far. ...

Generating a dynamic table using Angular

My goal is to populate a table dynamically using the code below: teams.component.ts import { Component, OnInit } from '@angular/core'; import { first } from 'rxjs/operators'; import { TeamService } from 'src/app/services/team.ser ...

How can you use jQuery to activate a specific tab?

I have 3 tabs with 3 different ids. $(document).ready(function() { $(function() { $( "#tabs" ).tabs(); }); $("#links > a").click(function() { var link = $(this).attr('href').substr(-1,1); console.log(link); $('#t ...

Achieving Horizontal Alignment of Tab Labels and Icons in Material-UI with Tabs API

I am currently attempting to customize the Material UI CSS in order to align both the phone icon and text on the same line and closer together. After doing some research, I stumbled upon the Tabs API which seemed promising. Upon further inspection, I disc ...

BeautifulSoup - Struggling to retrieve tbody element

Having trouble accessing a table nested deep inside multiple layers? I'm relatively new to utilizing Beautifulsoup and have been practicing with some basic examples. However, I've hit a roadblock as I can't seem to locate the "div" tag with ...

Applying a Webkit Scroll Bar to a specific element on the webpage

I've been attempting to apply the Scroll Bar webkit styling to a particular element but haven't had any success. Despite searching extensively, I have come across 2 threads on Stack Overflow that do not provide a solution. Most of the available ...

Ways to showcase a website within an HTML document using a URL?

Is it possible to show 2 webpages on a single aspx webpage? For instance, When a user opens the link for www.mywebsite.com, I would like to display both www.google.com and www.bing.com on my homepage. Behind the scenes, I will call two separate URLs an ...

Place content following a three.js display created within a <div id="mainWindow">

Recently, I created a small Three.js animation and embedded it in my HTML page like this: <div id="mainWindow" class="popup_block"> <!-- JavaScript for simulation --> <script src="../temp/webgl-debug.js"></script> <scri ...