【问题标题】:Marquee text appears in multiple lines选取框文本出现在多行中
【发布时间】:2021-06-29 17:13:07
【问题描述】:

我有以下代码:

<marquee><p>{a long text}</p></marquee>

选框内的文本在 webkit 浏览器中以多行显示。如何强制它出现在一行中?删除&lt;p&gt; 标签可以解决问题,但我想知道是否有办法而不是删除&lt;p&gt; 标签。

【问题讨论】:

  • 在

    内移动 会发生什么?

标签: html marquee


【解决方案1】:
marquee p
{
    white-space:nowrap;
}

【讨论】:

    【解决方案2】:
    <marquee behavior="scroll" direction="left">
        Welcome! Feel free to surf on our website. 
        <span style="margin-left:1in;"></span> 
        This makes it appear as two marquees in 1 line
    </marquee>
    

    【讨论】:

    【解决方案3】:

    这里是完整的code 以了解同一行的字幕文本。

    <!DOCTYPE html>
    <html>
    <head>
        <title>Marquee Text on the same line</title>
        <style type="text/css"> 
        marquee span { 
        margin-right: 100%; 
        } 
        marquee p { 
        white-space:nowrap;
        margin-right: 1000px; 
        } 
    </style> 
    </head>
    <body>
      <marquee scrollamount="10"><b>Hello, I am a StackOverflow user.<span> </span> And I Code the Web.</b></marquee> 
    </body>
    </html>
    

    Click here 获取上述代码的实时示例。

    【讨论】:

      【解决方案4】:

      我在 Django 中尝试了下面的代码片段,效果很好。

          <div class="alert alert-success" role="alert">
              <marquee width="100%" direction="left" height="30px" scrollamount="8">
                  <p style="text-align: center;">
                      {%for message in message_obj%}
                      {{message.message}}&emsp;&emsp;&emsp;&emsp;
                      {%endfor%} 
                  </p>
              </marquee>
          </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-02-22
        • 1970-01-01
        • 2021-09-02
        • 1970-01-01
        • 2021-03-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多