vertical-alignment

How to vertical align an inline-block in a line of text?

你说的曾经没有我的故事 提交于 2019-11-27 18:38:33
I want to create an inline-block that will take on some unknown width and height. (It'll have a table inside it with content dynamically generated). Further, the inline-block should be placed inside a line of text, such as "my text (BLOCK HERE)". To make it look pretty, I'm trying to make the block be vertically centered in the line . So if the block looks like this: TOP MIDDLE BOTTOM Then the line of text will read: "My text ( [MIDDLE] )" (with TOP and BOTTOM above and below the line) Here's what I have so far. CSS .example { background-color: #0A0; display: inline-block; margin: 2px; padding

How to vertically align two or more (side by side) elements in a div?

百般思念 提交于 2019-11-27 18:10:37
问题 I am trying to vertically align two elements with different heights in a div: <div class="footer-icons"> <div id="footer-twitter"> <img src="images/twitter.png" width="40" alt=""> </div> <div id="footer-fb"> <div class="fb-like" data-href="http://facebook.com/user" data-send="false" data-layout="button_count" data-width="160" data-show-faces="false" data-font="arial"></div> </div> </div> The twitter div has a height of 40px, and the fb div has a height of 20px. What is currently happening is

How to vertically align 2 different sizes of text?

为君一笑 提交于 2019-11-27 18:04:16
I know to vertically align text to the middle of a block, you set the line-height to the same height of the block. However, if I have a sentence with a word in the middle, that is 2em . If the entire sentence has a line-height the same as the containing block, then the larger text is vertically aligned but the smaller text is on the same baseline as the larger text. How can I set it so both sizes of text are vertically aligned, so the larger text will be on a baseline lower than the smaller text? MatTheCat Try vertical-align:middle; on inline containers? EDIT : it works but all your text must

trying to align html button at the center of the my page

廉价感情. 提交于 2019-11-27 17:39:25
I'm trying to align an HTML button exactly at the centre of the page irrespective of the browser used. It is either floating to the left while still being at the vertical centre or being somewhere on the page like at the top of the page etc.. I want it to be both vertically and horizontally be centered. Here is what I have written right now: <button type="button" style="background-color:yellow;margin-left:auto;margin-right:auto;display:block;margin-top:22%;margin-bottom:0%"> mybuttonname </button> Mohamad Here's your solution: JsFiddle Basically, place your button into a div with centred text:

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

江枫思渺然 提交于 2019-11-27 16:57:24
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 first line, at the first character of the text field. Use android:gravity="top" Nandagopal T This is similar to CommonsWare answer but with a minor tweak:

How to center div vertically inside of absolutely positioned parent div

我的未来我决定 提交于 2019-11-27 16:51:15
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. Jsfiddle Hashem Qolami First of all note that vertical-align is only applicable to table cells and inline-level elements. There are couple of ways to achieve

Font: poor vertical metrics cause inconsistent line-height rendering across browsers. Solution?

喜夏-厌秋 提交于 2019-11-27 16:35:43
问题 After hours of debugging and pottering around I found out that it is impossible to vertically align a font with poor vertical metrics consistently across browsers. If a font has poor vertical metrics it may either be rendered too far up or too far down and looks horrible especially inside buttons. There is no way to solve this problem with css alone. You can check the vertical metrics of a font with the tests on this website: http://levien.com/webfonts/vmtx/ ( Just download a test and replace

Flex items not centering vertically

回眸只為那壹抹淺笑 提交于 2019-11-27 16:24:52
I'm trying to center vertically the content with flex boxes without success. I don't like to use position or translate because it is not a fixed size. What is wrong with my code? .row-centered { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; } .col-centered { display: flex; flex-direction: column; align-self: flex-start; float: none; margin-right: 0 auto; } .us-container{ display: flex; justify-content: center; align-items: center; vertical-align: middle; resize: both; overflow: auto; } .us-container div{ resize: both; overflow: auto; } <link rel="stylesheet"

vertical alignment of image inside a div

我的梦境 提交于 2019-11-27 16:05:42
问题 I want to set vertical alignment of image inside a div. I use img { vertical-align:middle} but it is not working. 回答1: Using the line-height property will solve the problem: <style> .someclass { width: 300px; height: 300px; text-align: center; line-height: 300px; border: dotted; } .someclass img { margin: auto; vertical-align: middle; } </style> <div class="someclass"> <img src="someimg.jpg" border="0" alt=""> </div> 回答2: This is a solution that doesn't require JavaScript (as my previous

Center a H1 tag inside a DIV

穿精又带淫゛_ 提交于 2019-11-27 15:29:28
问题 I have the following DIV inside a body tag: <div id="AlertDiv"><h1>Yes</h1></div> And these are their CSS classes: #AlertDiv { position:absolute; height: 51px; left: 365px; top: 198px; width: 62px; background-color:black; color:white; } #AlertDiv h1{ margin:auto; vertical-align:middle; } How can I align vertically and horizontally H1 inside DIV? AlertDiv will be bigger than H1. 回答1: You can add line-height:51px to #AlertDiv h1 if you know it's only ever going to be one line. Also add text