tags:

views:

76

answers:

4

Got:

<ul>
    <li><div style="width:200px; display:table-cell;">Something here</div> <div style="width:40px; display:table-cell;">Edit</div> <div style="width:40px; display:table-cell;">Delete</div></li>
</ul>

Hopefull you get what I'm trying to do, have the first div be a fixed width. But I can't seem to do this, each div takes up a line by itself.

How can this be done without messy floats?

Thanks

+1  A: 

Hopefull you get what I'm trying to do, have the first div be a fixed width. But I can't seem to do this, each div takes up a line by itself.

For display-table:cell to have effect, the parent element needs to be set to display: table-row and the parent parent element to display: table.

That said: Are you sure a <table> element is not the more appropriate thing here?

Pekka
Why would a `table` be more appropriate here? It may be slightly easier to layout, but isn't it obvious that this *isn't* tabular data?
Yi Jiang
@Yi how do you deduct that this is not tabular data?
Pekka
The two other 'cells' contain actions 'delete' and 'edit'. There is no data with which he is attempting to correlate the data in the first cell with - instead what he is attempting to create is most likely something like a control/management panel for contents, like blog posts.
Yi Jiang
@Yi and a control/management panel for blog posts is not tabular data? I'm not following you. Also, I am not saying it *is* tabular data; I am merely asking the OP to think whether he is using the correct tag.
Pekka
No its not - there is no *data*, but rather a list of actions. On both semantics and practicality I'd say that the structure should be a `ul` of action with a `p class="preview"` sibling and a `li class="blog-post"` parent. Also, if you're not saying that it is tabular data then why suggest `table` as more appropriate? On an entirely separate note, can you stop referring to me as 'Yi' - its not polite. I know its a cultural thing, but *Yi Jiang* is my last name. 'Yi' doesn't mean anything. Sorry if I sound rude.
Yi Jiang
@Yi Jiang whether this is tabular data or not is really a pointless discussion. I am showing the OP how to make his current method work, and suggesting that he think about whether he's using the correct tag, nothing more. If you want to discuss whether this is tabular data, why not take it to @GuidoH who is certain it is. As to the addressing - I'm happy to use your full name, no problem.
Pekka
Thanks Pekka and Yi, so far it looks like there is no CSS solution without using floats (which I believe are messy due to needing clear styles)
Igor K
@Igor but there is - didn't you read my answer? :)
Pekka
@Pekka yeah I did, but that needs parent elements to have styles attached. I'm just shocked at how difficult it is to create inline fixed width blocks using CSS (without messy floats)
Igor K
+3  A: 

Please, never do that again! The way to do it would be with floats, but you really NEVER wanna use something like that! By the way, div's aren't allowed within an ul. If you wanna display data like that, you should use real tables.

Did I mention that you really shouldn't use that under any circumstance?

GuidoH
It's probably not tabular data he's trying to display, so it would not be appropriate to use a table. If support for the table display properties was better, I also wouldn't suggest that floats are necessarily better.
Joeri Hendrickx
A: 

ohh ok i get it... in firefox it works but not in iexplorer... i agree with @GuidoH and @pekka, you should not use it like that... but if you need to, if you really really really need to... you could use display:inline the problem is that you wont be able to change the width

pleasedontbelong
Doesnt work in Chrome either
Igor K
A: 

Use span instead of div perhaps? (avoid new lines)

Mark Schultheiss
Thanks but couldnt get span to work. Tried display:inline-block; but didnt work either
Igor K