-3

我正在为一个带有 HTML/CSS/JS 的网站做一个测验。测验中的每个问题都有几个可能的答案供您选择。完成测验后,您将获得 0-100% 的分数。

用户提交答案后,需要将用户重定向到另一个页面,该页面将显示他们的分数。

在这个页面上,我还需要用户看到一条线的图像,线的起点代表 0%,线的终点代表 100%。

箭头图像应指向代表其百分比分数的线条区域。这是一张图片证明我的意思

所以,我的问题是:如何动态自定义箭头的位置以适应 0-100% 的任何可能分数?

我在这个网站上看到了一个非常相似的事情,它会根据你对一组政治问题的回答,然后给你一个定制的图像,并根据你的回答在图表上绘制一个点。任何帮助,将不胜感激。

4

2 回答 2

0

一个简单的方法应该是使用 html 和 css 显示结果。

我在其中一个项目中使用的代码如下:

<div id="mainDiv">
  <div id="resultArea" style="width:80%;">
    <div style='font-size:50px;display: inline-block; width: 30%; text-align: right;'>&#8615;</div>
      <div id="resultPercentage" style="padding: 10px 0; border: 1px solid #cccccc; background: #cccccc;">
        <span style="float: left; margin-top: 10px;">0</span>
        <span style="float: right;margin-top: 10px;">100</span>
     </div>
   </div>
   <p>&nbsp;</p>
</div>

请注意,在 id 为“userPercentage”的 div 中,最后一个样式“width: 30%”会将 unicode 箭头符号从 0 移动到 100..

于 2019-03-18T10:50:59.540 回答
-1
HTML <input> element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent.
**HTML:**
<label for="name">Name (4 to 8 characters):</label>

<input type="text" id="name" name="name" required
       minlength="4" maxlength="8" size="10">
**CSS**
label {
    display: block;
    font: 1rem 'Fira Sans', sans-serif;
}

input,
label {
    margin: .4rem 0;
}

.note {
    font-size: .8em;
}
于 2019-03-18T11:18:06.733 回答