<div onclick="location.href='news';" class="news_other_layout" style="background-image: url('');">
</div><div onclick="location.href='news';" class="news_other_layout" style="background-image: url('');">
</div>
update it.
in your code, there is a newline character between the two div. When set to the inline-block element, if the font-size of the parent element is not 0, the newline character will take up a certain amount of space. As a result, the total width of the child element in the parent element is 50% + the width of the newline character + 50%
, which causes the second div to be squeezed below.
so the solution is:
- compress html, to remove line breaks;
- parent element font-size is set to 0pm div reset font-size;
- width is set to 49% or less.
< del > besides, you always say you want to use Flex layout, but you don't ask the landlord (? Is it really good to consider compatibility? Why not use Grid layout? < / del >
is not filling in the same row now?
if a parent div is wrapped around a flex layout
newline character, use float, or use flex
at the parent.
I have encountered a problem on your side. Although you set the display of div to inline-block, it is strange that the line wrapping between the two div tags still seems to take up some space, so that although their width is 50% and the total is 100%, they still cannot be side-by-side. You need to remove the space between the two div tags.
for example:
<div onclick="location.href='news';" class="news_other_layout" style="background-image: url('');">
</div><div onclick="location.href='news';" class="news_other_layout" style="background-image: url('');">
</div>