vertical-alignment

Align vertically using CSS 3

∥☆過路亽.° 提交于 2019-11-26 11:52:56
问题 With CSS 3, are there any way to vertically align an block element? Do you have an example? Thank you. 回答1: Was looking at this problem recently, and tried: HTML: <body> <div id="my-div"></div> </body> CSS: #my-div { position: absolute; height: 100px; width: 100px; left: 50%; top: 50%; background: red; transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); } Here's the Fiddle: http://jsfiddle.net

Add centered text to the middle of a <hr/>-like line

爷,独闯天下 提交于 2019-11-26 11:31:16
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 fancy things like this: <div style="float:left; width: 44%;"><hr/></div> <div style="float:right; width: 44%;"><hr/></div> Next section Or alternatively, because the above has problems with alignment (both vertical and horizontal): <table><tr> <td style="width:47%"><hr/></td> <td style="vertical-align:middle; text-align: center">Next section</td> <td style="width:47%"><hr/></td> <

CSS Vertical align does not work with float

巧了我就是萌 提交于 2019-11-26 11:15:38
问题 How can I use the vertical-align as well as float in the div properties? The vertical-align works fine if I do not use the float . But if I use the float, then it does not work. It is important for me to use the float:right for the last div. I am trying following, if you remove the float from all div\'s then it would work fine: <div class=\"wrap\"> <div class=\"left\">First div, float left, has more text.</div> <div class=\"left2\">Second div, float left </div> <div class=\"right\">Third div,

vertical alignment of text element in SVG

左心房为你撑大大i 提交于 2019-11-26 10:25:48
问题 Let\'s say I have the SVG file: <svg width=\"1024\" height=\"768\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> <text x=\'20\' y=\'60\' style=\"font-size: 60px\">b</text> <text x=\'100\' y=\'60\' style=\"font-size: 60px\">a</text> </svg> I want to somehow align the top of a and b . Actually, I want my positioning to be according to the roofline instead of baseline ! 回答1: The alignment-baseline property is what you're looking for it can take the following

Is there a “right” way to have NSTextFieldCell draw vertically centered text?

北慕城南 提交于 2019-11-26 10:16:05
问题 I have an NSTableView with several text columns. By default, the dataCell for these columns is an instance of Apple\'s NSTextFieldCell class, which does all kinds of wonderful things, but it draws text aligned with the top of the cell, and I want the text to be vertically centered in the cell. There is an internal flag in NSTextFieldCell that can be used to vertically center the text, and it works beautifully. However, since it is an internal flag, its use is not sanctioned by Apple and it

Vertically centering text in HTML table cell in Java JLabel

喜夏-厌秋 提交于 2019-11-26 10:03:24
问题 I have an HTML table (styles with CSS) that is displayed in a JLabel. I would like the contents (a single, short line of text) of the cells to be both horizontally and vertically centered. Horizontal centering is easy, but I cannot seem to center the text vertically. I\'ve tried vertical-align: and valign: with both middle and center arguments. I\'ve looked at several of the tricks, but none of them seemed doable, and the ones I tried didn\'t work. What I have now: Inline (in the <style> tag)

iOS 7 UITextView vertical alignment

别来无恙 提交于 2019-11-26 09:36:01
问题 How is that possible that my editable UITextView (placed inside a straightforward UIViewController inside a UISplitView that acts as delegate for the UITextView ) is not showing text from the beginning but after something like 6-7 lines? I didn\'t set any particular autolayout or something similar, trying to delete text doesn\'t help (so no hidden chars or something). I\'m using iOS 7 on iPad, in storyboard looks good... The problem is the same on iOS simulator and real devices. I\'m getting

Vertical align not working on inline-block

走远了吗. 提交于 2019-11-26 09:03:01
问题 I was told that: Vertical align only works for inline,inline-blocks,images,and table elements. It has to be applied on the child element, as oppose to the parent element, unlike text-align. However, when I tried to set vertical align middle on an inline-block element, it didn\'t work. Why? #wrapper { border: 1px solid black; width: 500px; height: 500px; } #content { border: 1px solid black; display: inline-block; vertical-align: middle; } <div id = \'wrapper\'> <div id = \'content\'> content

Font Rendering / Line-Height Issue on Mac/PC (outside of element)

寵の児 提交于 2019-11-26 08:05:33
问题 The Design The info widgets content should be vertically aligned in the middle as such: The Coded Design Windows: Chrome 20 / FF 14 / IE 9 Mac (Lion / Mt. Lion): Chrome / FF The Code HTML <div class=\"info\"> <div class=\"weather display clearfix\"> <div class=\"icon\"><img src=\"imgs/icons/thunderstorms.png\" align=\"Thunderstorms\" /></div> <div class=\"fl\"> <p class=\"temperature\">82° / 89°</p> <p class=\"conditions\">Thunderstorms</p> </div> </div> <div class=\"time display\"> <p>11:59

CSS: Vertically align div when no fixed size of the div is known

馋奶兔 提交于 2019-11-26 05:18:48
问题 How do I align a <div> which contains an image (or flash) vertically with CSS. Height and width are dynamic. 回答1: This is a pure CSS2 solution for horizontally and vertically centering without known sizes of either container nor child. No hacks are involved. I discovered it for this answer and I also demonstrated it in this answer. The solution is based on vertical-align: middle in conjunction with line-height: 0 , which parent has a fixed line-height. The HTML: <span id="center"> <span id=