Answers for "spacing between items in flex"

CSS
2

css flex gap between items

/* limited support (Q1/2021: Firefox, Chrome, Safari) */
.flex-container
{
  display: flex;
  gap: 5px;
}

/* broad support */
.flex-item
{
  margin: 5px;
  /* and/or */
  padding: 5px;
}
Posted by: Guest on February-25-2021
0

flex lines between items

######## HTML ########
<div class="Container">
    <ul class="Flex">
        <li class="Flex-item">Lorem</li>
        <li class="Flex-item">consectetur</li>
        <li class="Flex-item">vestibulum</li>
        <li class="Flex-item">nec</li>
        <li class="Flex-item">condimentum</li>
    </ul>
</div>

########## CSS ###########
html {
    box-sizing: border-box;
}

.Container {
    max-width: 70%;
    margin-right: auto;
    margin-left: auto;
    background: blue;
    padding-top: 20px;
    padding-bottom: 20px;
}

.Flex {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-between;
    list-style: none;
    margin: 0;
    padding: 0;
}

.Flex-item {
    flex: 1 1 auto;
    background: red;
    position: relative;
    text-align: center;
    line-height: 40px;
}

.Flex-item + .Flex-item {
    border-left: solid 1px white;
}

/** Optional for OPs exact layout */

.Flex-item:first-child {
    text-align: left;
}

.Flex-item:last-child {
    text-align: right;
}

reference:
https://stackoverflow.com/questions/41631136/add-dividing-line-between-flex-items-with-equal-space-distribution/42160101
Posted by: Guest on June-11-2021

Code answers related to "spacing between items in flex"

Browse Popular Code Answers by Language