如何建立段落中断的链接

时间:2012-05-05 23:04:41

标签: c# asp.net

我在asp中有这个代码,里面有一个段落和一个链接。问题是它获得的链接超长,所以它制作了页面的设计,无论如何都要让它看起来像一个盒子(就像它有一个换行符)。更具体地说,我有一个看起来像这样的链接

http://www.google.com/cewcexxwrfrgregrfref/rferfrefrferfrefrf_jerfreferfrefrefrefrefrefer_freferfwrfwefewfewfwefewfwefefwefewfwefewf909ew0fwefwefwefwefwefwefwefwefewfwefewffwefwefwefwef99we0fwef__________________fwefwefewfewfw45453rwefwef

我希望它看起来与此类似,这样它就不会破坏我的页面。

            http://www.google.com/cewcexxwrfrgregrfref/
            rferfrefrferfrefrf_jerfreferfrefrefrefrefrefer_
            freferfwrfwefewfewfwefewfwefefwefewfwefewf909e
            w0fwefwefwefwefwefwefwefwefewfwefewffwefwefwefwef99we0f
            wef__________________fwefwefewfewfw45453rwefwef

这是代码

 <h4 class="SubTitle">
 Follow our Instructions</h4>
 <p>
   The instructions can be found in several places but we recommend:
     <br />
       <asp:LinkButton ID="lnkUrl" runat="server" Width="100px"></asp:LinkButton>
 </p>

3 个答案:

答案 0 :(得分:1)

以这种方式使用CSS word-wrap属性:

a { display: block; word-wrap: break-word; }​

你可以看到它正常工作here。所以,在你的代码中它可能是:

<h4 class="SubTitle">Follow our Instructions</h4>
<p>
    The instructions can be found in several places but we recommend:
    <br />
    <asp:LinkButton ID="lnkUrl" runat="server" Style="display: block; word-wrap: break-word; width: 100px;"></asp:LinkButton>
 </p>

答案 1 :(得分:0)

你应该把它放在宽度为div的div中。浏览器会自动为您包装。

<p>
   The instructions can be found in several places but we recommend:
</p>
<div style="width: 100px;">
<asp:LinkButton ID="lnkUrl" runat="server" Width="100px"></asp:LinkButton>
</div>

答案 2 :(得分:0)

 I think this might work, apply this css class to your link
 <head>
 <style type="text/css">
 .nobreak{display:inline;}
 </style>
 </head>

 <h4 class="SubTitle">
  Follow our Instructions</h4>
  <p>
   The instructions can be found in several places but we recommend:
   <br />
  <asp:LinkButton cssClass="nobreak" ID="lnkUrl" runat="server" Width="100px">    </asp:LinkButton>
</p>