简体   繁体   English

减少两个连续<sup>元素</sup>之间的空白

[英]Reduce white space between two consecutive <sup> elements

I have the following code我有以下代码

 <p>Test <sup>1</sup> <sup>, 2</sup> </p>

Which are displayed like 1 , 2 .显示为1 , 2 When I try apply some style I don't know where, since no margins or paddings are set.当我尝试应用一些样式时,我不知道在哪里,因为没有设置边距或填充。 So, which style should I apply for all but the first sup ?那么,除了第一个sup之外,我应该应用哪种样式?

You can try just using one sup .您可以尝试只使用一个sup If you need two, you can also try applying a negative margin on sup .如果您需要两个,您也可以尝试在sup上应用负margin Since you don't need it on the first-child but need it on all other children, use this:由于first-child不需要它,但所有其他孩子都需要它,所以使用这个:

p > sup:not(:first-child) {}

See it working here:看到它在这里工作:

 p>sup:not(:first-child) { margin-left: -4px; }
 <p>Test <sup>1,2,</sup> <sup>3</sup> </p> <p>Test <sup>1,</sup> <sup>2,</sup> <sup>3,</sup> <sup>4</sup> </p> <p>Test <sup>1,</sup> <sup>2,</sup> <sup>3,</sup> <sup>4,</sup> <sup>5,</sup> <sup>6,</sup> <sup>7,</sup> <sup>8</sup> </p>

Does this solve your problem ?这能解决你的问题吗?

<p>
    <sup>1, 2</sup>
</p>

If you have to use two elements, then try如果您必须使用两个元素,请尝试

<p>test
      <sup>1</sup>
      <sup style="margin:0; margin-left:-5; padding:0;">, 2</sup>
</p>

I hope I could help you, otherwise I'll need some more info.我希望我能帮助你,否则我需要更多信息。

Just place the comma inside the first <sup> element rather than in the subsequent ones like so:只需将逗号放在第一个<sup>元素中,而不是像这样放在后面的元素中:

 <p>Test <sup>1,</sup> <sup> 2</sup> </p>

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

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