Ok this is the div structure.
<div class="DivParent">
<a href="#">
<div class="DivWhichNeedToBeVerticallyAligned"></div>
</a>
</div>
DivParent has fixed width and height values but DivWhichNeedToBeVerticallyAligned does not have fixed height values.
If you make DivParent display:table-cell; you can vertically align DivWhichNeedToBeVerticallyAligned but i don't want to use that feature since it causes some mess.
A href tag link should be same size with the divParent i mean whole divparent has to be clickable. like display:block.
So are there any CSS way of vertically aligning or lightweight jquery solution would also help.
Thank you.
Here jsfiddle : http://jsfiddle.net/XHK2Z/
*
There is no way to do this with CSS without knowing the height of the child div.
With jQuery, you could do something like this.
I have been using the following solution (with no positioning, no table-cell/table-row and no line height) since over a year, it works with IE 7 and 8 as well.
This solution works for me fine in modern browsers including IE 10 and above.
inlucluding this css
You can use an extra helper to achieve vertical alignment in a block with fixed height.
Look at this: http://jsfiddle.net/kizu/7Fewx/
There you must have a helper near a block you want to align with:
And add
display: inline-block; vertical-align: middle;
to.DivWhichNeedToBeVerticallyAligned
Here is another option for modern browsers:
if the parent don't have any other child. this would be a css only "hack"
another hack is