chaitanya90
chaitanya90

Reputation: 707

css: how to make circles connected by lines responsive with bootstrap?

I have the code which got me three circles connected by two lines. Have a look here: JSFIDDLE

Here is my code:

HTML

<div class="form-group">
            <div class="col-md-4"></div>
            <div class="col-md-4">              
            <div class="circle" style="float:left;"></div>
            <div id="horizontal" style="float:left;"></div>
            <div class="circle" style="float: right;"></div>
            <div id="horizontal" style="float: right;"></div>
            <div class="circle"></div>
            </div>
            <div class="col-md-4"></div>
            </div>              
        </div>

CSS

#horizontal
{
 width: 230px;
 border-bottom: 2px solid #CCCCCC;
 padding-top: 6px;
}
.circle {
  background: #CCCCCC;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border:1px solid #CCCCCC;
}

But this wont be responsive as i am setting width component to it. Is there anyway i can make it responsive using twitter bootstrap.

Using @media queries wont help for this case. Any help will be appreciated.

Upvotes: 1

Views: 10878

Answers (3)

G-Cyrillus
G-Cyrillus

Reputation: 105863

For info:

You could use a background-image or gradient too : DEMO

CSS revisited

.form-group {
    background:linear-gradient(to top,#cccccc,#cccccc) repeat-x center;/* gradient can be replace for a 1pixel gray image */
    background-size:2px 2px;
    min-width:50px;/* keep those 3 15px boxes on one line */

}
.circle {
    background: #CCCCCC;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border:1px solid #CCCCCC;
    margin:auto;
}

& less HTML

<div class="form-group">
    <div class="circle" style="float:left"></div>
    <div class="circle" style="float: right;"></div>
    <div class="circle"></div>
</div>

Upvotes: 2

misterManSam
misterManSam

Reputation: 24692

The simplest solution contains two divs and two pseudo elements. position: absolute keeps the circles over the parents border and position: relative keeps the circles positioned relative to the parent.

Have an example!

HTML

<div class="parent"><div class="child"></div></div>

CSS

* {
  margin:0;
  padding:0;
}

.parent {
  margin:100px 0 0;
  width:100%;
  border-bottom:2px solid #CCC;
  position:relative;
  z-index:-1;
}

.parent:before,.parent:after,.child {
  background:#CCC;
  width:15px;
  height:15px;
  border-radius:50%;
  border:1px solid #CCC;
  position:absolute;
  content:'';
  top:-8px;
}

.parent:before {
  left:0;
}

.parent:after {
  right:0;
}

.child {
  left:50%;
  margin-left:-8px;
}

Upvotes: 1

Bodzio
Bodzio

Reputation: 2520

Try this:

html:

<div class="responsive-circle"><i></i></div>

css:

.responsive-circle {
    height: 2px;
    background-color: #CCC;
    overflow: visible;
    position: relative;
}

.responsive-circle:before,
.responsive-circle:after,
.responsive-circle > i {
    background: #CCCCCC;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border:1px solid #CCCCCC;
    position: absolute;
    content: "";
    top: -7px;
}

.responsive-circle:after {
    right: 0;
}

.responsive-circle > i {
    left: 50%;
    left: calc(50% - 9px);
}

demo: http://jsfiddle.net/m787ydjz/

Upvotes: 0

Related Questions