Vertical aligning text on a LinkButton

Hi All,

I have a LinkButton whose width I've set to 150px and a heigh of 20px.  I am using 8pt font for the button text.  So, the text is quite a bit shorter in height than the overall button.  The problem is that the text automatically vertically aligns to the top left of the button.  How do I vertically align to "middle"?  I've assigned a CSS style to it and set:

vertical-align: middle;

....but it does nothing.

Any ideas?

Thanks,

K
kaubeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NowaYCommented:
Have you tried sticking HTML in the text of the control?

lnkButton.text = "<center>Click me!</center>"

or something like that...
kaubeyAuthor Commented:
I thought of it, but I can't think of any HTML that would vertically align text.

Any suggestions?

Thanks....
trevorhartmanCommented:
I think a better way of doing it would be to put a div inside the the linkbutton so you have more control over the way it renders.

<asp:LinkButton>
    <div class="linkText">text</div>
</asp:LinkButton>


.linkText
{
     width:150px;
     height:20px;
     text-align:center;
     line-height:20px;
}

This will make your line-height of the inside text to be 20 pixels, vertically aligning the text in the middle of the line.  Try it out

HTH - Trevor

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
samtran0331Commented:
I've always had problems with this and found the easiest and least painful fix is to just make a new image that includes the text as part of the image and leave the actual text property blank.
kaubeyAuthor Commented:
Thanks for all your input -- Trevor's idea works perfectly....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.