3
关注
1769
浏览

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

为什么被折叠? 0 个回复被折叠
De芙 未验证用户 用户来自于: 广东省
2020-09-17 01:43

我想这是你正在尝试做的。

document.write("
 ______
"
); for(i=0;i<6;i++) { document.write("
|  |
"
) } document.write("
 ______
"
);
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 人关注

相关问题

对干只有一个输出端的时钟信号线,如何实现差分布线?
如何知道当前页面代码添加到窗口中的对象?
语音识别快速纠错如何处理?
如何实现技术再次提升?
将函数赋值给使用“this”引用自身的数组对象
乡镇边界数据和行政村边界数据如何获取得到啊?
如何实现价值,技术的双重提升标准。
振弦采集模块如何判断数据是否是有效值?
的Javascript为什么我可以访问的功能
word文档如何去除这个竖线
个人工作笔记 Powered BY WeCenter V4.1.0 © 2024 粤ICP备2020123311号