CSS: ajuste dinámico de ancho en función del contenido

This is a problem I at first didn't thought was so problematic, and perhaps it aint, but I haven't found a solution yet. I've tried a few different approaches but didn't really get the correct solution.

I've tried to show in this picture.

  1. When the topic is short, the comment count should follow after directly.
  2. When the topic is longer, it should be cut (hidden) and the comment count should only take up as much width as it has to.
  3. The above should work even when the comment count is longer/shorter.

Hope this is clear enough. Thanks for any inputs!

preguntado el 08 de enero de 11 a las 19:01

It's doable, but it's not trivial... -

1 Respuestas

I had to use JavaScript: http://jsfiddle.net/xGWsa/

Respondido el 08 de enero de 11 a las 22:01

Great solution, works like a charm, only problem is js. Would be great if someone could work this out with CSS. - martnu

@Martin Note that you can achieve a decent effect by just having the comments on the right: jsfiddle.net/xGWsa/2 - Šime Vidas

@Šime Yes, I though so too, but the client didn't :) I also tried a max-width approach on the left element, but that locks the comment count to a certain width, which is bad. - martnu

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.