2

Hi Im trying to create a div with responsive circles connected by a line using css3.

Example of the what im trying to do http://codepen.io/bookcasey/pen/cEntL

In the above example i want to make it responsive such that the circle size doesnot change but if width increases i want first and last circles to be on left side and right side of the UL and other circles position in between at equal distances. circles can increase or decrease least is two circles and a line.

thechoosenone
  • 129
  • 2
  • 8
  • 16

3 Answers3

5

You could use the solution of Justify the last line of a div? in order to make it full width.

And fake the line with absolute positioned pseudo-elements.

Demo

ul {
  text-align: justify;
  position: relative;
  overflow: hidden;
}
ul:before, .active:after {
  content: '';
  width: 100%;
  border: 2px solid dodgerblue;
  position: absolute;
  top: 1em;
  margin-top: -2px;
  z-index: -1;
}
.active:after {
  border-color: lightblue;
}
ul:after {
  content: "";
  display: inline-block;
  width: 100%;
}
li {
  width: 2em;
  height: 2em;
  text-align: center;
  line-height: 2em;
  border-radius: 50%;
  background: dodgerblue;
  margin: 0 1em;
  display: inline-block;
  color: white;
}
.active ~ li {
  background: lightblue;
}
body {
  font-family: sans-serif;
  padding: 2em;
}
Community
  • 1
  • 1
Oriol
  • 274,082
  • 63
  • 437
  • 513
  • Thank you so much @Oriol, Can you help me in one small thing in the above example, a small part of line is coming out of first circle and last circle, can we also keep it inside so that it looks like line start after circle and ends before last circle. – thechoosenone Mar 19 '14 at 18:08
  • @thechoosenone Not at all :) Just remove `li { margin: 0 1em; }`. [**Demo**](http://codepen.io/anon/pen/kpEyw/). – Oriol Mar 19 '14 at 18:09
  • tried it but after the last circle a part of line is coming out in the right hand side. – thechoosenone Mar 19 '14 at 18:13
  • im using Safari on Mac. – thechoosenone Mar 19 '14 at 18:21
  • @thechoosenone You can fix it commenting the spaces between `
  • ` elements, or using `font-size: 0` to `
      ` and resetting it to `
    • `s. [**Demo**](http://codepen.io/anon/pen/KifyB/)
  • – Oriol Mar 19 '14 at 18:36