Divide Width of Element Between Child Divs With CSS - css

I have a varying number of inline-block divs that I want to collectively take up 100% of their parent. Can this be done without JavaScript? The only way I can think of is with a table but it's of course bad practice to use a table solely for layout purposes.
|----------------------|
|{ div 1 }{ div 2 }|
or
|{div 1}{div 2}{div 3}|
|----------------------|
I have also tried { display:block; float:left; } but it doesn't seem to make a difference.

You can use display:table-cell on your inner divs to do this. For the browser to make the inner divs behave like table cells, it also needs two layers of containing elements: one to acts as the table, and another to act as the table-row.
For a structure like this:
<div class="outer">
<div class="middle">
<div class="inner">Item 1</div>
<div class="inner">Item 2</div>
<div class="inner">Item 3</div>
<div class="inner">Item 4</div>
</div>
</div>
Use this CSS:
div.outer {display:table;}
div.middle {display:table-row;}
div.inner {display:table-cell;}
A nice structure to use is a UL wrapped in a DIV: the DIV acts as a table, the UL as a row, and the LI's as table-cells.
This technique is not well supported in older browsers - for anything older than IE8, you're out of luck entirely.
Let me know if you need more sample code than that!

You can utilize css3 benefits here. I was also facing this issue now i have fixed that using below example code
.parent-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
-webkit-justify-content: space-around;
flex-wrap: nowrap;
-webkit-flex-wrap: nowrap;
}
.child-item {
margin: 5px;
text-align: center;
padding: 10px;
background-color: red;
color: #fff;
}
<ul class="parent-container">
<li class="child-item">1</li>
<li class="child-item">2</li>
<li class="child-item">3</li>
<li class="child-item">4</li>
<li class="child-item">5</li>
<li class="child-item">6</li>
<li class="child-item">7</li>
</ul>
Thanks & Regards,
Lingeshram

The accepted answer missed an important CSS property which is necessary to work:
table-layout: fixed;
This is the correct answer:
HTML:
<div class="outer">
<div class="middle">
<div class="inner">Item 1</div>
<div class="inner">Item 2</div>
<div class="inner">Item 3</div>
<div class="inner">Item 4</div>
</div>
</div>
</div>
CSS:
div.outer {display:table; table-layout: fixed;}
div.middle {display:table-row;}
div.inner {display:table-cell;}

I'd like to expound on #lingeshram's answer. Flexboxes have come so far that I think it's really the way to do it now. If you have to support old browsers, be sure to check caniuse first.
.container {
display: flex; /* or inline-flex */
}
.col {
flex-grow: 1;
border: 1px solid #000;
}
.col2x {
flex-grow: 2;
border: 1px solid #000;
}
Evenly split three children
<div class='container'>
<span class='col'>Inner 1</span>
<span class='col'>Inner 2</span>
<span class='col'>Inner 3</span>
</div>
<br>
Evenly split two children
<div class='container'>
<span class='col'>Inner 1</span>
<span class='col'>Inner 2</span>
</div>
<br>
Split three children, but the middle is twice the size of the others
<div class='container'>
<span class='col'>Inner 1</span>
<span class='col2x'>Inner 2</span>
<span class='col'>Inner 3</span>
</div>
Here is a pretty good guide to the different ways you can use flexbox.

Related

pushing icons closer together in footer gone wrong?

im trying to create a footer with a few social media icons...however, the method i've tried has resulted in the following problem :
expectation:
reality:
as you can see i'm failing in bringing the social media icons closer together... i tried setting the columns flex % to - however that pulls everything closer together towards the left of the screen...
here is my .row and .column as well as the social media icons..
.row {
display: flex;
}
.column {
flex: 30%;
padding: 00px;
}
.marginauto1 {
margin: 30px auto 20px;
display: block;
horizontal-align; middle;
vertical-align: middle;
}
<footer class= "marginauto1">
<center><div class="row">
<div class="column">
<center><a class= "pointer" href="twitter_url">
first time taking a stab at this on my own and I'm just really stuck here.. any help or tips would be appreciated!
If you want to put all your icons together in the middle:
img{
height:50px;
}
div{
display:flex;
justify-content: center;
background-color:blue;
}
<footer>
<div>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA81BMVEXgT1////9ktfYAiXvc3Nzg4ODeP1L4+Pj44OL22tzePVDgTF367O3fSVrn5+ffRFb5/P+x2ftdsvZ/wvj/7ljjZXJ7u8LhVWX99fbv7u7iW2rogozsmKHqipT87u/21NfwrrTtn6fzwcfoiJHmeoXlbnzzwMXyuL31zdHupa3mc3/f5uX/8FG93/v/8UlbsvxOqtgAhnHs3t/fzc7goabktbnekpjlsrfixciMyfh1u+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LvHxoh/vcPpd6wNED8b1i+gHdIX8Bbss//PeAX8KbzC3iX+wW8rW4HcsnFSoTnbLeRTSgTDVekg6iXk9DuPxFE5Bc9FFpEaM/kH0E5ohAuzKMUEtqDpzAVMXMZ5SCUPxk+ng4SM2KEyreitKs0h1JGaA/NtiIpAywnNNuKHFmwckKTrVhuQS5Ce2ropoHy0jJShHTTMBERlWwTIoT2zEDvBvl8ByZ8hNSBM229wYWumjih7RoWaeB5gbMtRWgHqu+7gopE3Fl2bsI06jdlMiJ2RK9EaI+UH1uGEQ5ZORlVQrs1NmGkkrHQuboQoR2cCR9MQQshwYMuMcJ0pFZrRiI0QmUI7V63QgcH4W7e4QssIXVTUVVmJIjHEVUntIO4ktmIUCxz1CxDSP3U8Oh7IyKhXOGOHCEdqv5xhyrxJQaoEqHtxtbx9n9sxbxuKByhbTtR4ziMuBE55V9HAyFlTI5gR2wlCnyKhDRunItXTIgI4cacMw7UREjt2NXo5ZCwq2Q/EELqj8dtLXsHIu0YoHYVgJC6ANMEQ09IjJMpSC0ZCCFldCILEJJ+VOQA1coBEdqpIbsWAVh2ECZWF8Z8S8ERUvUmSYiUIOm/DpOJcPxQJFBCKncWjxtypqTGa4zjmbTzwhA0IVXgDiLPF6OkdL4XDVwNdaoaCFP1nMlwTNoEY1wYaSFEf4L+3Hg4cUDH5laaCFdyR8PTxAsRISQlRRkwSkb/FoVecjocQQ/MHWklTNXstZz+dDDsRp4Xhr5v+X4Yel7UHQ6mfafVa5Z/hJr+D8W0TFVSelAUAAAAAElFTkSuQmCC">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRyFcxKQYRAhR9esHvHVZokZGCYFNC1_rMHhw&usqp=CAU">
</div>
</footer>
<center> tag will not applicable if you are using flexbox. Instead flex-box itself has some properties that you can make use of. In your use-case you can go with justify-content: center
.row{
display: flex;
justify-content: center;
}
.item{
color: red;
background: lightblue;
margin-left: 20px;
}
<footer class= "marginauto1">
<div class="row">
<div class="item 1">
<h1>Telegram</h1>
</div>
<div class="item 2">
<h1>Facebook</h1>
</div>
<div class="item 3">
<h1>Twitter</h1>
</div>
</div>
</footer>
If you don't want any space in between of 2 or more items you can remove the margin.
Its working as expected. You have defined .column with flex: 30%; which intrun will split into 3
flex-grow: 1;
flex-shrink: 1;
flex-basis: 30%;
So what have you done is allowing the element to grow till the available width with a minimum of 30% relative to the container. This is because the flex-basis is defined. This will be 33% each.
For your soution to work remove flex: 30%; from .column. This will take the width depending on the content.
If you want some gap between the element, try adding some margin or padding, I have used margin for that. Or you can set the width of column element.
Inorder to align the items center in horizontal axis, use justify-content: center; for the flex element.
Working Fiddle
.row {
display: flex;
justify-content: center;
}
.column {
padding: 0px;
margin-right: 20px;
}
.marginauto1 {
margin: 30px auto 20px;
display: block;
}
.pointer img {
width: 50px;
}
<footer class="marginauto1">
<div class="row">
<div class="column">
<a class="pointer" href="">
<img src="https://cdn1.iconfinder.com/data/icons/logotypes/32/twitter-512.png" alt="">
</a>
</div>
<div class="column">
<a class="pointer" href="">
<img src="https://cdn1.iconfinder.com/data/icons/logotypes/32/twitter-512.png" alt="">
</a>
</div>
<div class="column">
<a class="pointer" href="">
<img src="https://cdn1.iconfinder.com/data/icons/logotypes/32/twitter-512.png" alt="">
</a>
</div>
</div>
</footer>

Reduce the bottom border width

I have two tabs and they have bottom-borders. This is the jsfiddle example.
<div class="component-content">
<div class="tabs-inner">
<ul class="tabs-heading">
<li tabindex="0" class="active">
<div>
<div class="row">
<div class="component content col-12">
<div class="component-content">
<div class="field-heading">TAB 1: STANDARD SMALL</div>
</div>
</div>
</div>
</div>
</li>
<li tabindex="-1">
<div>
<div class="row">
<div class="component content col-12">
<div class="component-content">
<div class="field-heading">TAB 2: STANDARD SMALL</div>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
.tabs-heading {
display: table;
table-layout: fixed;
width:100%;
}
.tabs-heading li {
display: table-cell;
border-bottom: 2px solid red;
}
I want to add padding in the border bottom so that it should look like this
I tried to add padding-bottom but it didn't work.
Any suggestion or help would be appreciated
I am not quite sure if I got your question right ... but maybe you are looking for something like this ...?
If you don't use table and table-cell ... but flexbox instead ... all tabs will get automatically the same height and you are able to work with padding-bottom. If you like you can add margins between tabs as well.
#wrapper {
display: flex;
align-items: stretch;
background-color: Gray;
}
#wrapper div {
padding-bottom: 10px;
border-bottom: 2px solid orange;
}
#one {
background-color: green
}
#two {
background-color: blue
}
#three {
background-color: red
<div id="wrapper">
<div id="one">one one one one one one one one one one one one one one one one one one one one one</div>
<div id="two">two two two two two two</div>
<div id="three">three</div>
</div>

How would I align text above and below a line while keeping the line centered?

I'm creating a timeline in css that overflows if content is too long. I have text above and below the timeline where each segment is equal to the width of the text.
I've played around with both absolute and relative positioning.
The issue with absolute position is that I can't set the width of each segment to the text, which causes issues when the width of the viewport is smaller than the cumulative text.
The issue with relative position is that the text and the segment is all centered as a whole, which doesn't center the segment perfectly.
Before this I used margin-top and margin-bottom and set the segment to the parent element. The issue with this is that now my height has to be set manually since the height of the element is tied to the segment, and not the child text.
<div class="timeline">
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul>
<li>list</li>
...
</ul>
</div>
...
</div>
.timeline
display flex
flex-wrap nowrap
align-items center
width 100%
.segment
flex auto
white-space nowrap
display flex
flex-direction column
.line
height 0.1rem
background-color black
I expect:
x x x
⬤⸻⬤⸻⬤⸻⬤
y y y
y
But I get this instead (roughly speaking):
x x x
⬤______⬤⸻⬤______⬤
y y y
y
I'm still not 100% sure how your code is set up but I believe the issue is with the uneven list items. This can happen when you use display flex with an uneven amount of items in a ul element.
I changed the display for .timeline from display: flex to display: inline-block, which is safer for displaying uneven lists, as well as the display for .segment from display: flex to display: inline-flex.
You should also consider using inline-flex for items that you want to have a display of flex but remain inline.
Please see the snippit below.
.timeline{
display: inline-block;
align-items: center;
width: 100%;
}
.segment{
width:200px;
display: inline-flex;
white-space: nowrap;
flex-direction: column;
}
.line{
height: 0.1rem;
background-color: black;
}
.timeline > div:nth-child(even) > .list {
position: absolute;
}
/* UNCOMMENT BELOW TO SEE ORIGINAL CSS*/
/* .timeline{
display: flex;
flex-wrap: nowrap;
align-items: center;
width: 100%;
}
.segment{
flex: auto;
white-space: nowrap;
display: flex;
flex-direction: column;
}
.line{
height: 0.1rem;
background-color: black;
} */
<div class="timeline">
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul class='list'>
<li>x</li>
<li>x</li>
</ul>
</div>
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul class='list'>
<li>y</li>
<li>y</li>
<li>y</li>
</ul>
</div>
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul class='list'>
<li>y</li>
</ul>
</div>
</div>
As you can see, I added
.timeline > div:nth-child(even) > .list {
position: absolute;
}
To give you a quick fix for displaying every second list item above the lines, keeping the odd lists below.
As you didn't provide all of your code I cannot make the replication exactly like your use case but the phenomenon is the same and this should help you achieve what you're looking for.
One thing you can do is to set align-items: start;. If need to center all that vertically in a container, you can wrap everything into a div that will be centered.
If you need to have different sized titles, you can set fixed line-height and margin.
.timeline {
display: flex;
flex-wrap: nowrap;
align-items: start;
width: 100%;
}
.segment {
flex: auto;
white-space: nowrap;
display: flex;
flex-direction: column;
}
.segment h1{
line-height: 38px;
margin: 21px 0;
}
.line {
height: 0.1rem;
background-color: black;
}
<div class="timeline">
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul>
<li>list</li>
</ul>
</div>
<div class="segment">
<h1>title</h1>
<div class="line"></div>
<ul>
<li>list</li>
<li>list</li>
</ul>
</div>
<div class="segment">
<h1 style="font-size: 20px;">title</h1>
<div class="line"></div>
<ul>
<li>list</li>
<li>list</li>
<li>list</li>
</ul>
</div>
</div>

In CSS display:table, how do I maintain consistent cell widths?

I'm using pure CSS to create table layouts and neither my rows nor cells are behaving like tr or td elements.
The results seem to be that cells do not keep a consistent width and rows seem to have a float: left behavior when they should be display: block
This seems to work OK without the anchor tags... why?
.livesearchtable {
display: table;
table-layout: fixed;
width: 100%;
}
.livesearchrow {
display: table-row;
background: #f8f8f8;
width: 100%;
}
.livesearchcell {
display: table-cell;
width: auto;
padding: 5px 7px;
border-bottom: 1px solid #ccc;
white-space: nowrap;
}
<div class="livesearchtable">
<a href="../something.php">
<div class="livesearchrow">
<div class="livesearchcell">1</div>
<div class="livesearchcell">Some text thats long enough to make a difference</div>
<div class="livesearchcell">Lorem Ipsum</div>
</div>
</a>
<a href="../something.php">
<div class="livesearchrow">
<div class="livesearchcell">2</div>
<div class="livesearchcell">short</div>
<div class="livesearchcell"></div>
</div>
</a>
</div>
Try this. Take class 'livesearchrow' and set it as class for a tags. Delete divs with 'livesearchrow' class. Now a.livesearchrow is table-row and divs inside it are table-cells.
<div class="livesearchtable">
<a href="../something.php" class="livesearchrow">
<div class="livesearchcell">1</div>
<div class="livesearchcell">Some text thats long enough to make a difference</div>
<div class="livesearchcell">Lorem Ipsum</div>
</a>
<a href="../something.php" class="livesearchrow">
<div class="livesearchcell">2</div>
<div class="livesearchcell">short</div>
<div class="livesearchcell"></div>
</a>
</div>

In CSS, display inline-block is acting like display block

What I want to have is two divs side-by-side and within one of them is an image and in the other is two divs, one above the other.
This happens to be a Wordpress theme, but I'm pretty sure this is basic CSS question.
The Wordpress stack exchange told me it was off-topic.
Call the left div #divL and the right div #divR.
I found an answer on SO mentioning that I should set display of #divL and #divR to
inline-block. I can get this to work on a test html file that I created in isolation but it doesn't work in the wordpress header. Specifically the divs in the wordpress header #divL and #divR act as if they had display: block rather than being positioned side-by-side.
Changing them to display: inline does put them side-by-side but then it
doesn't work to stack two divs within #divR.
I'll replicate here some of the code in the Wordpress header. Note that I'm going to simplify this by omitting the stacked divs inside #divR, because the symptom is obvious without that.
the following is what I'm using to try to get #divL and #divR to display side-by-side.
#divL { display: inline-block; }
#divR { display: inline-block; }
<header class="site-header">
<div class="wrap">
<div class="title-area">
<div id="divL">
<img id="logo-img" class="attachment-full size-full">
</div>
<div id="divR">Some text that should go on right</div>
</div>
<nav> .... </nav>
</div>
</header>
But they display one above the other.
Note that this actually does work to get them side-by-side, but then the
stacked divs inside #divR don't work as intended:
#divL { display: inline; }
#divR { display: inline; }
<header class="site-header">
<div class="wrap">
<div class="title-area">
<div id="divL">
<img id="logo-img" class="attachment-full size-full">
</div>
<div id="divR">Some text that should go on right</div>
</div>
<nav> .... </nav>
</div>
</header>
There is a lot of CSS on these other elements but I'm not sure which of it is important to this question so I'll wait for someone to comment and tell me what I should include.
As I wrote in my comment, you should set widths for those ìnline-blocks, that should basically do what you are after.
But as an alternative you can also use display: flex; on the container DIV. This can be done rather simple, but in the snippet below I added some additional settings to define a certain width for the two DIVs and to center the contents in these DIVs both horizontally and vertically (by also making the child elements flexboxes with flex-directon: column. For the rest of the settings see the code below.
.title-area {
display: flex;
justify-content: center;
align-items: stretch;
}
.title-area>* {
width: 40%;
border: 1px solid green;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
<header class="site-header">
<div class="wrap">
<div class="title-area">
<div id="divL">
<img id="logo-img" src="https://placehold.it/200x150/fa0" class="attachment-full size-full">
</div>
<div id="divR">Some text that should go on right</div>
</div>
<nav> .... </nav>
</div>
</header>
Here's an example of what would work:
<header class="site-header">
<div class="wrap">
<div class="title-area">
<div id="divL">
<img id="logo-img" class="attachment-full size-full" />
</div>
<div id="divR">
<div id="divTR">Some text that should go on top right</div>
<div id="divBR">Some text that should go on bottom right</div>
</div>
</div>
<nav>....</nav>
</div>
</header>
And the CSS:
#divL {
display: inline-block;
width: 49%;
}
#divR {
display: inline-block;
width: 49%;
}
But also Jon P is right; it might be worth your while to investigate one of the newer methods for dynamically spacing and sizing content.

Resources