jquery - 如何使 ul 之前的文本在 html 中以单行显示?

标签 jquery html css

我正在使用 jquery li scroll plugin在我创建新闻自动收报机的网站上,这个 jqueryli 滚动插件需要你的新闻在 <li> 中标签和这个插件对我来说工作正常,但问题是我想在新闻行情之前放置文本。

我想要像 NEWS FEED : actual news 这样的输出

目前我已经实现了“实际新闻”,当我尝试将 NEWS FEED 标签放在自动收报机前面时,它出现了我的问题。

问题是,当我将 NEWS FEED 标签放在代码前面时,代码新闻会转到下一行,然后我输出为:

 NEWS FEED :

                                       "actual news "

我用过代码:

<div>NEWS FEED
   <ul id="ticker01">
   <?php foreach ($news_array as $single_news) : ?>
   <li><span><?php echo $single_news; ?><span></li>
   <?php endforeach; ?>
   </ul>
<div>

如何在单行中实现 NEWS FEED 标签和新闻行情?

我已经按如下方式编辑了 css:

.tickercontainer { /* the outer div with the black border */


width: 850px; 
height: 32px; 
margin-left: 100px; 
padding: 0;
overflow: hidden; 
}
.tickercontainer .mask { /* that serves as a mask. so you get a sort of padding both left and right */
position: relative;
left: 10px;
top: 8px;
width: 718px;
}
ul.newsticker { /* that's your list */
position: relative;
left: 750px;
font: bold 10px Verdana;
list-style-type: none;
margin: 0;
padding: 0;

}
ul.newsticker li {
float: left; /* important: display inline gives incorrect results when you check for elem's width */
margin: 0;
padding: 0;
background: #fff;
}
ul.newsticker a {
white-space: nowrap;
padding: 0;
color: #ff0000;
font: bold 10px Verdana;
margin: 0 50px 0 0;
} 
ul.newsticker span {
white-space: nowrap;
padding: 0;
font-family: "Times New Roman";
font-size: 16px;
color: #ff0000;
margin: 0 50px 0 0;
} 



/* liScroll styles */

这是问题 fiddle :click here

最佳答案

好的。

作品:http://jsfiddle.net/p6akP/2/

#outerdiv{
   float:left;
   width:1000px;
 }

.tickercontainer { /* the outer div with the black border */
     width: 850px; 
     height: 32px; 
     float:right;
     padding: 0;
      overflow: hidden; 
 }

 .tickercontainer .mask {
     top:0;
     //other styling you have
  }

 <div id="outerdiv">NEWS FEED
   <ul id="ticker01">
     <li><span>10/10/2007</span><a href="#">The first thing ...</a></li>
     <li><span>10/10/2007</span><a href="#">End up doing is ...</a></li>
     <li><span>10/10/2007</span><a href="#">The code that you ...</a></li>
   </ul>
<div>

关于jquery - 如何使 ul 之前的文本在 html 中以单行显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20106575/

相关文章:

html - 如何在 bootstrap 中将 colls 居中?

html - ipod 和 xcode 模拟器之间的 HTML 元素位置不一致?

jquery - 如何像在 Wella.com 上那样在 div 元素上制作悬停渐变?

html - 如何在没有表格的情况下垂直对齐标题中的元素?

javascript - 使用 Node.js 创建网站

jquery 工具提示在模态窗口后面呈现

javascript - 在 IOS9 中的 Cordova 应用程序上使用 JQuery/Javascript 的 window.history 问题

jquery - 使用Google Closure编译器

javascript - jQuery:如何仅为表的第一行为每个循环设置不同的操作

jquery - 如何从每个子元素中选择第一个元素