Achieve perfect alignment of columns using CSS to ensure they fill the entire panel

I want to arrange a specific number of columns on a panel, each with a different width so that they fill the entire panel and create a full row of panels.

Currently, the columns have varying widths but only occupy 70% of the panel's width.

I am not using traditional table tags like <table> or <tr>; instead, I'm using CSS with <div> elements to structure my "table."

The panel consists of a single row with a variable number of columns (4, 5, or 7) depending on where it is implemented.

fiddle: http://jsfiddle.net/Rm5VT/

HTML (excerpt):

<wicket:panel>
        <div class="separator">Gen I</div>
        <div class="row">
            <div class="gen-i">
                <div class="column">
                    <!-- mfr -->
                    <div class="field">
                        <span class="field-name">Mfr</span> 
                        <div class="value">
                            <select name="Mfr" wicket:id="mfr"></select>
                        </div>
                    </div>

                    <!-- s cd -->
                    <div class="field">
                        <span class="field-name">S cd</span> 
                        <div class="value">
                            <input wicket:id="sCd" type="text" />
                        </div>
                    </div>

                    <!-- N pts -->
                    <div class="field">
                        <span class="field-name">N Pts</span> 
                        <div class="value">
                            <input  wicket:id="nPts" type="text" />
                        </div>
                    </div>
                </div>

                <div class="column">
                    <!-- atv-->
                    <div class="field">
                        <span class="field-name">Atv</span>
                        <div class="value">
                            <span wicket:id="atv"></span>
                        </div>
                    </div>

                    <!-- p sys -->
                    <div class="field">
                        <span class="field-name">P Sys</span>
                        <div class="value">
                            <span wicket:id="partOfSystem"></span>
                        </div>
                    </div>
                </div>

                <div class="column">
                    <!-- ty dvc -->
                    <div class="field">
                        <span class="field-name">Ty</span> 
                        <div class="value">
                            <textarea wicket:id="ty"></textarea>
                        </div>
                    </div>

                    <!-- foa -->
                    <div class="field">
                        <span class="field-name">FoA</span> 
                        <div class="value"> 
                            <select wicket:id="foa"></select>
                        </div>
                    </div>
                </div>  
            </div>
        </div>
    </wicket:panel>  

CSS (excerpt):

.separator {
color: #FEFDFD;
background-color: #4984BD;
text-align: center;
font-size: 15px;
font-family: Verdana, sans-serif;
font-weight: bold;
}

.row {
background-color: lightyellow;
display: table;
width: 100%;
}

.column { 
float: left;
display: table-column;
}

Thank you for your assistance. I hope my explanation was clear.

Answer №1

After floating your divs, it's crucial to define a specific width for them. Without specifying a width, floated elements will only occupy the necessary amount of space, neither more nor less.

Determining the appropriate width depends on the desired appearance of these elements.

Answer №2

Do you think this is the right course of action?

.section {
width:100%;
height:auto;
}

Once all sections are complete, include a div to clear any floats.

Answer №3

Check out this solution I came up with for your question. I made sure to keep the original format while incorporating some jquery:

http://jsfiddle.net/UniqueUser123/AbcDeFg/2/

$('.box').each(function() {
    var size = $(this).parent().children().length;
    $(this).height($(this).parent().height() / size);
});

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

Bootstrap: Easily align elements to the right with the .pull-right class, avoiding the need to manually adjust margins

This is the code snippet I am working with (you can view the fiddle here): <div class='container'> <div class='hero-unit'> <h2>Welcome</h2> <p>Please log in</p> <div i ...

Differences between .php and .html: What causes variations in IE rendering?

After duplicating one of the HTML pages in my project, I simply changed the file extension from .html to .php. Surprisingly, all browsers display the page identically except for Internet Explorer (IE), which seems to handle the pages differently based on t ...

Issue with Google Maps: undesired change in map size

Welcome to my app! Check out the link to my app here: http://jsbin.com/axeWOwAN/1/edit If you prefer a full-screen view, click here: http://jsbin.com/axeWOwAN/1 I'm encountering an issue with the map on the second page of my app. The map works perf ...

Using Selenium to Implement Accept Policy Targeting

I am attempting to locate and click on a button from dekudeals using selenium. Specifically, I am trying to target the accept button within the site's policy window. The button that needs to be clicked can be found here. I have made several attempt ...

How can Django display HTML content verbatim without needing a variable?

I have a collection of HTML code: <div align="center" id="whatever"> <a href="http://www.whatever.com" style="text-decoration:none;color:black"> <img src="http://www.whatever.com/images/whatever.jpg" /> </a></div> I am look ...

What is the best way to implement buttons dynamically in multiple divs created by Django using JavaScript loops?

I have been working on a Django project where I've created several HTML divs. My goal is to add a single button to each div. https://i.sstatic.net/DEIqL.png In the image provided, you can see a div with the class card-footer that I created using a Dj ...

Using CSS and JQuery to position the dropdown selector arrow before the text

Can anyone help me figure out how to show the tick on a dropdown before the text? SelectBox|v| <-- DROPDOWN WITH SELECTOR TICK AFTER TEXT |v|SelectBox <-- I want my dropdown to look like this If you have any insights on how to achieve this using C ...

Ways to fix text overlap in a pill

Click here to view the code on jsBin I quickly copied HTML/CSS code to jsBin using a tool called SnappySnippet. I attempted various solutions, but none of them worked. The best option for me seems to be overflow: ellipses word-break: break-word; word-b ...

The functionality to rename a label by clicking on an image button is currently malfunctioning

There seems to be an issue with this code where the label name is not changing as expected when clicking the image button. I have noticed that upon closer inspection, the label does change momentarily but then reverts back to its original value immediatel ...

Is there a way I can reduce the duration of this date without needing to execute date()?

Working on a project with Django and AngularJS, I recently received a response from a request that included an object containing the name, price, and date of modification for this input. In my HTML, I am using {{price_level.modified }} to display 2018-01- ...

JSOUP is cleverly filtering out specific tags while navigating through the HTML tree

While attempting to navigate the HTML tree of a Wikipedia page, I noticed that certain blocks of HTML elements in the code are being omitted. Is there a way to prevent these omissions? CODE Document doc = Jsoup.connect(url).timeout(10000).userAgent(USER_ ...

Ways to determine if a website element is hidden from view

I am currently investigating the visibility of the following element: <ul class = 'pagination-buttons no-bullets'> https://i.sstatic.net/oOo7S.png When <ul class = 'pagination-buttons no-bullets'> is visible, its parent el ...

Concealing navigation options using CSS styling

A unique program I developed generates a tree structure that looks like this: <li class="linamesystem">Alternator</li> <ul class="boxfornamegroupsparts"> <li class="linamegroup"><a href="#top(1)">Alternator2</a> ...

Trouble encountered in collapsing list with nestedSortable functionality

I'm having some trouble getting the collapsible feature to work with nestedSortable. http://jsfiddle.net/meisam/vq9dD/ This is the javascript code I am currently using: $('ol.sortable').nestedSortable({ disableNesting: 'no-nest&a ...

Spinning triangle around central point using CSS

I'm working on a project that includes the following code snippet: body { background-color: #312a50; font-family: Helvetica Neue; color: white; } html, body { height: 100%; } .main { height: 100%; width: 100%; display: table; } .wr ...

The navigation bar in my HTML/CSS project is malfunctioning, causing the text to extend beyond the edges

Welcome to my HTML sub-page where I'm struggling with scrolling. Can someone please help me understand why it's not working? I've experimented with various solutions suggested by others facing similar issues, like adding a div at the bottom ...

Error in Javascript caused by the use of Jquery's "hide on load" feature

Looking for help with creating a menu where the subitems disappear when the page loads. If you require the full HTML code, I can provide it, but essentially it consists of several DIVs, with the items under headers having a class of subitems. I was able ...

Adjust speed on various HTML5 video players

I'm looking to slow down all the HTML5 video players on my page to 0.5x speed. Currently, I have a JavaScript snippet that only affects one video player at a time. <script type="text/javascript"> /* play video twice as fast */ document.quer ...

Annoying line break tags found within a div element

Using jQuery AJAX to populate values in a JSP page is causing unwanted line breaks. This is the JSP page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" ...

Warning in Next.js: When utilizing conditional rendering, the server HTML is expected to have a corresponding <div> inside another <div>

Although similar questions have been asked on various platforms like Google, none seem to provide answers that align with my specific situation. Essentially, my goal is to have a different search bar displayed in the header based on the page I am currentl ...