我无法让fa图标左对齐我的h3标题

时间:2019-03-21 23:17:44

标签: html css twitter-bootstrap-3

我尝试了一些在网上找到的技巧,但是在不失去格式,大小和位置颜色的前提下,我无法将其排列起来。等等。我希望所有文字和图像都居中。我不知道。

这是我当前的代码和CSS:`

管道螺纹 在管道穿线方面,我们有您的支持。我们使用最好的技术来确保准确和精确的穿线。

这是我的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>

`

3 个答案:

答案 0 :(得分:1)

添加了col-center类,该类可以应用于您的列以使框正确居中。

.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>

答案 1 :(得分:0)

您可以将h3标题包含在fa div中。例如: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>

答案 2 :(得分:0)

您可以使用flexbox实现此目的。

您需要进行一些包装,移除图标上的位置,更改右列上的弯曲方向,等等...

master

提琴:https://jsfiddle.net/srtk05mx/12/