GibboK
GibboK

Reputation: 73988

How to set the height of a flex box without setting its position to absolute?

I need to assign a dimension of height: 50px to

.panelDraggable__header 
.panelDraggable__info 
.panelDraggable__footer 

Using the following code I am not able to set the height, if you trying to inspect .panelDraggable__header its computed value is 18px.

Only way is when I adjust the position to absolute, which disrupt my layout.

#panelDevTools {
  position: fixed;
  top: 25px;
  left: 50px;
  width: 260px;
  height: 300px;
  background-color: yellow;
}
.panelDraggable {
  display: flex;
  -webkit-flex: auto;
  -ms-flex: auto;
  flex: auto;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}
.panelDraggable__header {
  order: 0;
  background-color: greenyellow;
  height: 50px;
}
.panelDraggable__info {
  order: 1;
  background-color: lightseagreen;
  height: 50px;
}
.panelDraggable__content {
  order: 3;
  background-color: slategrey;
}
.panelDraggable__footer {
  order: 4;
  background-color: blueviolet;
  height: 50px;
}
<div data-ntv-type="PanelDevTools" class="panelDraggable" id="panelDevTools" widgetid="panelDevTools">
  <div id="panelDevTools__info" class="panelDraggable__info">Tools for developement</div>
  <div id="panelDevTools__content" class="panelDraggable__content">
    <div id="cnt-inner" style="height:800px;width:50px;background-color:red;"></div>
  </div>
  <div id="panelDevTools__footer" class="panelDraggable__footer ">Footer</div>
  <div id="panelDevTools__header" class="panelDraggable__header">
    <div id="panelDevTools__title" class="panelDraggable__title">Developer Tools</div>
    <div id="panelDevTools__handle" class="panelDraggable__handle"></div>
    <div id="panelDevTools__help" class="panelDraggable__help"></div>
  </div>
</div>

Upvotes: 1

Views: 458

Answers (1)

Victor Radu
Victor Radu

Reputation: 2292

just use min-height instead of height as you actually what the height to be flexible but at least 50px

#panelDevTools {
  position: fixed;
  top: 25px;
  left: 50px;
  width: 260px;
  height: 300px;
  background-color: yellow;
}
.panelDraggable {
  display: flex;
  -webkit-flex: auto;
  -ms-flex: auto;
  flex: auto;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}
.panelDraggable__header {
  order: 0;
  background-color: greenyellow;
  min-height: 50px;
}
.panelDraggable__info {
  order: 1;
  background-color: lightseagreen;
  min-height: 50px;
}
.panelDraggable__content {
  order: 3;
  background-color: slategrey;
}
.panelDraggable__footer {
  order: 4;
  background-color: blueviolet;
  min-height: 50px;
}
<div data-ntv-type="PanelDevTools" class="panelDraggable" id="panelDevTools" widgetid="panelDevTools">
  <div id="panelDevTools__info" class="panelDraggable__info">Tools for developement</div>
  <div id="panelDevTools__content" class="panelDraggable__content">
    <div id="cnt-inner" style="height:800px;width:50px;background-color:red;"></div>
  </div>
  <div id="panelDevTools__footer" class="panelDraggable__footer ">Footer</div>
  <div id="panelDevTools__header" class="panelDraggable__header">
    <div id="panelDevTools__title" class="panelDraggable__title">Developer Tools</div>
    <div id="panelDevTools__handle" class="panelDraggable__handle"></div>
    <div id="panelDevTools__help" class="panelDraggable__help"></div>
  </div>
</div>

Upvotes: 3

Related Questions