0

columns

Image to better explain the problem.

What I'm trying to do is make the columns in the second section the same as the first. So far, I've achieved this by adding 13% padding to the left and right sides of the section and setting the correct width in percentages for each column, although I've had problems with it because it was automatically setting the wrong percentages to fill 100% of the section.

The content is in "infobox".

If I don't set padding in section, it looks like this: columns_without_padding

I know there has to be a better way to achieve the same result. Any ideas?

4
  • Questions seeking code help must include the shortest code necessary to reproduce it in the question itself preferably in a Stack Snippet using the <> icon. See How to create a Minimal, Reproducible Example Commented Aug 18, 2024 at 16:10
  • @Paulie_D Added some details, maybe it will help? Commented Aug 18, 2024 at 16:30
  • Not really, what does "make the columns in the second section the same as the first" mean? The same width? The same place as the column above? What is this supposed to look like? Also, as mentioned, we need an minimal reproducible example Commented Aug 18, 2024 at 18:02
  • Are you saying that there are always 7 photos in all - or is there a different layout required for e.g. narrower devices and/or might there be more or fewer photos? If you know it's 7 then an 8 column grid would easily do this for you. Commented Aug 18, 2024 at 19:57

2 Answers 2

2

.container {
  display: flex;
  width: 80vw;
  margin: 0 auto;
  justify-content: space-between;
  border: solid 1px green;
  text-align: center;
}

.full {
  border: solid 1px red;
  width: 100%;
}

.half {
  border: solid 1px blue;
  width: 50%;
}
<div class='container'>
  <div class='full'>1</div>
  <div class='full'>2</div>
  <div class='full'>3</div>
  <div class='full'>4</div>
</div>

<div class='container'>
  <div class='half'></div>
  <div class='full'>1</div>
  <div class='full'>2</div>
  <div class='full'>3</div>
  <div class='half'></div>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, on divs it works exactly how I need it. But I've tried it with sections and columns, section is "container" class, columns with infobox are "full" class, and empty columns are "half" class. And it looks like this: img
0

@DCR, your solution convinced me to use additional columns, but I gave them 12.5%. So... the top table has 4 columns with 25% width each, and the bottom has 5 columns with the width with following percentages: 12.5%, 25%, 25%, 25%, 12.5%.

This way the width of the ones at the bottom is identical to the ones at the top.

|   25%    |   25%    |   25%    |   25%    |
|12,5%|   25%    |   25%   |   25%    |12,5%|

Thanks.

1 Comment

what's important is the extra columns are half the size of the full columns - at least for a 4 , 3 frame. Check out flexbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.