- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经创建了这个简单的 javascript 测验应用程序。我也编写了一个进度条,它在我的离线笔记本电脑上运行得非常好,但是当我尝试在 Codepen.io 上上传文件时, 进度条不显示。
谁能解释一下我做错了什么。
代码如下:
var allQuestions = [
{
question: "Before Mt. Everest was discovered, whaich mountain was considered to be the highest mountain in the world?",
choices: ["Mt. Kilimanjaro", "Kanchenjunga", "Mount Everest"],
correctAnswer:1
},
{
question: "Does England have a 4th of July?",
choices: ["Yes","No","I don't know"],
correctAnswer:0
},
{
question: "What is Rupert the bear's middle name?",
choices: ["Bear","He doesn't have one!", "The","Rupert"],
correctAnswer:3
},
{
question: " What can you never eat for breakfast? ",
choices: ["Dinner","Something sugary","Lunch","Supper"],
correctAnswer:0
},
{
question: "If there are three apples and you took two away, how many do you have?",
choices: ["One","Two","None"],
correctAnswer:1
},
{
question: "Spell 'Silk' out loud, 3 times in a row. What do cows drink?",
choices: ["Milk","Water","Juice","Cows can't drink"],
correctAnswer:1
},
{
question: "Which is heavier, 100 pounds of rocks or 100 pounds of gold? ",
choices: ["100 pounds of rocks","100 pounds of rocks","They weigh the same"],
correctAnswer:2
},
{
question: "Can you spell 80 in two letters?",
choices: ["AI-TY","It's not possible","EIGH-TY","A-T"],
correctAnswer:3
},
{
question: "What question must always be answered ''Yes''?",
choices: ["What does Y-E-S spell?","Will everyone die someday?","Does everyone have a biological mother?","Are you a human?"],
correctAnswer:0
},
{
question: "How many sides does a circle have?",
choices: ["The back","None. It's a circle","Two","Four"],
correctAnswer:2
},
{
question: "What has a tail but no body?",
choices: ["A human","A coin","A cloud"],
correctAnswer:1
},
{
question: "What word in the English language is always spelled incorrectly?",
choices: ["It's possible to spell anything right as long as you learn it","Shakespeare","Onomatopoeia","Incorrectly"],
correctAnswer:3
},
{
question: "When do you stop at green and go at red?",
choices: ["Watermelon!","Traffic light!","Garden"],
correctAnswer:0
},
{
question: "What rotates but still remains in the same place?",
choices: ["Bottle (spin the bottle game)","Clock","Stairs"],
correctAnswer:2
},
{
question: "How can you lift an elephant with one hand?",
choices: ["Truck","Use both hands!","Use a lever","There is no such thing"],
correctAnswer:1
}
];
var currentquestion=0;
var correctAnswers=0;
function setupOptions(){
$('#question').html(parseInt(currentquestion)+1+". "+allQuestions[currentquestion].question);
var options = allQuestions[currentquestion].choices;
var formHtml='';
for (var i = 0; i < options.length; i++){
formHtml += '<div><input type="radio" name="option" value="'+i+'" id="option'+i+'"><label for="option'+i+'">'
+allQuestions[currentquestion].choices[i]+'</label></div><br/>';
}
$('#form').html(formHtml);
$("#option0").prop('checked', true);
};
function checkAns(){
if($("input[name=option]:checked").val()==allQuestions[currentquestion].correctAnswer){
correctAnswers++;
};
};
$(document).ready(function(){
$(".jumbotron").hide();
$('#start').click(function() {
$(".jumbotron").fadeIn();
$(this).hide();
});
$(function() {
$( "#progressbar" ).progressbar({
max: allQuestions.length-1,
value: 0
});
});
setupOptions();
$("#next").click(function(){
checkAns();
currentquestion++;
$(function() {
$( "#progressbar" ).progressbar({
value: currentquestion
});
});
if(currentquestion<allQuestions.length){
setupOptions();
if(currentquestion==allQuestions.length-1){
$('#next').html("Submit");
$('#next').click(function(){
$(".jumbotron").hide();
$("#result").html("You correctly answered " + correctAnswers + " out of " + currentquestion + " questions! ").hide();
$("#result").fadeIn(1500);
});
}
};
});
});
html, body, div, span, object, iframe, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body {
line-height:1;
}
article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section {
display:block;
}
nav ul {
list-style:none;
}
blockquote, q {
quotes:none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content:'';
content:none;
}
h1 {
font-size: 15em;
font-family: 'Chonburi', cursive;
}
a {
margin:0;
padding:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
.ui-widget-header {
background-image: none !important;
background-color: #FF7860 !important;
}
label{
display: inline-block;
}
h3, #next {
text-align: center;
display: inline-block;
border-radius: 20%;
}
#result {
font-family: 'Press Start 2P', cursive !important;
font-weight: bold;
font-size: 1.5em;
color: #036;
}
input[name="option"] {
float:left;
}
#form div{
margin:auto;
max-width: 205px;
}
#progressbar {
margin: auto;
margin-top: 20px;
float: none;
width: 50%;
}
#container {
text-align: center;
}
span {
margin:5em;
padding:3em;
}
/* change colours to suit your needs */
ins {
background-color:#ff9;
color:#000;
text-decoration:none;
}
/* change colours to suit your needs */
mark {
background-color:#ff9;
color:#000;
font-style:italic;
font-weight:bold;
}
del {
text-decoration: line-through;
}
abbr[title], dfn[title] {
border-bottom:1px dotted;
cursor:help;
}
table {
border-collapse:collapse;
border-spacing:0;
}
/* change border colour to suit your needs */
hr {
display:block;
height:1px;
border:0;
border-top:1px solid #cccccc;
margin:1em 0;
padding:0;
}
input, select {
vertical-align:middle;
}
.button {
display: inline-block;
padding: 1em;
background-color: #79BD9A;
text-decoration: none !important;
color: white !important;
}
body{
text-align: center;
}
.progress-bar {
float: left;
width: 0;
height: 100%;
font-size: 12px;
line-height: 20px;
color: #fff;
text-align: center;
background-color: #337ab7;
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
-webkit-transition: width .6s ease;
-o-transition: width .6s ease;
transition: width .6s ease;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width = device-width, initial-scale = 1">
<link href='https://fonts.googleapis.com/css?family=Chonburi' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Press+Start+2P' rel='stylesheet' type='text/css'>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<body>
<h1>Quiz</h1>
<br/>
<br/>
<a href="#" id="start" class="btn btn-primary btn-lg">Let's Begin</a>
<br/>
<div class="well jumbotron">
<h3 id="question"></h3>
<br/><br/>
<form id="form">
<div><input type="radio" name="option" value="0" id="option0" checked><label for='option0'></label><br/></div>
<div><input type="radio" name="option" value="1" id="option1"><label for='option1'></label><br/></div>
<div><input type="radio" name="option" value="2" id="option2"><label for='option2'></label><br/></div>
</form>
<br/>
<a href="#" id="next" class="button">Next</a><br/>
<div id="progressbar" class="progress-bar progress-bar-striped"></div>
</div>
<div id="result"></div>
</body>
我还有一些其他问题,这些问题不是 codepen.io 特有的:
标题“测验”没有响应。我该如何解决?
文本选项与 radio
按钮没有完全对齐?
从一个问题转到另一个问题时,如何固定网页的位置?
最佳答案
Unable to show progress bar
.progress-bar
上的 height
规则似乎是罪魁祸首。
- The heading "Quiz" isn't responsive.How do I fix that?
您可以使用视口(viewport)单元,这样字体会随着视口(viewport)的变化而变化。 16.7vw
等于(足够接近)您使用的值 (15em
)。
参见 this有关更多信息的相关问题。
Browsers支持视口(viewport)单位。
- The text options aren't perfectly aligned with the radio buttons?
不知道你说的是什么意思。您将文本居中 - 您不希望它居中吗?
- How can I fix the position of the webpage, when moving from one question to the other?
据此,我假设您不希望页面在您单击下一步时跳到顶部?如果是这样,在“下一步”按钮
的click
事件上,公开事件对象并通过 event.preventDefault();
阻止默认操作>.
关于javascript - 无法显示进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35975987/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!