1

I have an input inside a div with flex-flow: row nowrap inside another div with flex-flow: column nowrap.

Why does the input grow(on Chrome it's 188px, YMMV), even if it doesn't have flex-grow: 1?

*, ::before, ::after {
    box-sizing: border-box;
}

.wrapper {
  align-items: stretch;
  background-color: #ffffff;
  border: 1px solid #ebf0ff;
  border-radius: 0.25rem;
  display: flex;
  flex-flow: column nowrap;
  margin: 0.75rem 0.5rem;
  max-width: 464px;
  padding: 1rem;
}

.input-wrapper {
  align-items: stretch;
  background-color: #ffffff;
  border: 1px solid #ebf0ff;
  display: flex;
  flex-flow: row nowrap;
  padding: 0.75rem;
}

input {
  border: none;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
}

input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.token-wrapper {
  align-items: center;
  display: flex;
  flex-flow: row nowrap;
  flex-shrink: 0;
  margin-left: 0.25rem;
}

.token-wrapper span {
  font-size: 1rem;
  font-weight: 700;
}

.separator {
  background-color: #ebf0ff;
  margin: 0.25rem 0rem 0.25rem 0.5rem;
  width: 1px;
}

.max-amount-wrapper {
  background-color: #ebf0ff;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-left: 0.5rem;
  padding: 0.5rem 0.375rem;
}

.max-amount-wrapper span {
  font-size: 0.75rem;
  font-weight: 400;
]
<div class="wrapper">
  <div class="input-wrapper">
    <input name="amount" placeholder="0" type="number" />
    <div class="token-wrapper">
      <span>DAI</span>
    </div>
    <div class="separator"></div>
    <div class="max-amount-wrapper">
      Max&nbsp;(<span>&nbsp;84&nbsp;</span>)
    </div>
  </div>
</div>
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114

1 Answers1

1

Thanks to one of @Michael_B's comments, I managed to identify the issue. Browsers set a minimum width to input tags.

I applied width: 0 on the input and the width scaled down to the value I was expecting.

Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114