【发布时间】:2021-06-29 17:13:07
【问题描述】:
我有以下代码:
<marquee><p>{a long text}</p></marquee>
选框内的文本在 webkit 浏览器中以多行显示。如何强制它出现在一行中?删除<p> 标签可以解决问题,但我想知道是否有办法而不是删除<p> 标签。
【问题讨论】:
-
在 内移动 会发生什么?
我有以下代码:
<marquee><p>{a long text}</p></marquee>
选框内的文本在 webkit 浏览器中以多行显示。如何强制它出现在一行中?删除<p> 标签可以解决问题,但我想知道是否有办法而不是删除<p> 标签。
【问题讨论】:
marquee p
{
white-space:nowrap;
}
【讨论】:
<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>
【讨论】:
这里是完整的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 获取上述代码的实时示例。
【讨论】:
我在 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}}    
{%endfor%}
</p>
</marquee>
</div>
【讨论】: