Search code examples
htmlcsslayoutpsd

How to place lines between circles with images?


I am beginner with HTML and CSS so I decided to try code .psd layout. Unfortunately, I am stuck with that part of layout:

enter image description here

I mean that lines between circles with images. Here is my code for that:

html {
    font-size: 62.5%;
}

body {
  width: 1400px;
  font-family: "Roboto Slab", serif;
}

section {
  padding-right: 230px;
  padding-left: 230px;
}

.culture {
    padding-top: 100px;
    padding-bottom: 100px;
    background-color: #f9f9f9;
    overflow: auto;
}

h2 {
    font-family: "Montserrat", sans-serif;
    font-size: 4rem;
    color: #222;
    text-align: center;
}

.culture p {
    color: #777;
    text-align: center;
}

.culture > p {
    padding-top: 20px;
    padding-bottom: 89px;
    font-size: 2rem;
}

.value {
    float: left;
    padding-right: 56px;
}

.line {
    width: 170px;
    height: 2px;
    background-color: #777;
}

.value_img {
    width: 91px;
    height: 91px;
    margin: 0 auto 25px;
    border: 2px #777 solid;
    border-radius: 100%;
    background-repeat: no-repeat;
    background-position: center center;
}

.balance {
    background-image: url("http://d-k.aq.pl/note.png");
}

.quality {
    background-image: url("http://d-k.aq.pl/chart.png");
}

.excellence {
    background-image: url("http://d-k.aq.pl/star.png");
}

h3 {
    font-family: "Montserrat", sans-serif;
    font-size: 1.8rem;
    color: #222;
    text-align: center;
}

.value p {
    padding-top: 20px;
    font-size: 1.4rem;
}
<head>
  <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700" rel="stylesheet" type="text/css">
</head>
<section class="culture">
  <h2>
    CULTURE &amp; VALUES
  </h2>
  <p>
    Phasellus gravida ex at odio elementum.
  </p>
  <div class="value">
    <div class="value_img balance">
                        
    </div>
    <h3>
      WORK-LIFE BALANCE
    </h3>
    <p>
      Suspendisse ut odio vel felis pulvinar<br>
      sodales. Nunc ultricies nibh non velit<br>
      feugiat cursus. Phasellus scelerisque
    </p>
  </div>
  <div class="line">
                    
  </div>
  <div class="value">
    <div class="value_img quality">
                    
    </div>
    <h3>
      QUALITY OVER QUANTITY
    </h3>
    <p>
      Suspendisse ut odio vel felis pulvinar<br>
      sodales. Nunc ultricies nibh non velit<br>
      feugiat cursus. Phasellus scelerisque.
    </p>
  </div>
  <div class="line">
                    
  </div>
  <div class="value">
    <div class="value_img excellence">
                        
    </div>
    <h3>
      DELIVER EXCELLENCE
    </h3>
    <p>
      Suspendisse ut odio vel felis pulvinar<br>
      sodales. Nunc ultricies nibh non velit<br>
      feugiat cursus. Phasellus scelerisque.
    </p>
  </div>
</section>

Should I use absolute positioning for them?


Solution

  • You can use pseudo elements and negative margins :

    .value + .value .value_img:before {
      content: '';
      display: block;
      margin: 50px 0 0 -190px;
      width: 170px;
      height: 2px;
      background-color: #777;
    }
    
    .line {/* deleted from html */}
    

    you may also take a look at display:flex to set the layout instead float, margin can be used too instead fixed average padding values

    html {
      font-size: 62.5%;
    }
    body {
      width: 940px;/* padding of section removed */
      font-family: "Roboto Slab", serif;
      margin: auto;
    }
    section {
      /* ?? 
      padding-right: 230px;
      padding-left: 230px;
      */
    }
    .culture {
      padding-top: 100px;
      padding-bottom: 100px;
      background-color: #f9f9f9;
      overflow: auto;
      display: flex;/* set things easily and will allow vertical and or horizontal alignements */
      flex-wrap: wrap;/* we need this here */
    }
    h2 {
      font-family: "Montserrat", sans-serif;
      font-size: 4rem;
      color: #222;
      text-align: center;
      width: 100%;
    }
    .culture p {
      color: #777;
      text-align: center;
    }
    .culture > p {
      padding-top: 20px;
      padding-bottom: 89px;
      font-size: 2rem;
      width: 100%;
    }
    .value {
      padding: 0 28px;/* around equally , helps to center things visually */
    }
    /* draw the lines here, .value + .value .. does not select first */
    .value + .value .value_img:before {
      content: '';
      display: block;
      margin: 50px 0 0 -190px;
      width: 170px;
      height: 2px;
      background-color: #777;
    }
    .line {/* no need no more */} 
    .value_img {
      width: 91px;
      height: 91px;
      margin: 0 auto 25px;
      border: 2px #777 solid;
      border-radius: 100%;
      background-repeat: no-repeat;
      background-position: center center;
    }
    .balance {
      background-image: url("http://d-k.aq.pl/note.png");
    }
    .quality {
      background-image: url("http://d-k.aq.pl/chart.png");
    }
    .excellence {
      background-image: url("http://d-k.aq.pl/star.png");
    }
    h3 {
      font-family: "Montserrat", sans-serif;
      font-size: 1.8rem;
      color: #222;
      text-align: center;
    }
    .value p {
      padding-top: 20px;
      font-size: 1.4rem;
    }
    <head>
      <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
      <link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700" rel="stylesheet" type="text/css">
    </head>
    <section class="culture">
      <h2>
        CULTURE &amp; VALUES
      </h2>
      <p>
        Phasellus gravida ex at odio elementum.
      </p>
      <div class="value">
        <div class="value_img balance">
    
        </div>
        <h3>
          WORK-LIFE BALANCE
        </h3>
        <p>
          Suspendisse ut odio vel felis pulvinar
          <br>sodales. Nunc ultricies nibh non velit
          <br>feugiat cursus. Phasellus scelerisque
        </p>
      </div>
    
      <div class="value">
        <div class="value_img quality">
    
        </div>
        <h3>
          QUALITY OVER QUANTITY
        </h3>
        <p>
          Suspendisse ut odio vel felis pulvinar
          <br>sodales. Nunc ultricies nibh non velit
          <br>feugiat cursus. Phasellus scelerisque.
        </p>
      </div>
    
      <div class="value">
        <div class="value_img excellence">
    
        </div>
        <h3>
          DELIVER EXCELLENCE
        </h3>
        <p>
          Suspendisse ut odio vel felis pulvinar
          <br>sodales. Nunc ultricies nibh non velit
          <br>feugiat cursus. Phasellus scelerisque.
        </p>
      </div>
    </section>