1

当您单击链接时[Expand][Collapse]会出现,但会随着文本的长度向右移动。
我不希望[Collapse]链接向右移动,我希望它说 put。

如何获取[Collapse]不随文本移动位置的链接?

{| class="mw-collapsible mw-collapsed" style="text-align:left;"<br>
! '''Header'''<br>
|-<br>
|<br>
Line1: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line2: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line3: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line4: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line5: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
|}


4

2 回答 2

1

要阻止展开/折叠链接移动,您可以在表格上设置宽度,例如:

{| class="mw-collapsible mw-collapsed"
! style="width: 50em" | '''Header'''
|-
| Line1: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line2: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line3: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line4: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line5: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
|}

(我删除了额外的<br>元素和对齐:左)

不幸的是,由于“展开”和“折叠”之间的宽度差异,表格标题仍会稍微移动位置。如果您想停止该移动,您可以向 wiki 的全局样式表 Mediawiki:Common.css 添加一条语句,以指定切换的宽度。检查源代码,切换位于 class 的元素中.mw-collapsible-toggle,因此您可以在 Mediawiki:Common.css 中使用如下语句指定宽度:

.mw-collapsible-toggle { width: 5em; }

您还可以将标题左对齐(就像您在原始示例中所做的那样)而不是居中对齐。

于 2014-03-24T20:49:54.187 回答
0

girlwithglasses 的解决方案是正确的。但是,如果 [collapse] 链接仍然移动,那是因为内容(<pre>由于间距而放在 -tags 之间)迫使表格超过 50em 宽。您可以通过显式设置单元格的最大宽度来防止这种情况:

{| class="mw-collapsible mw-collapsed"
! style="width: 50em" | '''Header'''
|-
| style="max-width: 50em" |
  Line1: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line2: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line3: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line4: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
  Line5: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
|}

...或者,当然,通过删除前导空格:

{| class="mw-collapsible mw-collapsed"
! style="width: 50em" | '''Header'''
|-
| Line1: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line2: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line3: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line4: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
Line5: A long line of text that is used to test the position of the [Collapse] link in my document.<br>
|}
于 2014-03-25T09:42:44.197 回答