Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

best practice for flex box

How can I avoid repeating (display:flex, justify-content:center , aign-items:center) in my codes?I want to use them but I don’t want to repeat my self (DRY rule).
is there any way to define a variable or something which contains those three lines? (WITHOUT USING SASS)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Make a template class for all flexboxes in your code:

.flexbox {
display: flex;
justify-content: center;
align-items: center;
}
<div class="flexbox navbar-flexbox">*some code*</div>
<div class="flexbox content-flexbox">*some code*</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading