0

If you see this page, text are aligned left side but I also want them to align centered vertically. Similar to Middle Align + Left Align in excel.

You can see this image to see what I am looking for enter image description here

closed as off-topic by Krzysiek Dróżdż, Jacob Peattie, Howdy_McGee Feb 22 at 5:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • You need to include more information, it's not easy for us to understand what it is you are asking. :) – Beaniie Feb 16 at 13:42
  • Okay, i have added more details to explain it more – Avinash Patel Feb 19 at 11:16
0

With flex:

.question-content-text {
    display: flex;
    align-items: center;
}

Without flex:

.question-content-text {
    position: relative;
}
.content-text {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
0

Use additional CSS rule.

.question-content-text{display:flex;align-items:center;}
0

The text will need to sit inside an element that has a width and left / right margins. For example, you would use a construct like this...

`<span style="width:50%;margin-left:25%;margin-right:25%">Here is my 
 text</span>`

Doing it like this will mean your text takes up the middle 50% of the available element, and it will align to the left of that middle 50% (unless you add something like text-align:center).

Most probably, you'll create a class in your custom css, with the attributes as above, and then just use the class wherever you want the text to appear like this.

`.my-center-text {width:50%;margin-left:25%;margin-right:25%;}`
  • Thanks for the time, could you please share the CSS code for the same. – Avinash Patel Feb 19 at 11:59
  • I've updated my answer to include backticks, so the code should show up now – Martin Jarvis Feb 19 at 16:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.