poseid
poseid

Reputation: 7156

How to make a CSS bar go from right to left?

Most examples on CSS bars are showing how to make a wrapper, and have an inner bar going from left to right.

I am looking to combine 2 bars, one from left to right, but on the same hight a bar from right to left.

So far, I have:

<div id="skills">
  <div class="grid left">
    <div class="bar pct-75"><div class="inner"></div>   </div>
  </div>
  <div class="labels">
    <p>Label</p>
  </div>

  <div class="grid right">
    <div class="bar pct-75"><div class="inner"></div>   </div>
  </div>
</div>

And CSS:

.grid {
  border-left: 1px dotted #e8ab6a;
  border-bottom: 1px dotted #e8ab6a;
  float: left;
  padding: 10px 0;
  position: relative;
}

.bar {
  height: 15px;
  margin-bottom: 20px;
  position: relative;
  width: 100%;
  z-index: 1;

  .inner {
    background-color: #feac40;
    position: absolute;
    bottom: 0;
    left: 0;
    top: 0;
  }
}

Fiddle: http://jsfiddle.net/f8WKt/

What is the trick to make the bar from right to left?

Upvotes: 0

Views: 448

Answers (3)

Kevin Lynch
Kevin Lynch

Reputation: 24723

I have provided an example of what I think you have asked

DEMO http://jsfiddle.net/f8WKt/5/

I have used position absolute within a ralative positioned div. The right one has right: 0; and the left one has left: 0;

.inner {
    background-color: #feac40;
    position: absolute;
    width: 80%;
    bottom: 0;
    top: 0;
}
.right .inner {
    right: 0;
}
.left .inner {
    left: 0;
}

I have put a border around them to make it clear that one is left to right and the other is right to left.

Upvotes: 1

polikin
polikin

Reputation: 304

Add right:0 to your right bar.

fiddle: http://jsfiddle.net/5SUVb/

Upvotes: 0

Huangism
Huangism

Reputation: 16448

try adding

.left .bar.pct-75 .inner {
    left: 25%;
    right: 0;
}

http://jsfiddle.net/f8WKt/3/

Assuming you want to join the 2 bars at the middle

Upvotes: 1

Related Questions