Trying to left-align text in a centered element

Viewed 61

I am trying to achieve what you see at the bottom of the panel in the image below. Each of the 3 items are centered but the text is left aligned.

I have developed the following basic CSS and HTML code. I am trying to use flexbox as much as possible for responsive layout. Anyone have any pure HTML/CSS solution?

I understand that the p tag is a block level element. So what are my options without setting the width of the p tag? Or maybe there is another tag I could use?

The HTML and CSS code I have provided below has the basic structure only.

enter image description here

.panel {
  display: flex;
  border: 1px solid black;
  min-height: 300px;
  flex-direction: column;
  max-width: 500px;
}

.panel-body {
  display: flex;
  flex: 1;
  flex-flow: row wrap;
  justify-content: center;
}

.panel-heading {
  padding: 10px 10px;
}

.panel-body div.chart {
  flex: 0 0 100%;
  min-height: 150px;
  background-color: green;
}

.panel-body div {
  text-align: center;
  flex: auto;
  background-color: red;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

p {
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
}
<div class="panel">
  <div class="panel-heading">
    HEADING
  </div>
  <div class="panel-body">
    <div class="chart"></div>
    <div>
      <p>HIGH
        <br/>144</p>
    </div>
    <div>MEDIUM
      <br/>2</div>
    <div>LOW
      <br/>3</div>
  </div>
</div>

2 Answers
Related