当前位置:网站首页>js打印99乘法表
js打印99乘法表
2022-06-27 07:20:00 【I am the sun?】
代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
for(var i = 1;i <= 9;i++){
for(var j = 1;j <= i;j++){
var sum = j * i;
document.write(j + "*" + i + "=" + sum);
}
document.write("<br />");
}
</script>
</head>
<body>
</body>
</html>
运行结果如下:
于是,我想到了每一个式子之间给它加上 空格,代码如下:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
for(var i = 1;i <= 9;i++){
for(var j = 1;j <= i;j++){
var sum = j * i;
document.write(j + "*" + i + "=" + sum + " ");
}
document.write("<br />");
}
</script>
</head>
<body>
</body>
</html>
运行结果如下:
因此,css它就出现了。我们给每个式子加上宽度。但是又得在一行显示。而块级元素是不能加宽度的,因此我要将块级元素转为行内块元素。代码如下:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
for(var i = 1;i <= 9;i++){
for(var j = 1;j <= i;j++){
var sum = j * i;
document.write("<span>" + j + "*" + i + "=" + sum + "</span>");
}
document.write("<br />");
}
</script>
<style type="text/css">
span {
width: 80px;
display: inline-block;
}
</style>
</head>
<body>
</body>
</html>
运行结果如下:
基本上能交作业了,但是,我浏览器一缩小它就会跑了,如下图:
还能完善吗?当然可以。我们给body设置上宽度就好啦:
代码如下:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
for(var i = 1;i <= 9;i++){
for(var j = 1;j <= i;j++){
var sum = j * i;
document.write("<span>" + j + "*" + i + "=" + sum + "</span>");
}
document.write("<br />");
}
</script>
<style type="text/css">
span {
width: 80px;
display: inline-block;
}
body {
width: 3000px;
}
</style>
</head>
<body>
</body>
</html>
运行结果如下:
现在跑不了啦~~·
边栏推荐
- Origin of forward slash and backslash
- manim 数学引擎
- js中判断奇偶的函数,求圆面积的函数
- RNA SEQ data analysis in R - investigate differentially expressed genes in the data!
- Custom palette for ggplot2
- How torch.gather works
- 2022 cisp-pte (II) SQL injection
- The first part of the construction of the defense system of attack and defense exercise is the introduction and the four stages of Defense
- oracle的similarity方法实现原理
- 语音合成:Tacotron详解【端到端语音合成模型】【与传统语音合成相比,它没有复杂的语音学和声学特征模块,而是仅用<文本序列,语音声谱>配对数据集对神经网络进行训练,因此简化了很多流程】
猜你喜欢

2022 cisp-pte (II) SQL injection
![[graduation season] graduation is the new beginning of your life journey. Are you ready](/img/4e/aa763455da974d9576a31568fc6625.jpg)
[graduation season] graduation is the new beginning of your life journey. Are you ready

使用 Blackbox Exporter 测试网络连通性

语音信号处理-概念(二):幅度谱(短时傅里叶变换谱/STFT spectrum)、梅尔谱(Mel spectrum)【语音的深度学习主要用幅度谱、梅尔谱】【用librosa或torchaudio提取】

Centos7.9 install MySQL 5.7 and set startup

js中如何查看程序运行时间(计时器)

POI replacing text and pictures in docx

MySQL

Machine learning

Park and unpark in unsafe
随机推荐
多表联查--07--- Hash join
[Software Engineering] software engineering review outline of Shandong University
2022 cisp-pte (II) SQL injection
Centos7.9 install MySQL 5.7 and set startup
manim 数学引擎
Interviewer: how to never migrate data and avoid hot issues by using sub database and sub table?
Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch
R language analyzing wine data
apifox学习
(已解决) npm突然报错 Cannot find module ‘D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js‘
guava 教程收集一些案例慢慢写 google工具类
oracle的similarity方法实现原理
DMU software syntax highlighting VIM setting -- Learning Notes 6
程序人生 - 程序员三十五岁瓶颈你怎么看?
再见了,敏捷Scrum
R 语言 基于关联规则与聚类分析的消费行为统计
hutool对称加密
面试官:请你介绍一下缓存穿透、缓存空值、缓存雪崩、缓存击穿的,通俗易懂
数据库系统工程师对口专业有哪些?
uview的安装和功能