white-space norma nowrap强制同一行内显示所有文本文字,让所有文字内容中一排显示不换行

日常我们为了让文字内容在一行内显示完,哪怕宽度不够也不能换行,我们可以使用white-space样式,但如果遇到了html br强制换行标签,无论是设置white-space与否都会被<br>强制换行

昨天仿照娜姐做的标题滚动,自己照着那个js也写了一个,结果发现死活就是不滚动,今天早上发现原来还有一段CSS代码没有看到,这个css代码尤为重要、

其中就是有一个属性:

white-space:nowrap;

2、white-space参数:
normal :  默认处理方式
nowrap :  强制在同一行内显示所有文本,直到文本结束或者遭遇br标签对象才换行。DIVCSS5推荐使用white-space:nowrap强制不换行

文章来源:http://www.divcss5.com/rumen/r401.shtml

滚动代码如下附上:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
#scrollobj01,#scrollobj02 {
white-space: nowrap;
overflow: hidden;
width: 390px;
}

</style>
</head>

<body>
<div >
<div class="gdxw" style="width:510px; margin-top:3px;">
            <img src="images/gdxl_tp2.gif" width="115" height="22" style="float:left;" />
            <div id="scrollobj01" onmouseover="javascript:_stop01();" onmouseout="javascript:_start01();" style="float:left; width:390px; font-size:14px; font-family:‘宋体‘; color:#ff0214;">
                生活生活生活生活生活生活生活生活生活生活生活生活
                    <a href="${document.fileName}?id=${document.id}" target="_blank" style="color:#FF0214;"><b>${document.title}</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </#list>
            </div>

            <script language="javascript" type="text/javascript">
            <!--

            function scroll01(obj) {
                /*往左*/
                var tmp = (obj.scrollLeft)++;
                //当滚动条到达右边顶端时
                if (obj.scrollLeft == tmp) {
                    obj.innerHTML += obj.innerHTML;
                }
                //当滚动条滚动了初始内容的宽度时滚动条回到最左端
                if (obj.scrollLeft >= obj.firstChild.offsetWidth) {
                    obj.scrollLeft = 0;
                }
            }
            var _timer = setInterval("scroll01(document.getElementById(‘scrollobj01‘))", 10);
            function _stop01() {
                if (_timer != null) {
                    clearInterval(_timer);
                }
            }
            function _start01() {
                _timer = setInterval("scroll01(document.getElementById(‘scrollobj01‘))", 10);
            }

            //-->
            </script>
        </div>
        </div>
</body>
</html>

仔细看别人代码

时间: 2024-08-04 01:25:09

white-space norma nowrap强制同一行内显示所有文本文字,让所有文字内容中一排显示不换行的相关文章

用CSS让字体在一行内显示不换行(收藏)

当一行文字超过DIV或者Table的宽度的时候,浏览器中默认是让它换行显示的,如果不想让他换行要怎么办呢? 用CSS让文字在一行内显示不换行的方法   一般的文字截断(适用于内联与块): .text-overflow{display:block;                     /*内联对象需加*/width:31em;word-break:keep-all;           /* 不换行 */white-space:nowrap;          /* 不换行 */overflo

用CSS让字体在一行内显示不换行

青枫 , 2012/07/13 18:08 , css样式设计 , 评论(0) , 阅读(2189) , Via 本站原创 大 | 中 | 小  当一行文字超过DIV或者Table的宽度的时候,浏览器中默认是让它换行显示的,如果不想让他换行要怎么办呢? 用CSS让文字在一行内显示不换行的方法 一般的文字截断(适用于内联与块): .text-overflow{display:block;                     /*内联对象需加*/width:31em;word-break:kee

Java文法(3)—— White Space

------------------------------------------------------------------------------- 说明: White space is defined as the ASCII space character, horizontal tab character, form feed character, and line terminator characters (§3.4). ---------------------------

select自定义箭头问题 。。。和一行内不同颜色的整体鼠标滑过变色

1.select自定义箭头问题 用<select><option></option></select>的时候自带的三角箭头与需要的三角不同,这是还要求有select的背景. background: #536479 url("../images/sel.png") no-repeat 79px; 既有了背景颜色,又有了自定义的三角箭头. 2. 在一行内不同颜色区域鼠标滑过的时候实现整体颜色变化. 如图所示 在tr一行中姓名一列的背景色与其他

dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.

采用dom4j方式解析string类型的xml xml:        String string="<?xmlversion=\"1.0\" encoding=\"UTF-8\"?><ROOT><HEAD><INFO><BUSINESSNO>T065205072015000097</BUSINESSNO><BUSINESSTYPE>T</BUSINESSTYPE&g

Div内部的内容超出部分显示省略号(仅仅只有一行内容)

效果如下: css代码: overflow:hidden;white-space: nowrap;text-overflow:ellipsis; 解释:简单理解就是我要把文本限制在一行(white-space: nowrap;),肯定这一行是有限制的(width),并且你的溢出的部分要隐藏起来(overflow: hidden:),然后出现省略号( text-overflow: ellipsis). text-ellipsis是一个特殊的样式,有关解释是这样的:text-overflow属性仅是

解决一行文本溢出隐藏点击展开之后全部显示并自动换行

var ele=[$("#customize p"),$("#uploadques p"),$("#memberques p")]; var i=0; (function() { ele[i].click( function () { console.log(this); console.log($(this).height()); if ($(this).height() === 20) { $(this).find("i"

Android实现搜索框内自动完成文本框

Android实现搜索框内自动完成文本框 xml文件代码如下: 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:orientation="vertical" 5 android:layout_width=

html中 让 ul 的多个 li 在一行内显示

有时候会需要ul的li都在同一行显示,避免li跑到下一行去,今天遇到了这个问题,记录下来,避免忘记~ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"