By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

How to position 2 items in a table cell using CSS?

P: 13
I'm translating one of my old ASP apps into ASP.Net and am having a bit of a problem with something that looks like it should be really easy!

In the header row of a table, I want the name of the column and an image showing the sort direction - no problem so far!

The problems started when I tried to right align the image.

In the old ASP version, I created a table in the cell with 1 row / 2 cols set the 1st col to 100% / Centred, and 2nd Col to 1% right justified.

I know the gridview uses a table anyway, but I'd like to do this without a table if I can.

I've looked at lots of tutorials, and tried lots of things, but the closest I can get is to put the image 1st and use float:right then put the title afterwards and float:center.

It nearly works!

But the problem is that whereas before the column width would be stretched to show the full title, now the width of the text in the header doesn't have any impact on the width of the column.

Am I missing a CSS element that will tell it to take as much space as it needs?

Or should I just revert to using a table whilst I've still got some hair?
Mar 30 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 7,435
You could put the text in a <p> or <hx> and float that left instead of the image right. Put the text first.
Mar 30 '08 #2

P: 13
Thanks, that did the trick!
Apr 14 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.