HTML 和 js 中 "空格 "的使用
最编程
2024-04-28 11:21:41
...
1.
转义字符的写法。
在html标签中使用。
可以写多个,每有一个则会渲染出一个空格,不会像按多个空格键一样,最终只显示一个。
<div>1 2</div> // 1 2
<div>1 2</div> // 1 2
注意:&和结尾的;都不能少
2. 
ASCII编码的写法。
在html标签中使用。
写一个和同时写多个一样,最终只显示一个,类似于按空格键
<div>1 2</div> // 1 2
<div>1 2</div> // 1 2
在js中使用。
可以使用String.fromCharCode(),参数是#后面的数字,可以输出多个空格
console.log(1+ String.fromCharCode(32) + String.fromCharCode(32) + String.fromCharCode(32) +2) // 1 2
3.\xa0
\xa0属于latin(ISO/IEC_8859-1,拉丁字母)中的扩展字符集字符,代表空白符nbsp(non-breaking space)
在html标签中使用。
和 一样,可以写多个,显示多个
<div>1 2</div> // 1 2
在js中使用。
在js中不需要&#,且可以连续写而不用拼接
console.log(1+ '\xa0\xa0\xa0\xa0' +2) //1 2
4.U+0020
属于Unicode字符
在js中使用。用法和\xa0一样
console.log(1+ '\u0020\u0020\u0020\u0020' +2) // 1 2
5.\x20
标准键盘码值表-十六进制
在html标签中使用。只显示一个
<div>1 2</div> // 1 2
在js中使用。
console.log(1+ '\x20\x20\x20\x20' +2) // 1 2
http://www.ssnd.com.cn 化妆品OEM代加工
6.%20
对URI 进行解码的样式,需要用到decodeURIComponent
在js中使用。
console.log(1+ decodeURIComponent('%20')+decodeURIComponent('%20')+decodeURIComponent('%20') +2) // 1 2
7.\t
这种相当于按了tab键,一个相当于4个空格
在js中使用.
console.log(1+ '\t\t\t\t' +2) // 1 2
推荐阅读
-
了解并使用 JAVA 中的 set 和 get 方法
-
使用 Node.js 获取用户的操作系统和版本号
-
实践中的软件测试技术:设计、工具和管理 - 第 2 章第 2.3 节 使用状态转换图设计测试用例
-
2024-04-23 用于查看内存占用情况的 linux 命令 free -h 和 cat /proc/meminfo- i. 要查看 Linux 系统中的内存占用情况,可以使用 free 命令或 top 命令。下面简要介绍这两条命令:
-
位、字节、WORD、DWORD 的区别和联系 - Unicode 和 ANSI 的区别就像输入法中 "全宽 "和 "半宽 "的区别一样。 由于不同的 ANSI 编码有不同的标准(不同的字符集),对于给定的多字节字符串,我们必须知道它使用的是哪种字符集,才能知道它包含哪些 "字符"。对于 UNICODE 字符串来说,无论环境如何,它所代表的 "字符 "内容始终是相同的。Unicode 有一个统一的标准,定义了世界上大多数字符的编码,因此拉丁文、数字、简体中文、繁体中文和日文都可以存储在一个编码中。统一码是一个统一的标准,定义了世界上大多数字符的编码。 比特(Bit)和字节(Byte)的区别:例如USB2.0 标准接口的传输速率为 480Mbps,有一些人误认为是每秒 480 兆比特,同样网络带宽为 2MB,就容易误认为是每秒 2 兆比特。其实,480Mbps 应该是 480 兆比特/秒或 480 兆字节/秒,它等于 "60 兆字节/秒";同样,2MB,应该是 256 兆字节/秒。 Bit 和 Byte 译为 "比特",都是数据计量单位,比特="位 "或 "比特"。 Byte = 字节,即 1byte = 8bits,两者的换算关系为 1:8。 Mbps = mega bits per second(兆位/秒)是速率单位,因此 2M 带宽应为 2 兆位/秒,即 2MBps。MB = 兆字节(Megabytes,兆字节)是单位量,1MB/S(兆字节/秒)= 8MBPS(兆字节/秒)。 通常所说的硬盘容量是指 40GB、80GB、100GB,其中的 B 是指 Byte 也称为 "字节"。 1 KB=1024 字节 1 MB=1024 KB=1024*1024 字节 1 GB=1024 MB=1024*1024*1024 字节 例如,以前所谓的 56KB MODEM 转换过来的 56KBps 除以 8 就是 7Kbyte,所以真正从网上下载文件存在硬盘上的速度也是每秒 7Kbyte;也就是说,用 B 表示传输速度一般指 Bit;用 B 表示容量一般指 Byte。比特、字节、WORD、DWORD 的本质。
-
贪婪算法在 Python、JavaScript、Java、C++ 和 C# 中的多种实现及其在硬币变化、分数骑士、活动选择和使用哈夫曼编码的最小生成树问题中的应用实例
-
如何在 Vue 中呈现使用 Vue 编写的 HTML 文件?
-
微信 "扫一扫 "物联网,全面揭秘 "扫一扫 "背后的扫盲技术!-1.1 扫一扫感知物体是做什么的? 1.1 微信扫一扫是做什么的? 扫一扫识物是指以图片或视频(商品图片:鞋/包/美妆/服饰/家电/玩具/图书/食品/珠宝/家具/其他商品)为输入媒介,挖掘微信内容生态中的有价值信息(电商+百科+资讯,如图1所示),并展示给用户。这里的电商基本涵盖了微信小程序覆盖上亿SKU的全量优质电商,可以支持用户货比N家并直接下单购买,百科和资讯则聚合了微信内的头部自媒体如搜狗、搜搜、百度等,向用户展示和分享拍摄商品相关的内容资讯。 图 1 扫一扫识别功能示意图 欢迎大家更新iOS新版微信→扫一扫→识货,亲自体验,也欢迎大家通过识货界面的反馈按钮向我们提交反馈意见。 扫一扫识物实景图展示 1.2 扫一扫识物有哪些使用场景? 扫一扫识物的目的是为用户访问微信内部生态内容开辟一个新窗口,以用户扫图片为输入形式,为用户提供微信生态内容中的百科、资讯、电商等作为展示页面。除了用户熟悉的扫一扫操作外,我们还将进一步拓展长按操作,让用户更方便地进行扫一扫操作。"扫一扫知事 "的落地场景主要涵盖三大部分: a. 科普知识: a.科普知识。用户通过扫一扫,可以在微信生态圈中获取该对象的百科、资讯等常识或趣闻,帮助用户更好地了解该对象; b.购物场景。同样的搜索功能支持用户看到喜欢的商品立即检索到微信小程序电商中的同款商品,支持用户即扫即购; c.广告场景。扫一扫识别物体可以辅助公众号文章、视频更好地理解其中蕴含的图片信息,从而更好地投放匹配广告,提高点击率。 1.3 Sweep Sense 为 Sweep 家族带来了哪些新技术? 对于扫一扫来说,大家耳熟能详的应该就是扫一扫二维码、扫一扫小程序码、扫一扫条形码、扫一扫翻译了。无论是各种形式的编码还是文字字符,都可以看作是图片的一种特定编码形式,而物的识别则是对自然场景图片的识别,这对于扫一扫家族来说是一个质的飞跃,我们希望从物的识别入手,进一步拓展扫一扫对自然场景图片的理解能力,比如扫酒、扫车、扫植物、扫人脸等服务,如下图3所示。 图 3 Sweep 家族
-
HTML 转义字符:使用转义和转回 HTML 字符的 xss 攻击
-
HTML 和 js 中 "空格 "的使用