Help needed with CSS layout of 3 boxes where 1 box sits next another and then wraps under it.

Hello, I am trying to do a layout design I am not even sure if is possible to do. The basic idea is to have 3 boxes. The first contains an image and sit on the top left, the second is a table and sits on the right. The 3rd contains text and sits under the image, to the left of the table, but will wrap under the table if it goes that long. I have attached a porly drawn image of what I am talking about. I know with a Grid I can make the 3 boxes and align them up, I just don't know how to make that text box wrap under the table or if it is even possible. Can anyone provide any guidance? Thanks.
No description
25 Replies
13eck
13eck8mo ago
If both the image and text are block-level elements you can float the table
Matthew Alexandros
Matthew AlexandrosOP8mo ago
Would the image and text be in a container div and the table be floated against that? I am struggling to see how the table would float against both elements
Chris Bolson
Chris Bolson8mo ago
Yes, they would need to be within a container. Here is a quick demo https://codepen.io/cbolson/pen/rNbverN
ἔρως
ἔρως8mo ago
do not forget to clear:both at the end i cant stress this enough: DO NOT FORGET TO CLEAR THE FLOAT you will have all sorts of weird issues if you dont, like the parent having 0px of height
Matthew Alexandros
Matthew AlexandrosOP8mo ago
Thanks for the code pen I see how it is done now. I was thinking backwards on it. Really apreciate it! So this is working almost 100%, the only problem is that the table gets pushed up against the right edge and when the image is smaller then other this can lead to lots of blank space and look odd. Is there a way to make sure the table sits next to the image? So say the container is 800px and the image only takes up 300px. but the table is only 200px. This would cause 300px of blank space between the too.
ἔρως
ἔρως8mo ago
tables... the bane of css and html
Matthew Alexandros
Matthew AlexandrosOP8mo ago
Yea, expecially to make them responsive. I wish there was a bettery way. But I think this problem would still exist even if it was not a table. The floated element wants to sit on the right edge so it causes that big spacing between the left and right elements
ἔρως
ἔρως8mo ago
to make them response, i force them into a grid
Matthew Alexandros
Matthew AlexandrosOP8mo ago
I am going to be dealing with the larger tables and responsivness later down the line. Is it possible to shift the table cell over to be next to the image cell but still get the text to wrap under it or should I go back to the drawing board on the layout and display? I wonder if I do something like make the table max-width content and then add another floaded div with a non breaking space afte that to take up the remainign it would push the table over where I want it?
ἔρως
ἔρως8mo ago
do you have any code?
Matthew Alexandros
Matthew AlexandrosOP8mo ago
<section class="clearFloat">
<h2 class="centerText">Final Fantasy VII Remake Board Game: Materia Hunter</h2>
<div>
<div class="floatRight">
<table>
<tr>
<td><p>Release Date</p></td>
<td><p>March 2024</p></td>
</tr>
<tr>
<td><p>Platorm</p></td>
<td><p>Tabletop Board Game</p></td>
</tr>
</table>
</div>

<picture>
<source media="(min-width: 1024px)" srcset="/media/sgjgw2de/1__40578.jpg?rmode=max&amp;width=423&amp;height=238&amp;v=1da6af48b2c9450">
<source media="(max-width: 1023px)" srcset="/media/sgjgw2de/1__40578.jpg?rmode=max&amp;width=200&amp;height=120&amp;v=1da6af48b2c9450">
<img src="" alt="Final Fantasy VII Remake Board Game: Materia Hunter Logo" decoding="async" />
</picture>

<p>This is a competitive board game for 2 or 4 players in a 1v1 or 2v2 setup. The goal is to collect he most materia using the abilities of the icon characters from the Final Fantasy VII Remake game. The game includes 20 character card,s 80 materia cards (there are 5 different types of materia to use), 20 medal tokens, and 5 materia titles. It is estimated to take about 30 minutes to play</p>
</div>
</section>
<section class="clearFloat">
<h2 class="centerText">Final Fantasy VII Remake Board Game: Materia Hunter</h2>
<div>
<div class="floatRight">
<table>
<tr>
<td><p>Release Date</p></td>
<td><p>March 2024</p></td>
</tr>
<tr>
<td><p>Platorm</p></td>
<td><p>Tabletop Board Game</p></td>
</tr>
</table>
</div>

<picture>
<source media="(min-width: 1024px)" srcset="/media/sgjgw2de/1__40578.jpg?rmode=max&amp;width=423&amp;height=238&amp;v=1da6af48b2c9450">
<source media="(max-width: 1023px)" srcset="/media/sgjgw2de/1__40578.jpg?rmode=max&amp;width=200&amp;height=120&amp;v=1da6af48b2c9450">
<img src="" alt="Final Fantasy VII Remake Board Game: Materia Hunter Logo" decoding="async" />
</picture>

<p>This is a competitive board game for 2 or 4 players in a 1v1 or 2v2 setup. The goal is to collect he most materia using the abilities of the icon characters from the Final Fantasy VII Remake game. The game includes 20 character card,s 80 materia cards (there are 5 different types of materia to use), 20 medal tokens, and 5 materia titles. It is estimated to take about 30 minutes to play</p>
</div>
</section>
This is the code set. Nothing special the the CSS, floatRight is
float: right
float: right
and clearFloat is a
clear: both
clear: both
13eck
13eck8mo ago
Please use proper formatted code blocks. See #How To Ask Good Questions for the syntax
Matthew Alexandros
Matthew AlexandrosOP8mo ago
The whole thing sits under a
<main></main>
<main></main>
where all my main content goes.
ἔρως
ἔρως8mo ago
can you make a codepen?
ἔρως
ἔρως8mo ago
is this what you want?
No description
ἔρως
ἔρως8mo ago
if it is, you have some things to do: 1- .floatRight needs to be moved after the image 2- the image must float to the left 3- remove the paragraphs from the table 4- set clear:both on the parent of .floatRight and the image
Matthew Alexandros
Matthew AlexandrosOP8mo ago
I am looking to have the image and table sitting next to eachotehr and the text starting under the image and then expaning under the table when it can.
No description
Matthew Alexandros
Matthew AlexandrosOP8mo ago
I forgot up to set the original pen to ahve alonger text and table. I updated the pen. The goal is to have the existing layout but have the table sit next to the image instead of hugging the right side of the page
MarkBoots
MarkBoots8mo ago
Had to play with it for a while, but If your image has a fixed width, you could do something like this https://codepen.io/MarkBoots/pen/bGJxBge
No description
ἔρως
ἔρως8mo ago
not gonna lie, nice work from you but that looks awful it's just fixing a content problem with css it has a lot of wasted space as well
MarkBoots
MarkBoots8mo ago
yea, not sure this is the nicest layout, but liked the struggle to make it work. tried almost everything (css columns, grid, loads of calcs)
ἔρως
ἔρως8mo ago
floating stuff in weird ways is always a massive pain but that table really needs content it's so thin
Matthew Alexandros
Matthew AlexandrosOP8mo ago
Thanks. The images have a fix max width. As I was going though this thread I was starting to think in my head this might be a bad design. I am on mobile at work so can't say for sure but it kind of looks like it feom the small pic I can see on my home. I really appreciate all the help though! The pages using that table would be large. I am trying to design a release information page . The goal is to have the name, logo, information about that particular release (like different editons and what was included in them as well as changes done if it was a remake or something), and a table containing things like release date platform locations publisher developer and much more. The current data is just kind of a place holder while i make the layout but even a full table would not make it much wider
ἔρως
ἔρως8mo ago
oh, that makes sense
Want results from more Discord servers?
Add your server