Why "vertical-align: middle;" doesn't work with "min-height"? - html

When I set min-height and "vertical-align: middle;" the text is not aligned vertically.
First example: http://jsfiddle.net/pkaXR/
How should I change css align image and text vertically ?

min-height sets the minimum height of a block.
vertical-align sets the position of inline content on a line.

Perhaps like http://jsfiddle.net/rPsEJ/26/ - I'm not sure I understood the question right though. ;-) As far as I know, vertical-align only applies to table cells.

Related

Why is vertical-align:middle not working like text-align:center

Can someone please tell me why vertical-align:middle Not working like text-align:center ?
I mean, why is it so hard to make it work?
I want to know why those W3 ppl don't make a text-align:middle
I'm asking why it's so hard to make the vertical-align:middle like text-align:center.
The vertical-align attribute is for inline elements only. It will have no effect on block level elements, like a div or a paragraph.If you would like to vertically align an inline element to the middle just use this.
Refer this Link : http://phrogz.net/CSS/vertical-align/index.html
text-align:center
means put the text in the center of the width of the <p> tag for example
vertical-align:middle
means. Put the <p> in the center (middle) of the height of the the parent tag <div> for example. Which means you need to increase the height of the parent.
Vertical align aligns like by height like this:
___________________________
Some text aligned top
Some text aligned middle
Some text aligned bottom
__________________________
Help with horizontal align can be found here: http://www.w3schools.com/css/css_align.asp

Any idea why these two boxes are offset?

In the fiddle below I have two inline-block DIVs that are the same size. They have overflow set to auto and have content in them. The second DIV has a rather large Y offset but I can't figure out why. They should just be right next to each other.
http://jsfiddle.net/nT4ku/
Any ideas?
Specifying a vertical-align on the side-by-side inline-block divs should fix this for you. vertical-align: top;
Here's my edit to your jsfiddle: http://jsfiddle.net/nT4ku/1/

CSS: vertical-align multiple text sizes

I'm having trouble with a text line that has multiple font sizes in it. I want all the text to be aligned to the middle of the .line1 element. I used vertical-align:middle but it doesn't do the trick. Here's the JSfiddle: http://jsfiddle.net/tWxdT/
erase all vertical-align in css. and give product_mark_bg a vertical-align:baseline
Looks fine to me in Google Chrome as well, but may I recommend using display: table-cell; in your CSS as well? If not even that then scrap using Vertical-Align and try having equal amounts of Padding via the Top and Bottom for your HTML Tags.
You can set the line-height to get better alignment of differently sized text. Not sure it's what you are looking for, but adding a line-height of 2.2em in the example centered the text a bit differently.

alternative to text valign in css

Do you know how can I make text vertically centred? I need something like valign attribute, but written in css. Any ideas?
There's is no universal answer to this. Unfortunataly, no, there is no true equivalent in CSS. Some options depending on the context of your particular layout:
for one line of text, giving the text a line-height equal to the height of the container will center it vertically
if not worrying about IE, you can use display: table-cell on the container and add vertical-align: middle
use JS to calculate the necessary positioning or padding/margin needed to center the element after calculating the heights of the container and child element.
Try the vertical-align property

align-middle question

What is my misunderstanding about the way that vertical-align:middle; works?
I have posted (http://jsfiddle.net/D6RwZ/) some code which I would expect to vertically align a red rectangle in a blue rectangle, but it doesn't look like that.
vertical-align:middle won't work on div (block element). You can refer here for details.
If you want to vertical align, I think the only option is using margin/padding with appropriate parameters.
Vertical-align only works on inline images and display: table-cell.
I've used this solution a few times and it works quite well but takes some work. If you're working with fixed size elements position absolute is by far the simplest. Dynamic sized elements and vertical centering can be very tricky, lots of browser quirks to deal with.
vertical-align can only be applied to elements with:
display:table-cell in order to vertically align the contents of the element.
display:inline or display:inline-block in order to vertically align the element within the text line that contains it
A cheap hack with the latter : http://jsfiddle.net/8bZQS/