• 非换行空白:non-breaking space


    一 维基百科(英文版)词条

     

    In word processing and digital typesetting, a non-breaking space (" ") (also called no-break space, non-breakable space (NBSP), hard space, or fixed space) is a space character that prevents an automatic line break at its position. In some formats, including HTML, it also prevents consecutive whitespace characters from collapsing into a single space.

     

    In HTML, the common non-breaking space, which is the same width as the ordinary space character, is encoded as   or  . In Unicode, it is encoded as U+00A0.

     

    1  不可中断空白连同前面一个、后面一个字符都在同一行,不会换行。

    2 多个不可中断空白不会被视为一个字符

    3 不可中断字符,在js中是xA0,在html中是 

     

    二 代码

     

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style type="text/css">
                *{
                    margin:10px 0 0 0;
                    padding:0;
                }
                .box{
                    width:50px;
                    height:50px;
                    background:grey;
                    font-size: 16px;
                }
            </style>
        </head>
        <body style="padding:0 50px;">
            <div class="box" id="box01">
                
            </div>
            <div class="box" id="box02">
                
            </div>
            <script>
                var str01 = '奥路xA0xA0xA0xA0xA0xA0xA0xA0菲';
                document.getElementById('box01').innerHTML = str01;
                var str02 = '奥路&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;菲';
                document.getElementById('box02').innerHTML = str02;
            </script>
        </body>
    </html>

    三 页面效果

  • 相关阅读:
    拓扑排序
    Codeforces #503 C. Elections(贪心,逆向
    Codeforces #367 (Div. 2) D. Vasiliy's Multiset (trie 树)
    字典树
    最大子段和
    P1880 [NOI1995] 石子合并
    P1140 相似基因
    P1280 尼克的任务
    [BZOJ4064/Cerc2012]The Dragon and the knights
    [BZOJ4066]简单题
  • 原文地址:https://www.cnblogs.com/sea-breeze/p/7285558.html
Copyright © 2020-2023  润新知