3

在chrome和safari中,链接不听width:500px;在 CSS 中。文本有,但链接没有。

请参见此处的打印屏幕 1

在此处查看简单示例

有任何想法吗?
非常感谢帮助。
谢谢艾玛
_

我也尝试了一个非常简单的测试。见代码:

<html>
<head>
<style type="text/css">
#main {width:100px;}
</style>
</head>

<body>
<div id="main">Content for  id "main" Goes Here Content for  id "main" Goes Here Content for  id "main" Goes Here Content for  id "main" Goes Here <a href="http://www.thesun.co.uk/sol/homepage/showbiz/4672063/kristen-stewart-flashes-bra-award-bash-jim-jams.html">http://www.thesun.co.uk/sol/homepage/showbiz/4672063/kristen-stewart-flashes-bra-award-bash-jim-jams.html</a></div>
</body>
</html>
4

2 回答 2

2

这是因为链接通常被视为一个单词(除非其中有连字符,这就是为什么您的链接最终会在文件名处中断的原因)。

您可以做的一件事是使用word-wrap: break-worddiv 上的样式,但这不适用于所有浏览器。

于 2012-11-29T14:21:09.097 回答
-1

试试这个代码: DEMO

<html>
  <head>
    <style type="text/css">
      #main {width:100px;}
      #main p{word-wrap: break-word;}
      #main a{word-wrap: break-word;}
    </style>
   </head>

   <body>
     <div id="main"><p>Content for  id "main" Goes Here Content for  id "main" Goes Here Content for  id "main" Goes Here Content for  id "main" Goes Here <a href="http://www.thesun.co.uk/sol/homepage/showbiz/4672063/kristen-stewart-flashes-bra-award-bash-jim-jams.html">http://www.thesun.co.uk/sol/homepage/showbiz/4672063/kristen-stewart-flashes-bra-award-bash-jim-jams.html</a></p>
      </div>
   </body>
</html>​
于 2012-11-29T14:21:01.453 回答