+ 1

How to Keep three div one below another.

Inside the third div keep two divs side by side..

26th Aug 2017, 11:34 AM
vignesh waran
vignesh waran - avatar
16 ответов
+ 5
<!-- Using "display:flex;" as I've previously shown doesn't suit to you? You can also do it through use of 'table' and 'table-cell' value for 'display' property, but 'flex' way is globaly better suited, if you doesn't encounter support lacks in old browsers ^^ --> <style> #wrapper { background:magenta; padding:2vh; display:table; height:30vh; width:100%; table-layout:fixed; box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; } #wrapper div { display:table-cell; width:50% } #wrapper div:first-child { background:lime; } #wrapper div:last-child { background:cyan; } </style> <div id="wrapper"> <div></div> <div></div> </div>
29th Aug 2017, 8:27 AM
visph
visph - avatar
+ 4
<style> #wrapper { background:magenta; padding:2vh; display:-webkit-box; display:-webkit-flex; display:-ms-flexbox; display:flex; -webkit-box-align:stretch; -webkit-align-items:stretch; -ms-flex-align:stretch; align-items:stretch; height:30vh; } #wrapper div { -webkit-box-flex:1; -webkit-flex:1; -ms-flex:1; flex:1 } #wrapper div:first-child { background:lime; } #wrapper div:last-child { background:cyan; } </style> <div id="wrapper"> <div></div> <div></div> </div> <!-- Something like that? --> <!-- Edited with vendors prefixed properties -->
26th Aug 2017, 12:48 PM
visph
visph - avatar
+ 3
If you'll make 3 divs in html whiteout inclosing one in the other they will already be kept one below the other because divs are block level elements and the default css of the browser tells them so.
26th Aug 2017, 12:14 PM
Vivek Singh
Vivek Singh - avatar
+ 1
this is how to make 3 div below each other https://code.sololearn.com/WWBgnW3L4026/?ref=app
29th Aug 2017, 9:26 AM
dar meer
dar meer - avatar
+ 1
this is how to make two div side by side https://code.sololearn.com/WwmULzL4y8v2/?ref=app
29th Aug 2017, 9:27 AM
dar meer
dar meer - avatar
0
thanks for this code. I will try
26th Aug 2017, 12:55 PM
vignesh waran
vignesh waran - avatar
0
<div style="display:block;"></div> <div style="display:block;"></div> <div style="display:block;"></div> //note---u should put other styles like background color and width and higth to see the result
29th Aug 2017, 7:56 AM
dar meer
dar meer - avatar
0
could you tell how to make 2div with equal width by side by side..with using display property..
29th Aug 2017, 8:04 AM
vignesh waran
vignesh waran - avatar
0
this is the final of what u want https://code.sololearn.com/WjhVn7N8butK/?ref=app
29th Aug 2017, 10:20 AM
dar meer
dar meer - avatar
0
https://code.sololearn.com/Wwby3r03MZG3/?ref=app
29th Aug 2017, 10:28 AM
vignesh waran
vignesh waran - avatar
0
pls check my code I want green color div in right side..how to acheive without using float, position
29th Aug 2017, 10:30 AM
vignesh waran
vignesh waran - avatar
29th Aug 2017, 10:50 AM
dar meer
dar meer - avatar
0
that's cool...can u explain in width calculation how it's works..
29th Aug 2017, 11:05 AM
vignesh waran
vignesh waran - avatar
0
the 50%of width is without the border size so when u put the width 50% it will be bigger than 50%with border so that is the reason why u could not make them in one line .......the calc function decrease 6 px which is the border size
29th Aug 2017, 11:12 AM
dar meer
dar meer - avatar
0
It has any other options to make same output using other property like margin,padding etc..or it's the only way to acheive!
29th Aug 2017, 11:32 AM
vignesh waran
vignesh waran - avatar
0
#dar meer if I put -5px it will come down.either I put 6px I got result..what's is the browser calculation about this px?
30th Aug 2017, 4:13 AM
vignesh waran
vignesh waran - avatar