简体   繁体   English

如何使内嵌标签<a>在块标签后</a>内联<a>显示</a> <p> <a>?</a>

[英]How to make an inline tag <a> display inline after a block tag <p>?

I need help with HTML, I don't know how to do this. 我需要HTML方面的帮助,但我不知道该怎么做。 So I've got: 所以我有:

<p>Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text <a href="#">Link</a></p>

So it will show: 因此它将显示:

> Text text text Text text text Text text text Text text text Text text > text Text text text Text text text Text text text Text text text > **Link** >文本文本文本文本文本文本文本文本文本文本文本文本文本文本>文本文本文本文本文本文本文本文本文本文本文本文本文本> **链接**

How can I make this link be next to the text but not in the <p> tag? 如何使此链接位于文本旁边而不是在<p>标记中? Is it possible? 可能吗?

Just add display:inline; 只需添加display:inline; to your p tag like this: 到这样的p标签:

p {
    display:inline;
}

Or if you don't want to change every p tag, then add a class and add the property to that like this: 或者,如果您不想更改每个p标签,请添加一个类,并向其添加属性,如下所示:

 p.sameLine {display:inline;} 
 <p class="sameLine">Text text text Text text text Text text text Text text text Text text text Text text text Text text text</p> <a href="#">Link</a> 

jsFiddle: http://jsfiddle.net/AndrewL32/65sf2f66/60/ jsFiddle: http : //jsfiddle.net/AndrewL32/65sf2f66/60/

Try this: 尝试这个:

 <p style="display:inline-block">paragraph</p> <a href="#">anchor</a> 

More information on the display property 有关显示属性的更多信息

请试试这个:

<p style="display:inline">Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text </p> <a href="#">Link</a>

If you try 如果你试试

<p>
    <span class="normal-text">Lots of Texts</span>
    <a href="#">Link</a>
</p>

in your HTML file and 在您的HTML文件中

.normal-text
{
    max-height: 50px;
}

in a corresponding .css file, then you will be able to apply css styling 在相应的.css文件中,那么您将能够应用CSS样式

  • <p> to style everything in the paragraph, text and link included <p>为段落,文本和链接中的所有内容设置样式
  • .normal-text to style everything in the normal, non-linked text .normal-text为普通非链接文本中的所有.normal-text设置样式
  • <a> to style everything to do with the link / anchor. <a>设置与链接/锚点相关的所有样式。

Please see http://www.w3schools.com/cssref/pr_dim_max-height.asp for information on max-height and a useful example. 请参阅http://www.w3schools.com/cssref/pr_dim_max-height.asp,以获取有关最大高度和有用示例的信息。

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

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