简体   繁体   English

如何在一段文本的第一行之后添加按钮

[英]How to add a button just after the first line in a paragraph of text

I want to have a paragraph where first line will have different font to appear as a title.我想要一个段落,其中第一行将有不同的字体作为标题出现。 Just after that text when first line ends I want to have a button to expand the whole message.就在第一行结束的那个文本之后,我想要一个按钮来展开整个消息。

I am title BUTTON我是标题按钮
This is detailed message which has more width than the first line.这是比第一行更宽的详细信息。 I hope you see what I am trying to achieve.我希望你能看到我正在努力实现的目标。

<p>
    I am title.
    This is detailed message which has more width than the first line. I hope you see what I am trying to achieve.
</p>

p::first-line::after {
  content: "BOTTON"
}

Please submit some code.请提交一些代码。 This is all a bit unclear.这一切都有些不清楚。

But I think you need this:但我认为你需要这个:

p::first-line { 
     --your css--
}

 <h1 style="display:inline-block">I am title</h1> <button style="display:inline-block" onclick="showDetails()">Button</button> <p id="details" style="display:none">this is details which has more width that the first line</p> <script> function showDetails(){ document.getElementById("details").style.display = "block"; } </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM