css - flexbox:last-of-type not working -
i've several flexboxes in container - have margin-bottom of e.g. 40px - i'd rid of margin of last flexbox within container - .flexbox:last-of-type not work - same :first-of-type, :last-child.
am missing here - hope can help.
thank in advance input.
i'm referring this:
<div class="container"> <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> </div> targeting last .flex .flex:last-of-type doesn't work me?
those pseudo-classes work, ass seen in following example:
.flex { display: flex; flex-direction: column; border: 1px solid blue; } span { height: 30px; width: 30px; border: 1px solid; margin-bottom: 10px; } span:last-child { margin-bottom: 0; } <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> however, might use row layout , last line contains more 1 flex-item. then, if remove margin of last flex-item, seem still has margin because of margin of other flex-items in line.
.flex { display: flex; flex-flow: row wrap; width: 64px; border: 1px solid blue; } span { height: 30px; width: 30px; border: 1px solid; margin-bottom: 10px; } span:last-child { margin-bottom: 0; } <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> to avoid problem, can add negative margin flex container neutralize margin of last row, , place flex container inside wrapper overflow: hidden.
.outer { overflow: hidden; width: 64px; border: 1px solid blue; } .flex { display: flex; flex-flow: row wrap; margin-bottom: -10px; } span { height: 30px; width: 30px; border: 1px solid; margin-bottom: 10px; } <div class="outer"> <div class="flex"> <span></span> <span></span> <span></span> <span></span> </div> </div>
Comments
Post a Comment