Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
div has width of 250px and height of 35px ,inside it there is an anchor with width and height 100% but at runtime anchor width not rendering as 250px and height is not rendering as 35px its stretching depending on data.
CSS
div.css
{
height:35px;
width:500px;
}
a.css
{
height:100%;
width:100%;
display:table - cell;
text-align:center;
vertical-align:middle;
}


output for anchor width and height 25px and 10px depending on data inside its span.

if i change anchor display to block,width becoming 250px and height 35px as i wanted, but span inside anchor vertical-align middle not working its going to top position.can any one help me here
Posted
Updated 11-Aug-12 20:50pm
v7
Comments
Kenneth Haugland 11-Aug-12 11:19am    
Add your solution and mark it as answer then :)
mallikharjunrao84 12-Aug-12 2:15am    
Sorry it is not resolved ,i have tried with display as block but vertical align is missing,
display:table-cell -->missing height and width
disaply:block missing -->vertical align

i need both ,anchor should have width as div and inner span should be aligned center and middle.i am not able to found a solution.

I am glad you resolved your issue, but can you please write down what you did in a solution an mark it as answer?

From OP:
Quote:
I resolved, actually anchor tag has display as table-cell when changed it to block its working fine


Kind regards
Kenneth :-)
 
Share this answer
 
Comments
mallikharjunrao84 12-Aug-12 2:32am    
Sorry it is not resolved ,i have tried with display as block but vertical align is missing, display:table-cell -->missing height and width disaply:block missing -->vertical align.I updated my question can you lookinto it.
i changed // lines then its working

CSS
div.css
{
//height:35px;
line-height:35px;
width:500px;
}



CSS
a.css
{
height:100%;
width:100%;
//display:table - cell;
display:block;
text-align:center;
vertical-align:middle;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900