My code has the following structure:
The h1 element is perfectly centered, however, I want to center horizontally the div inside the first one.
I’m trying to make it responsive.
For example, if there are 3
inside the main one, and in the screen fit only two side by side, the third one should be placed centered under the other two.
My code is this: https://jsfiddle.net/1yvjLjzq/
If you use inline-block instead of float then the elements will sit alongside each other and be centred by the text-align:center on the parent.
You will need to increase the 50% width on content-main though otherwise there won’t be room for them to sit side by side. Also vertical-align only applies to elements that are inline, inline-block or table-cell so the rule on content-main should be removed as it does nothing,
You could also do it this way:
I must have misunderstood as I thought the blocks were supposed to be side by side
You were right, this is what I wanted. Thank you
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.