How to get both icon and title in one line in css

I want to mark the headers on the same line as follows:

enter image description here

but I still get the following:

enter image description here

The code:

.icon-small i{
  height: 38px;  
  width: 38px; 
  color: #fff;
  background-color: #888;
  border-radius: 10%;
  text-align: center;
  vertical-align: middle;
  padding-top: 12px;

}
.icon-small + p{
  margin-top: 15px;

}
.icon-small h4,
.icon-small h5{
  text-align: left;
}
<div class="row">
  <div class="col span-1-of-3">
    <span class="icon-small">
      <i class="fa fa-television"></i>
      <h4>Web applications</h4>
      <h5>Mobile & Tablets Ready</h5>
    </span>
    <p>Powerful, fast and robust web applications to cater for complex business needs.</p>
  </div>
  <div class="col span-1-of-3">
    <span class="icon-small">
      <i class="fa fa-mobile-phone"></i>
      <h4>Mobile apps</h4>
      <h5>For the iPhone, iPad & Android</h5>
    </span>
    <p>Apps that connect directly to your customers.</p>
  </div> 
  <div class="col span-1-of-3">
    <span class="icon-small">
      <i class="fa fa-image"></i>
      <h4> Graphic </h4>
      <h5>Infographics, site designs and more</h5>
    </span>
    <p>Let our graphics speak the thousand words that you simply don't have the time to say.</p> 
  </div>
</div>
Run codeHide result

I have only a few things, but it didn’t work. I used Font Awesome and the matching grid.

I used this to reset the default styles:

* {
    margin: 0px;
    padding: 0px;
    box-sizing: border-box;
}
+4
source share
4 answers

I think you want an floaticon:

.icon-small i {
    float: left;
    margin-right: 10px;
    /* ... */
}

And for a good measure:

.icon-small + p {
    clear: left;
    /* ... */
}

https://jsfiddle.net/mblase75/e42rsw04/

+2
source

: : - : .

<div class="logo">
    <div class="text">Some Text</div>
</div>

.text{
    position:relative;
}

.text::before {
    position:absolute;
    margin-left: -30px;
    background-image: url("youricon.png");
    background-color: #fff;
    height:<<height of your icon goes here>>;
    width:<<width of your icon goes here>>;
}

<div class="logo">
    <div class="icon"><img src="youricon.png" alt="Logo"></div>
    <div class="text">Some Text</div>
</div>


.logo{
    display: inline-block;
    width: 100%;
}

.icon, .text {
    display:inline;
}

.text{
    margin-left:10px;
}
+1

position:absolute -.

.icon-small {
    position: relative;
    padding: 0 0 0 48px; /* 38px icon width + 10px gap between icon and text */
}

.icon-small i {
    height: 38px;  
    width: 38px;
    position: absolute;
    left: 0;
    top: 0;
}
0

flexbox http://jsfiddle.net/hnsd4np6/2/

<div class="row container">
 <div class="col span-1-of-3 box">
   <span class="icon-small">
   <i class="fa fa-television"></i>
  <div class="details">
    <h4>Web applications</h4>
    <h5>Mobile & Tablets Ready</h5>
  </div>
</span>
<p>Powerful, fast and robust web applications to cater for complex business needs.</p>
</div>
<div class="col span-1-of-3 box">
  <span class="icon-small">
    <i class="fa fa-mobile-phone"></i>
    <div class="details">
      <h4>Mobile apps</h4>
      <h5>For the iPhone, iPad & Android</h5>
   </div>
</span>
<p>Apps that connect directly to your customers.</p>
</div> 
 <div class="col span-1-of-3 box">
   <span class="icon-small">
     <i class="fa fa-image"></i>
    <div class="details">
      <h4> Graphic </h4>
      <h5>Infographics, site designs and more</h5>
   </div>
</span>
</div>
</div>

, html-,

  • container row
  • box col span-1-of-3
  • details,

    CSS

.icon-small{
 display:flex;
flex-direction:row;
align-items:center;
}
  .details{
    padding:0 1em;
  }
.box{
    border:1px solid #333;
    background-color:#fff;
    width:300px;
    padding:1em;
   }
  .container{
    display:flex;
    flex-direction:row;
    flex-wrap:wrap;
    border:1px solid #333;
    background-color:powderblue;
   }

<br>

, flexbox clickhere

0

All Articles