Этот сайт имеет ограниченную функциональность, пока мы проводим техническое обслуживание для улучшения его работы. Если какая-либо статья не решила вашу проблему и вы хотите задать вопрос, наше сообщество поддержки ждёт вас: @FirefoxSupport в Твиттере и /r/firefox на Reddit.

Поиск в Поддержке

Избегайте мошенников, выдающих себя за службу поддержки. Мы никогда не попросим вас позвонить, отправить текстовое сообщение или поделиться личной информацией. Сообщайте о подозрительной активности, используя функцию «Пожаловаться».

Подробнее

1, Strange formatting of <B> inside <PRE>, and 2, Unexpected formatting of bogus <D> element

  • 9 ответов
  • 0 имеют эту проблему
  • 1 просмотр
  • Последний ответ от Mark Filipak

more options

FFox 112.0.2 (64-bit) running in Linux Mint 20.3 Una.

1, Strange formatting of <B> inside <PRE>. When using the default monospace font inside a <PRE> element, adding <B> elements disrupts character spacing. A screen shot is attached. "wheat" & "purple" are the colors. They are set in a CSS file. Here is the source HTML:

<PRE class="white">
// (1/240) sec-per-char +-all-strides-------------------------->
<B class="wheat">24pps</B>                // <B class="purple">(Aa______)(Bb______)(Cc______)(Dd______)</B> source pps
<B class="wheat">_hpps(Aa..Dd)</B>        // <B class="purple">(A_______)(B_______)(C_______)(D_______)</B> source top hpps
                     // <B class="purple">(a_______)(b_______)(c_______)(d_______)</B>        bottom hpps
<B class="wheat">(AaBbBcCdDd)=60hpps</B>  // <B class="purple">(A_-20%)(B_________+60%)(C_-20%)(D_-20%)</B> target top hpps
                     // <B class="purple">(a_-20%)(b_-20%)(c_-20%)(d_________+60%)</B>        bottom hpps
<B class="wheat">]30'1.001htfps</B>       // <B class="purple">[A+a___][B+b___][B+c___][C+d___][D+d___]</B> target htfps
                     //                 ================         combed</PRE>

<This character spacing disruption is surely a bug.>

<2, Unexpected formatting of bogus <D> element.> elements to (bogus) <D> elements in the source HTML. The result? The colors were retained and the characters became aligned.>

<What do you think of 1 & 2? Can you test in other browsers -- I can't.>

<Thanks for Your Thoughts,> Mark.

FFox 112.0.2 (64-bit) running in Linux Mint 20.3 Una. 1, Strange formatting of &lt;B&gt; inside &lt;PRE&gt;. When using the default monospace font inside a &lt;PRE&gt; element, adding &lt;B&gt; elements disrupts character spacing. A screen shot is attached. "wheat" & "purple" are the colors. They are set in a CSS file. Here is the source HTML: <pre><nowiki><PRE class="white"> // (1/240) sec-per-char +-all-strides--------------------------> <B class="wheat">24pps</B> // <B class="purple">(Aa______)(Bb______)(Cc______)(Dd______)</B> source pps <B class="wheat">_hpps(Aa..Dd)</B> // <B class="purple">(A_______)(B_______)(C_______)(D_______)</B> source top hpps // <B class="purple">(a_______)(b_______)(c_______)(d_______)</B> bottom hpps <B class="wheat">(AaBbBcCdDd)=60hpps</B> // <B class="purple">(A_-20%)(B_________+60%)(C_-20%)(D_-20%)</B> target top hpps // <B class="purple">(a_-20%)(b_-20%)(c_-20%)(d_________+60%)</B> bottom hpps <B class="wheat">]30'1.001htfps</B> // <B class="purple">[A+a___][B+b___][B+c___][C+d___][D+d___]</B> target htfps // ================ combed</PRE> </nowiki></pre><br> <This character spacing disruption is surely a bug.> <2, Unexpected formatting of bogus <D> element.> <I accidentally changed the <B> elements to (bogus) <D> elements in the source HTML. The result? The colors were retained and the characters became aligned.> <What do you think of 1 & 2? Can you test in other browsers -- I can't.> <Thanks for Your Thoughts,> Mark.
Приложенные скриншоты

Изменено cor-el

Выбранное решение

I came up with a workaround that doesn't depend on bogus elements.

I'll make all the diagrams entirely bold. Then, using a <B> element inside the diagram in order to change background-color won't screw up the vertical alignment.

Thanks for your help. Mark.

Case closed.

Прочитайте этот ответ в контексте 👍 0

Все ответы (9)

more options

The problem statement above got slightly distorted because of formatting, but not badly. There appears to be no way to fix it. I can't find a way to edit the posting. Sorry.

more options

You can't expect that mixing bold characters and normal spaces take the same width because bold spaces have a width that matches the width of the bold character.

Does this also happen if you include the spaces within the <b></b> tags ?

<PRE class="white">
// (1/240) sec-per-char +-all-strides-------------------------->
<B class="wheat">24pps                </B>// <B class="purple">(Aa______)(Bb______)(Cc______)(Dd______)</B> source pps
<B class="wheat">_hpps(Aa..Dd)        </B>// <B class="purple">(A_______)(B_______)(C_______)(D_______)</B> source top hpps
                     // <B class="purple">(a_______)(b_______)(c_______)(d_______)</B>        bottom hpps
<B class="wheat">(AaBbBcCdDd)=60hpps  </B>// <B class="purple">(A_-20%)(B_________+60%)(C_-20%)(D_-20%)</B> target top hpps
                     // <B class="purple">(a_-20%)(b_-20%)(c_-20%)(d_________+60%)</B>        bottom hpps
<B class="wheat">]30'1.001htfps       </B>// <B class="purple">[A+a___][B+b___][B+c___][C+d___][D+d___]</B> target htfps
                     //                 ================         combed
</PRE>


// (1/240) sec-per-char +-all-strides-------------------------->
24pps                // (Aa______)(Bb______)(Cc______)(Dd______) source pps
_hpps(Aa..Dd)        // (A_______)(B_______)(C_______)(D_______) source top hpps
                     // (a_______)(b_______)(c_______)(d_______)        bottom hpps
(AaBbBcCdDd)=60hpps  // (A_-20%)(B_________+60%)(C_-20%)(D_-20%) target top hpps
                     // (a_-20%)(b_-20%)(c_-20%)(d_________+60%)        bottom hpps
]30'1.001htfps       // [A+a___][B+b___][B+c___][C+d___][D+d___] target htfps
                     //                 ================         combed

Изменено cor-el

more options

You can find "Edit this question" under the "Question Tools" menu in the sidebar. For a reply, "Edit this post" is in the three-dot menu next to a reply.

more options

cor-el said

You can't expect that mixing bold characters and normal spaces take the same width because bold spaces have a width that matches the width of the bold character.

Pale Moon doesn't add space. It enboldens characters without taking up more space. I don't/can't run other browsers, so I don't know about them. That's why I asked users to try other browsers.

Изменено Mark Filipak

more options

This might depend on the font that is used as some fonts may have a bold version that takes the same space as the normal version, but a bold font is usually wider than a normal font for readability. You can not know beforehand what font is used, so you need to ensure that the number of bold characters stays the same to ensure proper formatting.

more options

cor-el said

Does this also happen if you include the spaces within the <b></b> tags ?

I tried soooooo many workarounds. Yes, I tried putting everything in <B> elements having differing colors but that provoked other problems.

When I stumbled on (bogus) <D> element that 'fixes' the problem (even though a bogus element shouldn't do anything), and it worked for both Pale Moon (in Windows) and FFox (in Linux), well, I jumpped on it. Does a bogus <D> element also work for other browsers? I don't/can't know. Do you know whether I can rely on it?

PS: Simply changing the background colors is all I need. Do you know of an HTML element that doesn't also make other changes?

Изменено Mark Filipak

more options

Выбранное решение

I came up with a workaround that doesn't depend on bogus elements.

I'll make all the diagrams entirely bold. Then, using a <B> element inside the diagram in order to change background-color won't screw up the vertical alignment.

Thanks for your help. Mark.

Case closed.

more options

You can use a SPAN to change the background color, so no need to use a B tag as that is meant to bold text.

more options

cor-el said

You can use a SPAN to change the background color, so no need to use a B tag as that is meant to bold text.

Using a <SPAN> inside a <PRE> causes too many other problems. Thank you for the suggestion though. -- Mark.