0

I am having an issue with flexbox text wrapping. The <div> with display: flex; does wrap the text correctly but it's width remains on maximum instead of changing to fit the wrapped text's size.

So, here is the HTML Markup:

<div class="tagsFormSection">
    <div class="tagsHolder">
        <div class="labelItem">
            <div class="labelContent">EMPRESA DE TESTE 3</div>
            <div class="labelAditional">manager</div>
            <div class="labelClose">x</div>
        </div>
        <div class="labelItem">
            <div class="labelContent">COOBO SOLUÇÕES EM PROCUREMENT LTDA</div>
            <div class="labelAditional">admin</div>
            <div class="labelClose">x</div>
        </div>
    </div>
</div>

And the SCSS:

.tagsHolder {
    display: flex;
    flex-direction: row;
    margin-bottom: 10px;
    flex-wrap: wrap;
    .labelItem {
        display: flex;
        margin-right: 10px;
        align-items: center;
        margin-top: 2px;
        .labelContent,
        .labelAditional {
            font-weight: 600;
            padding: 5px 8px;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .labelContent {
            color: #fff; //background-color: #666;
            background-color: $gray-300;
            border-bottom-left-radius: 5px;
            border-top-left-radius: 5px;
            font-size: 0.7rem;
        }
        .labelAditional {
            color: #444;
            background-color: lighten(map-get($theme-colors, "success"), 10%);
            font-size: 0.6rem;
        }
        .labelClose {
            display: flex;
            justify-content: center;
            align-items: center;
            text-transform: uppercase;
            color: #fff; //background-color: #444;
            background-color: $gray-400;
            padding: 2px 6px;
            border-bottom-right-radius: 5px;
            border-top-right-radius: 5px;
            cursor: pointer;
            font-weight: 700;
            font-size: 0.7rem;
            height: 100%;
            position: relative;
            box-sizing: border-box;
            transition: all 0.25s ease-in-out;
            &:hover {
                //background-color: #555;
                background-color: $gray-500;
            }
        }
    }
}

Here is a screenshot of what is outputted:

Error example

Thanks in advance!

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701

0 Answers0