This new value for the display
property allows you to somehow remove an element from the box tree but still keep its contents.
display: contents
makes that the div doesn’t generate any box, so its background, border and padding are not rendered. However the inherited properties like color and font have effect on the child (element as expected.
<div style="border: 1px solid red;
padding: 20px;color: white; font: 15px; Monospace; background: red;">
<span style="background: black;">foobar</span>
</div>
display: contents
makes that the div
doesn’t generate any box, so its background, border and padding are not rendered. However the inherited properties like color
and font
have effect on the child (span
element) as expected.
display:contents
<div style="display: contents; border: 1px solid red;
padding: 20px;color: white; font: 15px; Monospace; background: red;">
<span style="background: black;">foobar</span>
</div>
<span style="background: black; color: white;
font: 15px;">foobar</span>
Here in desktop we have 2 columns that is combined into group as shown in screenshot below
Changes we have to do in mobile to change the order of blocks.
that has row1 and row2 combined in it should be given following css in mobile
display: flex;
flex-direction: column;
2) and should be given following css in mobile. causes an element's children to appear as if they were direct children of the element's parent, ignoring the element itself. So when display:contents property is used, row 1 and row 2 will be ignored and all columns will be treated as direct children of group.
display: contents;
3) Now we can give whatever ordering we want to give to columns. As per output required the ordering will be like this -
1
order: 3;
2
order: 2;
3
order: 4;
4
order: 5;
5
order: 1;
6
order: 6;