Looking to optimize the positioning of a list of items using flexbox. I've managed to solve it with the usual methods, but now I want to enhance my code by utilizing better tools like flexbox. Here is what I currently have:
https://i.sstatic.net/OzKRa.png
However, I aspire to achieve the following layout with Flexbox:
https://i.sstatic.net/hJFa2.png
HTML
<div
v-for="item in list"
:key="item.id+Math.random()"
class="neo-form-toggle-list__item neo-form-toggle neo-form-toggle--checkbox slideout--checkbox container--checkbox"
>
<div class="checkbox--group">
<input
class="neo-form-toggle__field"
type="checkbox"
:id="item.id"
name="rule"
:checked="checked"
/>
<label
class="neo-form-toggle__label checkbox--label rule"
:class="item.templateRule.title.length > 5 ? 'rule__big--title' : 'rule__small--title'"
:for="item.id">
{{ item.templateRule.title }}
</label>
<p class="item">{{ item.templateRule.description }}</p>
</div>
</div>
My css bellow:
.neo-form-toggle__label {
&.checkbox--label {
text-transform: none;
font-weight: normal;
font-size: 12px;
float: right;
margin-right: 3%;
&.rule {
font-weight: bold;
&__big--title {
margin-right: 1rem;
}
&__small--title {
margin-right: 5rem;
}
}
}
}
.neo-form-toggle {
&.neo-form-toggle--checkbox {
&.checkbox--margin {
margin-right: 2.25rem !important;
}
}
}
.neo-form-toggle {
&.neo-form-toggle--checkbox {
&.slideout--checkbox {
width: 13rem;
}
&.checkbox--margin {
margin-right: 2.25rem !important;
}
&.container--checkbox {
margin-right: 5rem;
margin-bottom: 0;
}
}
}
Although I've started learning about Flexbox, I'm still struggling to grasp its functionality. Any guidance on enhancing this CSS would be greatly appreciated.