Issue
How do I change the order of this code in mobile?
Currently on desktop <div class="grid4-12">
(left) and <div class="grid8-12">
(right) are stacked to each other.
How do I change the code in responsive such that <div class="grid8-12">
is on top and <div class="grid4-12">
is at the bottom?
Code below
<div class="card-content-lg" style=" background: #ffffff;">
<div class="grid4-12">
<div class="quote-wrapper test">
<div class="quote-col1 test">
<div class="quote-image"><img alt="Image1" src="/images" /></div>
</div>
<div class="quote-col2 test2">
<div class="quote-text">This is only test</div>
</div>
<div class="quote-col3">
<div><img alt="ABC" src="/images" /></div>
</div>
</div>
</div>
<div class="grid8-12">
<div class="card-content-md">
<h2 class="abc">This is h2 text</h2>
<p>This is a test.</p>
</div>
</div>
</div>
Solution
You can give the parent class (.card-content-lg) a display value of flex, with flex-direction set to column. Then, on the "second" / "right" element, give it a value of "order: -1;". Then, change the value of flex-direction to "row" on larger viewports, and change the order back to 1.
.card-content-lg {
display: flex;
flex-direction: column;
}
@media all and (min-width: 640px) {
.card-content-lg {
display: flex;
flex-direction: row;
}
}
.grid4-12, .grid8-12 {
background: gray;
min-height: 6rem;
margin: 1rem;
padding: 1rem;
color: white;
}
.grid8-12 {
order: -1;
}
@media all and (min-width: 640px) {
.grid8-12 {
order: 1;
}
}
<div class="card-content-lg" style=" background: #ffffff;">
<div class="grid4-12">
<div class="quote-wrapper test">
<div class="quote-col1 test">
<div class="quote-image"><img alt="Image1" src="/images" /></div>
</div>
<div class="quote-col2 test2">
<div class="quote-text">This is only test</div>
</div>
<div class="quote-col3">
<div><img alt="ABC" src="/images" /></div>
</div>
</div>
</div>
<div class="grid8-12">
<div class="card-content-md">
<h2 class="abc">This is h2 text</h2>
<p>This is a test.</p>
</div>
</div>
</div>
Answered By - yerme
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.