vertical-alignment

Vertical align table-cell don't work with position absolute

左心房为你撑大大i 提交于 2019-11-27 08:15:50
http://jsfiddle.net/fQv97/ HTML <div class="table-cell"> My text, should be align middle </div> CSS .table-cell { height: 200px; width: 200px; vertical-align: middle; background: #eee; display: table-cell; position: absolute; } Problem The text should be placed in the middle of my "table cell". Everything works as expected until I add "position: absolute". Now it can't place my content in the middle any more? Why not? It still knows my height and width because I set it in my CSS. Any clever workaround for this? Everything works as expected until I add "position: absolute". Now it can't place

Vertically align horizontal inline-block elements

不想你离开。 提交于 2019-11-27 07:47:42
问题 I've got a checkbox group. Which are centrally aligned with checkboxes on top and text below. Here is what I mean : So I want to align So each checkbox + label is wrapped in a div with class choice . All choice divs are part of div with additional-info . choice divs are inline-block elements with fixed width. How do I align div choice to be in the same height as the first one? I've tried setting the additional-info position to relative and choice to absolute. But then they overlap each other

Vertical Align with Absolute Positioning

左心房为你撑大大i 提交于 2019-11-27 07:23:01
问题 In the following code I'm trying to make the elements within the green div.middle elements to vertically align to the middle. I've tried the table-cell approach but cant get it working. I heard it's due to absolute positioning and tried this solution with no luck: CSS - Vertical align table-cell don't work with position absolute This appears to be due to .table-cell having no height - I would like it's height to equal its parent container, which varies in height. jsfiddle: http://jsfiddle.net

CSS - Center align text with icon

烈酒焚心 提交于 2019-11-27 06:24:14
问题 Using material icons with CSS, I have the following code that renders a link with icon and text. <a href="#"><i class="material-icons">group_work</i>Groups</a> As you can see in the image below, the text seems to be sinking down.. I would like them to be vertically aligned center together. How can i achieve this? PS. (Not a designer!) 回答1: To vertically center elements, you can use the vertical-algin: middle; rule. In your case, that would most propably be: .material-icons { vertical-align:

CSS: How to align vertically a “label” and “input” inside a “div”?

不打扰是莪最后的温柔 提交于 2019-11-27 06:13:38
Consider the following code : HTML: <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div> CSS: div { height: 50px; border: 1px solid blue; } What would be the easiest method to put the label and the input in the middle of the div (vertically) ? Marc-François div { display: table-cell; vertical-align: middle; height: 50px; border: 1px solid red; } <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div> The advantages of this method is that you can change the height of the div , change the height of the text field and change the font size and

Align vertically using CSS 3

 ̄綄美尐妖づ 提交于 2019-11-27 06:08:28
With CSS 3, are there any way to vertically align an block element? Do you have an example? Thank you. 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/sTcp9/6/ It even works when using "width/height: auto", in the place of fixed dimensions. Tested on the

Stacking Divs from Bottom to Top

痞子三分冷 提交于 2019-11-27 05:09:23
问题 When appending div s to a div with a fixed height, the child divs will appear from top to bottom, sticking at the top border. ┌─────────────────────────┐ │ Child Div 1 │ │ Child Div 2 │ │ │ │ │ │ │ └─────────────────────────┘ I'm now trying to display them from bottom to top like this (sticking to the bottom border): ┌─────────────────────────┐ │ │ │ │ │ │ │ Child Div 1 │ │ Child Div 2 │ └─────────────────────────┘ ┌─────────────────────────┐ │ │ │ │ │ Child Div 1 │ │ Child Div 2 │ │ Child

Vertical centering variable height image while maintaining max-width/height

让人想犯罪 __ 提交于 2019-11-27 04:34:43
I want to center an image of unknown width/height on a page, while making sure that it shrinks if it is bigger than the page (i.e. use max-width / max-height ). I tried using the display:table-cell method, but max-width is ignored in Firefox for all elements within elements declared with display:table-cell . Is there a way to vertically center a variable-height element without using display:table-cell ? I can change the mark up. JavaScript is acceptable, but I cannot use JQuery (or any other JS library). This should prove to work quite well... no JavaScript necessary :) See the working demo on

Vertically align contents of a button other than center

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:28:42
问题 Usually people try to figure out how to vertically center stuff, I want to remove an instance of centered content and align and I'm stuck. The content of the button (that is placed in a list in a table cell) is vertically centered by default. How can I remove this? How to align the contents of the <button> vertically to the top? <table> <tbody> <td> <ul> <li> <button> <div>Content</div> I have an example on jsFiddle. button { display: block; position: relative; background-color: pink; width:

vertical alignment of text element in SVG

孤街醉人 提交于 2019-11-27 03:07:00
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 ! Simon West The alignment-baseline property is what you're looking for it can take the following values auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge |