源码-JavaScript&jQuery交互式前端开发-第4章-判断和循环
2016-09-27 11:07
811 查看
示例效果:
JS代码:
HTML代码:
CSS代码:
@import url(http://fonts.googleapis.com/css?family=Wellfleet);
body {
background-color: #523620;
color: #fff;
font-family: 'Wellfleet', times, serif;
font-size: 150%;
margin: 0px 0px 0px 0px;}
h1 {
background-image: url('../images/bullseye-logo.png');
background-repeat: no-repeat;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
height: 109px;
width: 643px;
margin: 40px auto;}
#teacher {
float:right;
margin:0px 30px 0px 0px;}
#teacher2 {
float:right;
margin:135px 30px 0px 0px;}
#page1, #page2 {
background-color: #fecc6f;
height: 596px;
padding: 10px;
min-width: 779px;}
#page2 {
height: 730px;}
#answer {
border: 12px double #fff;
color: #523620;
text-align: left;
padding: 20px;
margin: 70px auto 10px auto;
width: 250px;
text-align: center;}
#blackboard {
background-color: #425a5a;
border: 25px solid #523620;
border-radius: 20px;
padding: 40px 20px;
margin: 0px auto;
height: 370px;
width: 600px;
text-align: center;}
JS代码:
var table = 3; // Unit of table var operator = 'addition'; // Type of calculation var i = 1; // Set counter to 1 var msg = ''; // Message if (operator === 'addition') { // Do addition while (i < 11) { msg += i + ' + ' + table + ' = ' + (i + table) + '<br />'; i++; } } else { // Do multiplication while (i < 11) { msg += i + ' x ' + table + ' = ' + (i * table) + '<br />'; i++; } } // Write the message into the page var el = document.getElementById('blackboard'); el.innerHTML = msg;
HTML代码:
<!DOCTYPE html> <html> <head> <title>Bullseye! Tutoring</title> <link rel="stylesheet" href="css/c04.css" /> </head> <body> <section id="page2"> <h1>Bullseye</h1> <img src="images/teacher.png" id="teacher2" alt="" /> <section id="blackboard"></section> </section> <script src="js/example.js"></script> </body> </html>
CSS代码:
@import url(http://fonts.googleapis.com/css?family=Wellfleet);
body {
background-color: #523620;
color: #fff;
font-family: 'Wellfleet', times, serif;
font-size: 150%;
margin: 0px 0px 0px 0px;}
h1 {
background-image: url('../images/bullseye-logo.png');
background-repeat: no-repeat;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
height: 109px;
width: 643px;
margin: 40px auto;}
#teacher {
float:right;
margin:0px 30px 0px 0px;}
#teacher2 {
float:right;
margin:135px 30px 0px 0px;}
#page1, #page2 {
background-color: #fecc6f;
height: 596px;
padding: 10px;
min-width: 779px;}
#page2 {
height: 730px;}
#answer {
border: 12px double #fff;
color: #523620;
text-align: left;
padding: 20px;
margin: 70px auto 10px auto;
width: 250px;
text-align: center;}
#blackboard {
background-color: #425a5a;
border: 25px solid #523620;
border-radius: 20px;
padding: 40px 20px;
margin: 0px auto;
height: 370px;
width: 600px;
text-align: center;}
相关文章推荐
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-文档对象模型
- 源码-JavaScript&jQuery交互式前端开发-第5章-文档对象模型-章节示例
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-Focus和blur事件
- 源码-JavaScript&jQuery交互式前端开发-第1章-编程基础知识
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-表单事件
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-使用构造函数语法创建对象
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-鼠标事件-浮层的显示与关闭
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-示例(Example)
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-浏览器对象模型
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-使用变量来存储字符串
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-HTML事件处理程序
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-鼠标事件-确定光标位置
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-使用字面量语法创建对象
- 源码-JavaScript&jQuery交互式前端开发-第5章-文档对象模型-更新文本和标签
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-在字符串中使用引号
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-HTML5事件
- 源码-JavaScript&jQuery交互式前端开发-第7章-JQuery-修改内容
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-章节示例
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-使用变量来存储数字
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-使用变量来存储布尔值