Two sections side by side, one section is set to a specific width while the other adjusts its width to fill the remaining space within

I am trying to create a simple 2 block column layout:

<div id="wrap">
    <div class="column_1"></div>
    <div class="column_2"></div>
</div>

My goal is to have column_2 with a fixed width of 60px, both columns floating to the left. The total combined width of the columns should be equal to the wrap's total width (which may vary):

#wrap { width: 100%; }
.column_1, .column_2 { float: left; }
.column_2 { width: 60px; }

Please note that the wrap's width will change as it is nested inside a block with varying sizes.

An example use case could be having a text input in column_1 and a button in column_2. The button would remain a constant size while the input in column_1 adjusts its width accordingly.

Any suggestions on how to achieve this?

Note: I am looking for a CSS solution primarily, but open to jQuery if necessary.

Answer №1

To determine the level of support for older browsers, you need to consider how far back you want to go. One approach is to implement detection - if a browser supports flexbox, then utilize it; otherwise, fallback to using jquery. While Javascript will always be an option, it may introduce additional processing. For those interested in exploring the new flexbox specification, check out this resource: http://www.adobe.com/devnet/html5/articles/working-with-flexbox-the-new-spec.html

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

Selenium IDE - Verify the color in a test step

I've exhausted all the suggestions I came across on Stack Overflow, but unfortunately none of them have been successful in solving my issue. Can you provide guidance on how to confirm that the background color is actually blue for the specified eleme ...

What is causing my table to refuse to center?

I'm having trouble keeping my table of images contained within the content area of my page. Additionally, I can't seem to get my footer to stay at the bottom of the page. Take a look at this image for reference: body { margin: 0px; padding ...

Form that adjusts input fields according to the selected input value

I am in need of creating a dynamic web form where users can select a category and based on their selection, new input fields will appear. I believe this involves using JavaScript, but my searches on GitHub and Stack Overflow have not yielded a suitable sol ...

How can we dynamically adjust the subset of choices in a Django form's field to be dependent on another field's selection?

My form allows users to select an airport and then choose from one of the available airport terminals (establishing a one-to-many relationship through ForeignKey). The choices for the terminal field need to be limited to terminals within the selected airp ...

Issue with Custom CSS Class Not Displaying Correctly

I have implemented some unique CSS styles on a group of posts. You can view the site here. Upon inspecting the CSS classes of the posts, you will notice that the last two classes are .floats and .colThree. .colThree is being applied correctly with no issu ...

Manipulating the visibility of components by toggling on click events according to the existing state in ReactJS

Disclosure: I am still getting familiar with ReactJS I'm currently working on incorporating a dialog window for selecting a country/language on the initial page of my application. Here's the concept: There's a small flag button in the to ...

How to position menu on the right side using bootstrap

Hello everyone, as a newbie I have been struggling to align my navigation menu to the right while keeping the logo on the left side. I have tried multiple approaches without success. Currently, I am working with Bootstrap 4.7 and using the navbar code in ...

Tips for concealing a tab upon selecting an option from a dropdown menu

<ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#song">Song</a></li> <li id="image-tab"><a href="#image" data-toggle="tab">Image</a></li> </ul> <div class="tab-cont ...

Using jQuery to select elements with specific innerHTML values

$('.select option:selected[innerHTML="5"]') In this case, I am attempting to choose an option that is currently selected and has innerHTML that perfectly matches a specific string (for example: "5") For reference, here is a fiddle link: http:// ...

Exploring the endless possibilities of using repeatable bootstrap panels

The current code structure is as follows (custom wells, labeled as well-xxxx, apply brand colors to default wells): <div class="panel-group" id="accordion1"> <div class="panel panel-info"> <div class="panel-heading" data-toggle="colla ...

Mastering the correct application of template language in CSS files

I am trying to serve a CSS file through my url.py file in order to utilize template tags in my CSS. Below is the code I am using: Base.html: <head> ... <link rel="stylesheet" type="text/css" href="/site_media/css/wideTitle.css" /> urls.py: ...

The outcome of a jQuery ajax call may vary depending on the browser being used

I'm facing an issue with a $.ajax call, as I'm getting different results on different servers. Within my js file, the code looks like this: function getData () { $.ajax({ async: false, type:'GET', contentTy ...

Ways to handle <select> change events effectively in materialize css

My attempt at using a basic jquery change listener on a materialize css select dropdown has been unsuccessful. $("#somedropdown").change(function() { alert("Element Changed"); }); 1) Can anyone provide guidance on how to add a listener to ...

Is there a way to change the class and content of a div element without refreshing the page when the JSON data updates?

I have a JSON database that is updated frequently, and based on this data, I update the content of my webpage. Currently, I am using the following script to reload: var previous = null; var current = null; setInterval(function() { $.getJSON("sampledat ...

Pressing the button will allow you to select and copy the text within the

I am looking to incorporate a mock-chat feature into my website. The concept is to type something on the website, then click a button next to it which will move the text to a frame above. I attempted this using a textarea and even found a code for selectin ...

Tips for eliminating excess space on mobile devices with CSS

When testing the responsiveness of my banner image at a specific breakpoint, I noticed white space. You can see the issue on my website here. https://i.sstatic.net/Oug2R.png I have tried the following CSS: html, body { width: 100%; -webkit-box-s ...

What is the best way to showcase this code using HTML?

Looking to create a real-time user counter for my Meteor app using Javascript. Currently, I am using the following code snippet to track the number of users on the site: Presences.find({online: true}).count(); However, I am unsure how to display this inf ...

Create a design where two columns can be scrolled independently and extend to fit the height of the viewport

I have successfully created a JS Fiddle that demonstrates exactly what I am looking for: http://jsfiddle.net/j7ay4qd8/5/ This Fiddle features two columns that can be scrolled separately, and different sections of the left column can be easily scrolled to ...

CSS: Implementing Lists on Multiple Divisions

I need help with organizing an unordered list in two separate divs. HTML <div class="wee"> <ul> <li>Apples</li> <li>Ball</li> <li>Apples</li> </ul> </div> <div class="wee&q ...

How can you apply styling to one element when focusing on a different element at separate hierarchy levels?

I'm currently facing a challenge with styling a text field to expand when focused, and adding an "Add" button below it. The issue is that the elements are on different levels in the code structure, making it difficult to show or hide the button when f ...