html – I can't get my fa icon to line up left to my h3 title-ThrowExceptions

Exception or error:

I’ve tried a couple of tricks I found online here, but I can’t get it to line up without losing my formatting, size, position color. etc. I want it all text and images to be centered. I can’t figure it out.

This is my current code and CSS:

PIPE THREADING
When it comes to pipe threading we have your back. We use the best technology to ensure accurate and precise threading.

here is my css

.demo {
  padding: 100px 0;
}

.heading-title {
  margin-bottom: 100px;
}

.serviceBox {
  padding: 30px 30px 30px 90px;
  background: #f8f8f8;
  color: #333;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover {
  background: #645e9d;
  color: #fff;
}

.serviceBox:after {
  content: "";
  display: block;
  border-top: 500px solid #fff;
  border-left: 500px solid transparent;
  margin-top: -55%;
  margin-left: 100%;
  opacity: 0;
  position: absolute;
  transform: scale(2);
  transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover:after {
  margin-left: 0;
  opacity: 0.1;
}

.serviceBox .service-icon {
  font-size: 50px;
  color: #645e9d;
  position: absolute;
  top: 40px;
  left: 20px;
  transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover .service-icon {
  color: #fff;
}

.serviceBox .title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px 0;
  text-transform: capitalize;
}

.serviceBox .description {
  font-size: 15px;
  color: #a3a3a3;
  line-height: 25px;
  margin: 0;
  transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover .description {
  color: #fff;
}

@media only screen and (max-width: 990px) {
  .serviceBox {
    margin-bottom: 15px;
  }
}
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>

<body>

  <div class="demo">
    <div class="container">
      <div class="row">

        <div class="col-md-4 col-sm-6">
          <div class="serviceBox">
            <div class="service-icon"><i class="icon fa fa-check-square-o" aria-hidden="true"></i></div>
            <h3 class="title">PIPE THREADING</h3>
            <p class="description">When it comes to pipe threading we have your back. We use the best technology to ensure accurate and precise threading.</p>
            <img class="rounded mx-auto d-block" src="wp-content/uploads/2019/03/pipethreading.jpg" alt="..." />
          </div>
        </div>
      </div>
    </div>
  </div>

</body>

</html>
How to solve:

You could include the h3 title into the fa div. As an example: https://jsfiddle.net/quyovr9a/

.demo
{
	padding: 100px 0;
}

.title {
	display: inline-block;
}

.description {
	padding-top: 90px;
}

.heading-title
{
	margin-bottom: 100px;
}
.serviceBox{
    padding: 30px 30px 30px 90px;
    background: #f8f8f8;
    color: #333;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover{
    background: #645e9d;
    color: #fff;
}

.serviceBox:after{
    content: "";
    display: block;
    border-top: 500px solid #fff;
    border-left: 500px solid transparent;
    margin-top: -55%;
    margin-left: 100%;
    opacity: 0;
    position: absolute;
    transform: scale(2);
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover:after{
    margin-left: 0;
    opacity: 0.1;
}

.serviceBox .service-icon{
    font-size: 50px;
    color: #645e9d;
    position: absolute;
    top: 40px;
    left: 20px;
    transition:all 0.3s ease-in-out 0s;
}

.serviceBox:hover .service-icon{
    color: #fff;
}

.serviceBox .title{
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 12px 0;
    text-transform: capitalize;
}

.serviceBox .description {
    font-size: 15px;
    color: #a3a3a3;
    line-height: 25px;
    margin: 0;
    margin-left: -8px;
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox .rounded_mx-auto_d-block {
    margin-left: -6px;
}

.serviceBox:hover .description{
    color: #fff;
}

@media only screen and (max-width: 990px){
    .serviceBox{ margin-bottom: 15px; }
}
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>

<div class="demo">
<div class="container">
<div class="row">

<div class="col-md-4 col-sm-6">
<div class="serviceBox">
<div class="service-icon"><i class="icon fa fa-check-square-o" aria-hidden="true"></i> <h3 class="title">PIPE THREADING</h3></div>
<p class="description">When it comes to pipe threading we have your back. We use the best technology to ensure accurate and precise threading.</p>
<img class="rounded_mx-auto_d-block" src="wp-content/uploads/2019/03/pipethreading.jpg" alt="..." />
</div>
</div>
</div>
</div>
</div>

</body>
</html>

###

Added a col-center class that can be applied to your column to center the box properly.

.col-center {
  float: none !important;
  margin: auto;
}
.demo
{
	padding: 100px 0;
}
.heading-title
{
	margin-bottom: 100px;
}
.serviceBox{
    padding: 30px 30px 30px 90px;
    background: #f8f8f8;
    color: #333;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover{
    background: #645e9d;
    color: #fff;
}

.serviceBox:after{
    content: "";
    display: block;
    border-top: 500px solid #fff;
    border-left: 500px solid transparent;
    margin-top: -55%;
    margin-left: 100%;
    opacity: 0;
    position: absolute;
    transform: scale(2);
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover:after{
    margin-left: 0;
    opacity: 0.1;
}

.serviceBox .service-icon{
    font-size: 50px;
    color: #645e9d;
    position: absolute;
    top: 40px;
    left: 20px;
    transition:all 0.3s ease-in-out 0s;
}

.serviceBox:hover .service-icon{
    color: #fff;
}

.serviceBox .title{
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 12px 0;
    text-transform: capitalize;
}

.serviceBox .description{
    font-size: 15px;
    color: #a3a3a3;
    line-height: 25px;
    margin: 0;
    transition: all 0.3s ease-in-out 0s;
}

.serviceBox:hover .description{
    color: #fff;
}

@media only screen and (max-width: 990px){
    .serviceBox{ margin-bottom: 15px; }
}


.col-center {
  float: none !important;
  margin: auto;
}
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>

<div class="demo">
<div class="container">
<div class="row">

<div class="col-md-4 col-sm-6 col-center">
<div class="serviceBox">
<div class="service-icon"><i class="icon fa fa-check-square-o" aria-hidden="true"></i></div>
<h3 class="title">PIPE THREADING</h3>
<p class="description">When it comes to pipe threading we have your back. We use the best technology to ensure accurate and precise threading.</p>
<img class="rounded mx-auto d-block" src="wp-content/uploads/2019/03/pipethreading.jpg" alt="..." />
</div>
</div>
</div>
</div>
</div>

</body>
</html>

###

You can use flexbox to achieve this.

You need to do some wrapping, remove your positioning on the icon, change flex-direction on the right column, etc…

.serviceBox {
  display:flex;
}


.box-left {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.box-right {
    display: flex;
    flex-direction:column;
    justify-content: center;
    align-items: flex-start;
    flex: 3;
}

Fiddle: https://jsfiddle.net/srtk05mx/12/

Leave a Reply

Your email address will not be published. Required fields are marked *