Vertical (rotated) label in Android

Here is my elegant and simple vertical text implementation, extending TextView. This means that all standard styles of TextView may be used, because it is extended TextView. public class VerticalTextView extends TextView{ final boolean topDown; public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | … Read more

How to align content of a div to the bottom

Relative+absolute positioning is your best bet: #header { position: relative; min-height: 150px; } #header-content { position: absolute; bottom: 0; left: 0; } #header, #header * { background: rgba(40, 40, 100, 0.25); } <div id=”header”> <h1>Title</h1> <div id=”header-content”>And in the last place, where this might not be the case, they would be of long standing, would … Read more

How can I vertically align elements in a div?

Wow, this problem is popular. It’s based on a misunderstanding in the vertical-align property. This excellent article explains it: Understanding vertical-align, or “How (Not) To Vertically Center Content” by Gavin Kistner. “How to center in CSS” is a great web tool which helps to find the necessary CSS centering attributes for different situations. In a … Read more

Vertically align text next to an image?

Actually, in this case it’s quite simple: apply the vertical align to the image. Since it’s all in one line, it’s really the image you want aligned, not the text. <!– moved “vertical-align:middle” style from span to img –> <div> <img style=”vertical-align:middle” src=”https://via.placeholder.com/60×60″> <span style=””>Works.</span> </div> Tested in FF3. Now you can use flexbox for … Read more