Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flexbox not respecting width

Tags:

html

css

flexbox

I'm trying to get my head around flexbox only I can't quite figure some things out.

I've built a layout that has a left column of 290px and a right 'content area'.

I want the content area to be fluid and both to be 100% in height. I've somewhat achieved this, but if I populate the content area with something with a width of 100vw it pushes the left column down in size.

.right_col {
  min-height: 792px;
  height: 100%;
  margin-left: 0px;
  background: #F7F7F7;
  display: flex;
  padding: 0 !important;
  width: 100%;
}
.callout-panel {
  background: #fff;
  width: 290px;
  float: none;
  clear: both;
  padding: 0 20px;
}
.input-group {
  position: relative;
  display: table;
  border-collapse: separate;
}
.input-group .form-control,
.input-group-addon,
.input-group-btn {
  display: table-cell;
}
.input-group .form-control {
  position: relative;
  z-index: 2;
  float: left;
  width: 100vw;
  margin-bottom: 0;
}
<div class="right_col">
  <div class="callout-panel">Left column</div>
  <section class="page-inner">
    <div class="input-group">
      <input type="text" class="form-control" placeholder="Search">
      <span class="input-group-btn">
             <button class=" btn-search" type="button" ></button>
       </span>
    </div>
  </section>
</div>
like image 290
Liam Avatar asked Jan 11 '17 16:01

Liam


1 Answers

An initial setting of a flex container is flex-shrink: 1.

This means that a flex item is allowed to shrink, in order to not overflow the container.

Instead of width: 290px try this:

flex: 0 0 290px; /* can't grow, can't shrink, fixed at 290px */

Or just add flex-shrink: 0 to the rule (.callout-panel) in order to disable shrinking.

For more details see:

  • What are the differences between flex-basis and width?
  • Flexbox - two fixed width columns, one flexible
like image 58
Michael Benjamin Avatar answered Oct 13 '22 17:10

Michael Benjamin