【问题标题】:How to access the first word in a button text如何访问按钮文本中的第一个单词
【发布时间】:2016-03-17 20:29:53
【问题描述】:

这是我的代码

<button class="mcnTextContent"  type="button" style="text-decoration:underline">Click here to Reactivate your account before Feb. 1, 2016 for FREE</button>

我想让第一个单词(点击)只加下划线。谁能帮我解决这个问题。

谢谢

【问题讨论】:

    标签: html css button underline


    【解决方案1】:

    您可以将 Click 一词包装成样式为 span 的样式,就像这样

    <button class="mcnTextContent"  type="button"><span style="text-decoration:underline">Click</span> here to Reactivate your account before Feb. 1, 2016 for FREE</button>
    

    Original Fiddle

    我也推荐使用内联样式,所以这里没有内联css

    CSS

    #underline{
        text-decoration:underline;
    }
    

    HTML

    <button class="mcnTextContent"  type="button">
        <span id="underline">Click</span> here to Reactivate your account beforeFeb. 1, 2016 for FREE
    </button>
    

    Updated Fiddle

    【讨论】:

    • 你能详细说明为什么内联样式不好。我正要推荐它。 (行内意思是用 将“Click”括起来吗?)
    • 内嵌样式是指标签的style 属性。即&lt;a style=""/&gt;,不建议这样做,因为它会增加您的HTML 代码长度并且难以维护
    【解决方案2】:
    <button class="mcnTextContent"  type="button" >
        <span style="text-decoration:underline;">Click</span> here to Reactivate your account before Feb. 1, 2016 for FREE
    </button>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 2014-02-12
      • 2020-06-07
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      • 2011-12-10
      相关资源
      最近更新 更多