使用CSS,如何在一个表格单元中分割一个字符串(例如一个长URL) ?

时间:2021-03-16 06:13:49

Here's the situation: I'm trying my hand at some MySpace page customisations. If you've ever tried [*], 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

现在的情况是:我正在尝试一些MySpace页面的定制。如果你曾经尝试过(*),我相信你能理解它是多么令人沮丧。基本上,它可以通过CSS定制,在一定的规则范围内(例如,“#”字符是不允许的)。多么有用!)如果你想了解更多的信息,可以看看这个博客,我把它作为我的习惯的基础。

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

所以唯一的问题是评论部分,“朋友”贴出他们想要的东西。它已经…

max-width:423px;

...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,它会吹出表的宽度,而不考虑最大的设置!

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.

问题:是否有一种方法可以管理将会推到表格宽度的文本?也许分裂/切绳子吗?或者我应该做更多的事情…url是作为文本发布的,而不是href。

Using Firefox and Firebug btw.

使用Firefox和Firebug btw。

Edit: Also javascript is not allowed ;)

编辑:javascript是不允许的;

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

另一个编辑刚刚和IE7核对过,而且看起来很有效。所以在这种情况下,firefox是很麻烦的。

3 个解决方案

#1


1  

Have you tried the various values for the "overflow" css property? I think that may do what you need in some permutation.

您是否尝试过“溢出”css属性的各种值?我认为这可能会在某些排列中发挥作用。

#2


1  

a few browsers support word-wrap

一些浏览器支持单词包装。

ex.

前女友。

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

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

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

#3


0  

Your options are pretty limited, if you are using only CSS. You can try

如果只使用CSS,那么您的选项非常有限。你可以试着

 overflow: hidden

to hide the offending parts. CSS 3 supports text-wrap, but support for it is probably non-existent. IIRC there is an IE-only css-property for doing the same thing, but I can't remember it at the moment and my Google-Fu fails me.

隐藏违规的部分。CSS 3支持文本包装,但是支持它可能不存在。IIRC做同样的事情只会有一个简单的css属性,但是我现在不记得了,我的Google-Fu让我失败了。

#1


1  

Have you tried the various values for the "overflow" css property? I think that may do what you need in some permutation.

您是否尝试过“溢出”css属性的各种值?我认为这可能会在某些排列中发挥作用。

#2


1  

a few browsers support word-wrap

一些浏览器支持单词包装。

ex.

前女友。

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

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

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

#3


0  

Your options are pretty limited, if you are using only CSS. You can try

如果只使用CSS,那么您的选项非常有限。你可以试着

 overflow: hidden

to hide the offending parts. CSS 3 supports text-wrap, but support for it is probably non-existent. IIRC there is an IE-only css-property for doing the same thing, but I can't remember it at the moment and my Google-Fu fails me.

隐藏违规的部分。CSS 3支持文本包装,但是支持它可能不存在。IIRC做同样的事情只会有一个简单的css属性,但是我现在不记得了,我的Google-Fu让我失败了。