-1

I want a stacked bar with inner vertical text. I failed to put it in the right position. This is how I want it: bars with angled text

This is my code and output:

.colWrapper{
    height:200px;
    width:100px;
    position:relative;
    border:1px solid #ccc;
}
.barContainer{
    position:absolute;
    bottom:0;
    width:100%;
}
.bar{
    widith:100%;
    padding:10px;
    transform: rotate(90deg);
    text-align:center;
    margin:0

}
<div class="colWrapper">
    <div class="barContainer">
        <div class="bar" style="background-color:#b4cde2;">Software</div>
        <div style="clear:both;"></div>
        
        <div class="bar" style="background-color:#7ca7cc;">Banking</div>
       
    </div>
</div>
dakab
  • 5,379
  • 9
  • 43
  • 67

2 Answers2

1

You need to use -90deg and also, use the transform-origin:

.colWrapper {
  height: 200px;
  width: 100px;
  position: relative;
  border: 1px solid #ccc;
}
.barContainer {
  bottom: 0;
  width: 100%;
}
.bar {
  padding: 10px;
  transform: rotate(-90deg);
  text-align: center;
  margin: 0;
  left: -25px;
  transform-origin: right bottom;
  position: absolute;
  width: 100px;
  bottom: 120px;
}
.bar:first-child {
  left: -80px;
}
<div class="colWrapper">
  <div class="barContainer">
    <div class="bar" style="background-color:#b4cde2;">Software</div>
    <div class="bar" style="background-color:#7ca7cc;">Banking</div>
  </div>
</div>

Second Method:

.colWrapper {
  height: 200px;
  width: 100px;
  position: relative;
  border: 1px solid #ccc;
}
.barContainer {
  bottom: -5px;
  width: 100%;
  transform: rotate(-90deg);
  position: absolute;
  left: 5px;
}
.bar {
  padding: 10px;
  text-align: center;
  margin: 0 0 15px;
  sposition: absolute;
}
.bar:first-child {
  left: -80px;
}
<div class="colWrapper">
  <div class="barContainer">
    <div class="bar" style="background-color:#b4cde2;">Software</div>
    <div class="bar" style="background-color:#7ca7cc;">Banking</div>
  </div>
</div>
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
1

You can also take a look at writing-mode and flex-box.

https://developer.mozilla.org/fr/docs/Web/CSS/writing-mode

div {
  display: inline-flex;
  flex-flow: column wrap;
  height: 320px;
  width: 270px;
  vertical-align: middle;
}
span {
  padding: 20px 5px;
  background: #1E84C6;
  -webkit-writing-mode: vertical-lr;
  /* old Win safari */
  writing-mode: vertical-lr;
  writing-mode: tb-lr;
  text-align: right;
  margin: 10px;
  height: 100px;
  width: 60px;
  font-size: 30px;
  line-height: 60px;
}
span:nth-child(3) {
  height: 260px;
}
a {
  display: inline-block;
  text-decoration: none;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: helvetica;
  color: white;
}
div + div a {
  transform: scale(-1, -1);
  /* reverse writing direction optionnal*/
  btext-align: left;
  transform-origin: 1em 1.25em;
}
span:nth-child(2) {
  background: #283F4F;
}
span:nth-child(4) {
  background: #1DC685;
}
​-
<div>
  <span> <a href>one</a></span>
  <span> <a href>two</a></span>
  <span> <a href>three</a></span>
  <span> <a href>four</a></span>
  <span> <a href>five</a></span>
</div>
or
<div>
  <span> <a href>one</a></span>
  <span> <a href>two</a></span>
  <span> <a href>three</a></span>
  <span> <a href>four</a></span>
  <span> <a href>five</a></span>
</div>
and so on ...
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
  • Thanks for answer its really WOW.. But i want it more interactive, i don't want it with fixed values, because later i want to convert it with dynamic values. Thanks. – Kiran Juvvalapalli May 18 '16 at 07:24
  • @KiranJuvvalapalli i guess you just need to update values , px to % or use min-width/min-height . code is yours now ;) play with it . here is a pen to play with live and fork http://codepen.io/gc-nomade/pen/jqozRB , you can download a zip of it from export button at bottom right – G-Cyrillus May 18 '16 at 07:29