3
关注
1783
浏览

如何使用_和|使JavaScript的数字形状?

查看全部 2 个回答

yuchenglong 未验证用户 用户来自于: 广东省
2020-09-16 02:38

你会想等宽字体,你将不得不使用下划线而不是连字符,并且你要心里有负担在第一行的空间的效果...

var myPre = document.getElementById("preformatted"); 
 

 
myPre.innerHTML = " __
| |
|__|
"
#preformatted { 
 
    font-family: monospace; 
 
    white-space: pre; 
 
}
<div id="preformatted"> 
 

 
div>

而且,只是˚F或咧嘴一笑......

// Save references to my two control elements. 
 
var myPre = document.getElementById("preformatted"); 
 
var numInput = document.getElementById("numInput"); 
 

 
// Create an array of the numbers 0 through 9 as 7 segment digits. 
 
var numberStrings = [ 
 
" __ 
| |
|__|
"
, "
|
|
"
, " __
__|
|__
"
, " __
__|
__|
"
, "
|__|
|
"
, " __
|__
__|
"
, " __
|__
|__|
"
, " __
|
|
"
, " __
|__|
|__|
"
, " __
|__|
__|
"
]; // Attach the listeners for the input changes. numInput.addEventListener("keyup", changeNumbers); numInput.addEventListener("change", changeNumbers); function changeNumbers(){ // Simply use the element from the array associated with // the entered number to update the preformatted display. myPre.innerHTML = numberStrings[numInput.value]; }
#preformatted { 
 
    font-family: monospace; 
 
    white-space: pre; 
 
    padding: 5px; 
 
    margin: 5px; 
 
    border: 1px dotted red; 
 
    width: 50px; 
 
    height: 50px; 
 
    position: relative; 
 
    text-align: center; 
 
} 
 
label { 
 
    display: block; 
 
}
<div id="preformatted"> 
 

 
div> 
 

 
<div class="number-entry-pane"> 
 
<label>Enter a digit: 
 
<input type="number" id="numInput" min=0 max=9 />label>

关于作者

问题动态

发布时间
2020-09-15 15:51
更新时间
2022-09-15 16:01
关注人数
3 人关注

相关问题

VM系列振弦采集模块如何修改通讯速率?
数控折弯机到哪买?如何选过?
如何通过改进现有代码让他运行起来
振弦采集读数模块如何恢复出厂参数?
万顺叫车app修改账号绑定的手机号码如何操作?
二三线制输入检测端隔离栅两进两出的可以当做一进两出的使用吗?
农牧行业想要实现数字化转型,有什么好的解决方案?
数组对象中的数组Javascript
美国ascii字符使用了单字节,还有用双字节。有无要emoji表情吗?
在页面加载时触发Javascript文本和图片预览
个人工作笔记 Powered BY WeCenter V4.1.0 © 2024 粤ICP备2020123311号