html - 滑动到 div 中心的字幕文本

标签 html

我有以下选取框:

<div id="tip"><marquee loop="1" direction="right" behavior="slide">Text</marquee></div>

以上代码将文本从左向右移动并停在 div 的右边缘。有没有办法强制它停在 div 的中心?我不能使用填充,因为文本是随机的并且没有固定长度。

当前行为:

--------------------------------------------------------------------------
 >      >      >      >      >      >       >      >      >          Text
--------------------------------------------------------------------------

我想要的行为:

--------------------------------------------------------------------------
    >    >     >    >     >     >   Text
--------------------------------------------------------------------------

最佳答案

不建议你使用选取框,但如果你真的想要,那么你可以这样做以获得你想要的效果

<div id="tip">
<div class="stop">
<marquee loop="1" direction="right" behavior="slide">Text</marquee>
</div>
</div>

CSS

.stop{width:*your choice*;}

关于html - 滑动到 div 中心的字幕文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9208662/

相关文章:

javascript - jQuery 可滚动 ul 通过箭头(并在到达列表的顶部或底部时删除箭头)

html - 调整窗口大小时居中图像

html - AngularJS - ng-repeat 在数据不可用时显示空单元格

javascript - jQuery .css() 附加或覆盖

html - 在某些 css 样式中使用背景颜色的差异

html - 从自定义包中加载聚合物元素

html - Logo 和导航不在标题中居中

html - 当专注于某个项目时,对讲/画外音不会读取 <legend>

javascript - 如何获取createAt对象?

java - 如何从 HTML 网站中提取数据?