How to center div vertically inside of absolutely positioned parent div

I am trying to get blue container in the middle of pink one, however seems vertical-align: middle; doesn’t do the job in that case. <div style=”display: block; position: absolute; left: 50px; top: 50px;”> <div style=”text-align: left; position: absolute;height: 56px;vertical-align: middle;background-color: pink;”> <div style=”background-color: lightblue;”>test</div> </div> </div> Result: Expectation: Please suggest how can I achieve that. … Read more

Android: Vertical alignment for multi line EditText (Text area)

I want to have 5 lines for the height of the text area. I am using the following code. <EditText android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:gravity=”center” android:singleLine=”false” android:lines=”5″ android:layout_marginLeft=”10dip” android:layout_marginRight=”10dip” /> The text area looks fine, but the problem is that the cursor is blinking in the middle of the text field. I want it to blink at … Read more

Add centered text to the middle of a horizontal rule [duplicate]

This question already has answers here: CSS technique for a horizontal line with words in the middle (30 answers) Closed last year. I’m wondering what options one has in xhtml 1.0 strict to create a line on both sides of text like-so: Section one ———————– Next section ———————– Section two I’ve thought of doing some … Read more

How to set the margin or padding as percentage of height of parent container?

I had been racking my brains over creating a vertical alignment in css using the following .base{ background-color:green; width:200px; height:200px; overflow:auto; position:relative; } .vert-align{ padding-top:50%; height:50%; } <!– and used the following div structure. –> <div class=”base”> <div class=”vert-align”> Content Here </div> </div> While this seemed to work for this case, i was surprised that … Read more

Best way to center a on a page vertically and horizontally? [duplicate]

This question already has answers here: How to center an element horizontally and vertically (26 answers) Closed 3 years ago. Best way to center a <div> element on a page both vertically and horizontally? I know that margin-left: auto; margin-right: auto; will center on the horizontal, but what is the best way to do it … Read more