1

How to center the Text Test Text vertically? see here

I want to make distance between the text and the boarder bottom equals the distance between the text and the boarder top. `

MANOJ GOPI
  • 1,279
  • 10
  • 31
Max_Salah
  • 2,407
  • 11
  • 39
  • 68

4 Answers4

4

For single lined text, use line-height that is equal to height (or rounded up to even number).

#a {
  display: inline-block;
  padding-right: 20px;
  padding-left: 15px;
  font-family: 'Roboto';
  font-size: 12px;
  font-weight: bold;
  font-stretch: condensed;
  COLOR: white;
  border-left: 10px solid transparent;
  border-bottom: 25px solid;
  border-bottom-color: #FF3300;
  height: 0;
  line-height: 26px;
  top: 50%;
}
<span id="a">TEST TEXT</span>
Justinas
  • 41,402
  • 5
  • 66
  • 96
2

Use line-height: 25px(will work for single-line text only).

#a {
  display: inline-block;
  padding-right: 20px;
  padding-left: 15px;
  font-family: 'Roboto';
  font-size: 12px;
  line-height: 25px;
  font-weight: bold;
  font-stretch: condensed;
  COLOR: white;
  border-left: 10px solid transparent;
  border-bottom: 25px solid;
  border-bottom-color: #FF3300;
  height: 0;
  top: 50%;
}
<span id="a">TEST TEXT</span>
Weafs.py
  • 22,731
  • 9
  • 56
  • 78
0

Use :before pseudo element for left part, line height is not going to work with bottom-border. I updated your fiddle:

http://jsfiddle.net/wfkd6Lbn/8/

lima_fil
  • 1,744
  • 27
  • 34
0

.area { 
  width: 300px; 
  height: 300px;  
  position: relative;
}

.bubble { 
  position: absolute; 
  left: 93px; 
  top: 21px; 
  width: 135px; 
  height: 84px; 
  display: table; 
}

.bubble p {
  display: table-cell; 
  vertical-align: middle; 
  text-align: center; 
<div class="area">
      <div class="bubble">
          <p>To look best, text should really be centered inside this bubble both vertically and horizontally.</p>
      </div>
</div>