- 1

Div

How can I put 6 divs in two columns and three rows, respectively? https://code.sololearn.com/W7hcBB1rdkRZ/?ref=app

14th Apr 2020, 5:20 PM
Atum
Atum - avatar
25 odpowiedzi
+ 4
Mohsen why avoiding table for formatting? If that's only related to the unadvised semantical misuse, you could workaround the problem... The idea is to use table behavior without using table semantic, thanks to the 'display' css property wich provide 'table', 'table-row' and 'table-cell' among the possible values ;) That results in a few less flexible layout than 'flex' nor 'grid', but strongest support on older browsers... and anyway, offers a lot of possibilities ^^ https://code.sololearn.com/W75cS68V5sP1/#html
16th Apr 2020, 9:38 AM
visph
visph - avatar
+ 4
<table> <tr> <td> <div></div> </td> <td> <div></div> </td> </tr> <tr> <td> <div></div> </td> <td> <div></div> </td> </tr> <tr> <td> <div></div> </td> <td> <div></div> </td> </tr> </table> And bro please show your attempt first then ask questions ok
14th Apr 2020, 5:30 PM
Ayush Kumar
Ayush Kumar - avatar
+ 2
You can use grid function. You should share your code too.
14th Apr 2020, 7:08 PM
Shubham Thakur
Shubham Thakur - avatar
+ 2
It is very easy with grid however you can use float too
14th Apr 2020, 7:31 PM
Shubham Thakur
Shubham Thakur - avatar
14th Apr 2020, 8:02 PM
Shubham Thakur
Shubham Thakur - avatar
+ 2
https://code.sololearn.com/W88HFLBK9hCh/?ref=app
16th Apr 2020, 1:44 AM
Mason Arb
Mason Arb - avatar
+ 1
Go for it
14th Apr 2020, 8:04 PM
Shubham Thakur
Shubham Thakur - avatar
15th Apr 2020, 7:02 AM
Rijwaan Ali
Rijwaan Ali - avatar
+ 1
You should use the table tag for rows and columns
16th Apr 2020, 1:35 AM
Mason Arb
Mason Arb - avatar
+ 1
No... 'float' is very specific, even if beginers tends to put it everywhere once they discover it... As for positioned modes (absolute, relative -- but in this cases rookies found it not enough intuitive :P). Notice however, that 'float' has is use cases, and its not evil: we just must to not abuse from it ;) The only best alternatives are 'flex' and 'grid', while you accept to have some visitors with old browsers where you design will broke ^^ Anyway, 'table' is safety, 'flex' is near futur (few browsers doesn't support at least root features), and 'grid' start to be introduced in more and more browsers/engines :)
16th Apr 2020, 12:07 PM
visph
visph - avatar
+ 1
You could use float, but you could only float into three different positions: left middle and right. But table can do a lot more
16th Apr 2020, 12:14 PM
Mason Arb
Mason Arb - avatar
+ 1
Mason Arb yes, I wanted not to say that it wasn't possible with 'float', but that was the worst way to do this... However, 'float' has only 2 values possible: 'left' and 'right'... Even if sometimes we would dream of a 'float:center', that sounds logical: how browsers should be decide in wich order placing the center-floating element?
16th Apr 2020, 12:19 PM
visph
visph - avatar
+ 1
Oh I thought there was a middle
16th Apr 2020, 1:07 PM
Mason Arb
Mason Arb - avatar
+ 1
One or two things useful to know when we're using display css property with 'table'-family values: We are not mandatory to use explicitly the structure table > row > cell, and we could "forgot" the row if we have a table with only one row (a phantom element would be implicitly inserted, acting as the row container. I don't remember if we can use just the cell: anyway, the use case is rare, because you often need to define some css properties on the table-like element, and phantom element cannot be accessed through css nor js ^^ The display property could be applied on any html element, including <body> and... <html>! So, if we want, we could define 'display:table;' for <html> and 'display:table-cell;' for the <body>, so it as the behaviour of a cell... with 100% height for <html> and <body>, we could relatively easily center the body content in the page (text-align:center; vertical-align;middle;) or just do a container of any size with centered content in it (both vertically and horizontally)
16th Apr 2020, 2:03 PM
visph
visph - avatar
0
You're certainly right, but I don't want to use tables for formatting.
14th Apr 2020, 6:49 PM
Atum
Atum - avatar
0
According to the file I put, can this be done with float and clear?
14th Apr 2020, 7:29 PM
Atum
Atum - avatar
0
Thank you for your help. Maybe it would be better for me to do this with float to find out if it gets into trouble or not!?!
14th Apr 2020, 8:03 PM
Atum
Atum - avatar
0
I used flex.....
15th Apr 2020, 7:05 AM
Rijwaan Ali
Rijwaan Ali - avatar
0
Amazing
15th Apr 2020, 7:55 AM
Shubham Thakur
Shubham Thakur - avatar
0
Thank Rijwaan Ali for your help. But this code is arranged in 2 rows and 3 columns, not 3 rows and 2 columns.
15th Apr 2020, 9:41 AM
Atum
Atum - avatar