使用CSS,如何在表格单元格中拆分字符串(例如长URL)? [英] Using CSS, how can I split a string (e.g. a long URL) in a table cell?

查看:453
本文介绍了使用CSS,如何在表格单元格中拆分字符串(例如长URL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是情况:我正在尝试一些MySpace页面自定义。如果你曾经尝试过 [stackoverflow],我相信你明白它是多么令人沮丧。 >
基本上它可以全部通过CSS定制,在一组规则中(例如,'#'字符是不允许的......多么有用!)。
看看这个博客如果您想了解更多信息,我会用它作为我的自定义的基础

Here's the situation: I'm trying my hand at some MySpace page customisations. If you've ever tried [stackoverflow], I'm sure you understand how frustrating it can be.
Basically it can be all customised via CSS, within a certain set of rules (e.g. the '#' character is not allowed...how useful!).
Have a look at this blog if you want more info, I used it as the basis for my customisations

所以唯一的问题是评论部分,其中'朋友'发布他们想要的任何内容。
它已经......

So the only problem is with the comments section, where 'friends' post whatever they feel like. It already has...

max-width:423px;

...设置在表格中,但我发现在评论中是否发布了长URL无论最大设置如何,它都会使表格宽度变宽!

...set on the table, but I've discovered if long URLs are posted in the comment section, it blows out the table width, regardless of the max setting!

问题:有没有办法管理要转到的文本推动桌子的宽度?

也许拆分/砍掉字符串?或者我应该做的还有更多......?

URL是以文本形式发布的,而不是hrefs。

Question: Is there a way to manage text that is going to push the width of the table?
Perhaps splitting/chopping the string? Or is there more I should be doing..?
The URLs are posted as text, not hrefs.

使用Firefox和Firebug btw。

Using Firefox and Firebug btw.

编辑:也不允许使用javascript;)

Edit: Also javascript is not allowed ;)

另一个编辑刚刚检查过IE7,它似乎有用......所以firefox在这种情况下很麻烦..

Another edit Just checked with IE7, and it seems to work.. so firefox is being the hassle in this case..

推荐答案

一些浏览器支持自动换行

ex。

<div style="width: 50px; word-wrap: break-word">insertsuperlongwordhereplease</div>

浏览器支持目前是IE / Safari / Firefox 3.1(Alpha)

browser support currently is IE / Safari / Firefox 3.1 (Alpha)

这篇关于使用CSS,如何在表格单元格中拆分字符串(例如长URL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆