Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add text next to a shape?

I am trying to add text next to the circle.

HTML

<div class="row">
   <div class="col-sm-2">
      <span><div class="circle"></div></span><p>available</p>

   </div>

 </div>

CSS

.circle {
width:10px;
height:10px;
border-radius:50px;
font-size:20px;
color:#fff;
line-height:100px;
background: green;

}

Right now, the circle is on top <p> tag. I am trying to add two circle: available and a red one saying not available. Also, if you know a better way to do this, please let me know.

Thanks,

like image 231
Maduro Avatar asked Oct 31 '25 23:10

Maduro


2 Answers

The div takes up 100% of the width by default, which is why your p tag wraps to the next line. You can set e.g. display:inline-block on the div to change this behaviour.

See this fiddle for your two circles.

like image 162
timgvandijk Avatar answered Nov 03 '25 14:11

timgvandijk


Just add the following code :

.col-sm-2 > span, .col-sm-2 > p {
  display: inline-block;
}

What this does is it causes the two elements span and paragraph <p> tags to become inline-block and hence align on the same line.

See this below :

.circle {
    width:10px;
    height:10px;
    border-radius:50px;
    font-size:20px;
    color:#fff;
    line-height:100px;
    background: green;
}

.col-sm-2 > span, .col-sm-2 > p {
  display: inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
    <div class="col-sm-2"> <span><div class="circle"></div></span>
        <p>available</p>
    </div>
</div>
like image 38
Satwik Nadkarny Avatar answered Nov 03 '25 14:11

Satwik Nadkarny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!