Kovac
Kovac

Reputation: 21

How to display paragraphs as a horizontal list?

I want my site to have an about section with one (col-1) section above others. And underneath that section, 3 columns which describe 3 aspects of my life.

I tried inline-block and can't get it working, but I would really like this method to succeed because of its flexibility.

html

<body>
  <section class="about">
    <h1>WHO I AM</h1>
    <div class="col-1">
      <h3>About me</h3>
      <p>sometihing
      </p>
    </div>
    <div class="col-3">
      <h3>My work</h3>
      <p>Something
      </p>
    </div><br>
    <div class="col-3">
      <h3>Ambitions</h3>
      <p>Something
      </p>
    </div>
    <div class="col-3">
      <h3>Accomplishments</h3>
      <p>Something
      </p>
    </div>
  </section>
</body>

css

.about {
  h1 {
    text-align: center;
    line-height: 200%;
  }
  p {
    line-height: 200%;
  }
  color: white;
  .col-1 {
    text-align: center;
    margin-right: 20em;
    margin-left: 20em;
  }

  .col-3 {
    display: inline-block;
  }
}

This is what I get: http://prntscr.com/mdwl74. This is what I want to get: http://prntscr.com/mdwkt6.

P.S. my body has id home

Upvotes: 2

Views: 651

Answers (2)

user10958959
user10958959

Reputation:

the float, box-sizing, and width property are both important here:

* {
  box-sizing: border-box;
}

.col-1 {
  text-align: center;
}

.float-next {
  float: left;
  width: 33.33%;
  text-align: center;
  padding: 10px;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}
<body>
  <section class="about">
    <h1>WHO I AM</h1>
    <div class="col-1">
      <h3>About me</h3>
      <p>sometihing
      </p>
    </div>
    <div class="col-3 float-next">
      <h3>My work</h3>
      <p>Something
      </p>
    </div><br>
    <div class="col-3 float-next">
      <h3>Ambitions</h3>
      <p>Something
      </p>
    </div>
    <div class="col-3 float-next">
      <h3>Accomplishments</h3>
      <p>Something
      </p>
    </div>
  </section>
</body>

Upvotes: 2

d-h-e
d-h-e

Reputation: 2548

flexbox is a good tool for this. You only need one wrapper Element (flexbox-container).

.flexbox-container {
  display: flex;
  justify-content: space-between;
  flex-flow: row nowrap;
}
<body>
  <section class="about">
    <h1>WHO I AM</h1>
    <div class="col-1">
      <h3>About me</h3>
      <p>sometihing
      </p>
    </div>
    <div class="flexbox-container">
      <div class="col-3">
        <h3>My work</h3>
        <p>Something
        </p>
      </div>
      <div class="col-3">
        <h3>Ambitions</h3>
        <p>Something
        </p>
      </div>
      <div class="col-3">
        <h3>Accomplishments</h3>
        <p>Something
        </p>
      </div>
    </div>
  </section>
</body>

Upvotes: 4

Related Questions