Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I align the bottoms of two labels in a horizontal UIStackView?

I have two labels in a horizontal UIStackView. Label 1 is a large font (the alarm time), Label 2 is a small font (AM/PM indicator) and I want to align the bottoms of each label.

enter image description here

I have the alignment of the stack view set to Bottom, but it seems like it's just aligning the bottoms of the labels' total area and not the actual text. The result is that the smaller font's bottom edge is about 3 or 4 pixels above the bottom edge of the large label. How do I fix this?

like image 869
Austin Berenyi Avatar asked Jan 03 '18 05:01

Austin Berenyi


People also ask

How to right align labels next to inputs?

Example of right aligning labels next to inputs with the text-align property: We can remove the text-align property, and the labels will be left-aligned by default. Let’s see an example, where we also add placeholder, id and name attributes on inputs and for attribute on labels. As a result, the input will be activated when a label is clicked.

How to align labels and groups of form controls in Bootstrap?

Use the .form-horizontal class in Bootstrap to align labels and groups of form controls in a horizontal layout. You can try to run the following code to implement .form-horizontal class:

How to align two divs horizontally using CSS?

It is clearly visible that the use of the <div> tag took the second link on the other line because it acquires the entire line width. If <div> was an inline tag, then by default two divs would align horizontally. Ways to align 2 divs horizontally: We have two divs that can be aligned horizontally with the use of CSS.

How to make an anchor tag go to the next line?

Here, 2 anchor tags are used. Since the anchor tag is an inline element, the second link comes right after the first one in the output. However, the second link can be made to go to the next line if we use the <div> tag.


Video Answer


1 Answers

You need check BaseLine Relative attribute in VERTICAL Stack view

enter image description here

For Horizontal stackview

You need to change alignment from fill mode to either First baseline or Last baseline

enter image description here

If you want to know about baseline here isa great explanation https://stackoverflow.com/a/24541992/4601900

Hope it is helpful to you

like image 130
Prashant Tukadiya Avatar answered Oct 01 '22 17:10

Prashant Tukadiya