Perhaps a repeated inquiry, yet I have been unable to discover a solution for this issue...
I am dealing with a div
element (referred to as master
) that I do not have the ability to adjust in terms of width or height.
Contained within the master
is another div
(known as container
) over which I do have control.
And within this div
, there are 3 ul
elements, each set at 240px.
My objective is as follows:
If the total width of the master
is less than 720px (240px per ul
multiplied by the number of ul's
), I want the ul
elements to be displayed vertically (stacked on top of each other).
However, if the overall width of the master
exceeds 720px, then I wish to display the ul
elements horizontally (side by side).
In addition, I would like the container
element to have the smallest possible width necessary to accommodate its child ul
elements.
Is it conceivable to achieve this using solely css/html?
I have attempted utilizing flex, float, and tables without success...
I have created this fiddle for reference.
To visually emphasize my request:
https://i.stack.imgur.com/J5Qmb.png
https://i.stack.imgur.com/WId5E.png
The gray box represents the master
element.
The red box denotes the container
.
While the green boxes symbolize the individual ul
elements.