如何做一个答题网页

其实非常简单,先看一下实例图网页请点击访问https://www.pmcainiao.cn/practice/main.html

网页主页面

章节测试页面

答题页面

其实老生常谈,主要包含有三个部分,那就是Html+Css+JavaScript啦!

html部分:就是网站的主页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习测试平台</title>
    <link rel="stylesheet" href="main.css">
</head>
<body>
    <div class="container">
        <div class="module" id="daily-practice">
            <h2>每日一练</h2>
            <p>每天坚持练习,提升知识水平。</p>
        </div>
        <div class="module" id="chapter-test" onclick="window.location.href='section.html'">
            <h2>章节测试</h2>
            <p>检验每个章节的学习成果。</p>
        </div>
        <div class="module" id="simulation-test">
            <h2>模拟测试</h2>
            <p>模拟真实考试环境,提前适应。</p>
        </div>
        <div class="module" id="real-exam">
            <h2>真题演练</h2>
            <p>使用历年真题进行实战演练。</p>
        </div>
    </div>
    <div class="countdown" id="countdown">2025/3月PMP倒计时: <span id="timer">00:00:00</span></div>
    <script src="main.js"></script>
</body>
</html>

Css部分:主要包含了网页内各个答题按钮的样式,后面会多加一些炫酷的效果哈哈

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: #f4f4f9;
}

.container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 800px;
    width: 90%;
}

.module {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease-in-out;
}

.module:hover {
    transform: scale(1.05);
}

.module h2 {
    color: #333;
}

.module p {
    color: #666;
}

.countdown {
    margin-top: 40px;
    font-size: 24px;
    color: #333;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

JavaScript部分:因为目前的需求不多,仅添加了一个考试倒计时的功能


function startCountdown() {
    // 设置目标日期为 2025 年 3 月 15 日
    const targetDate = new Date("2025-03-15T00:00:00");

    const timer = setInterval(() => {
        const now = new Date().getTime();
        const distance = targetDate - now;

        if (distance < 0) {
            clearInterval(timer);
            document.getElementById('timer').innerHTML = "时间到!";
            return;
        }

        const days = Math.floor(distance / (1000 * 60 * 60 * 24));
        const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        const seconds = Math.floor((distance % (1000 * 60)) / 1000);

        const timerElement = document.getElementById('timer');
        timerElement.innerHTML = `${days.toString().padStart(2, '0')} 天 ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
    }, 1000);
}

// 页面加载完成后启动倒计时
window.onload = startCountdown;

        目前总的来说肯定还是有很多的不完善啦,希望就是抛砖引玉,能够有一个直接可运行的例子引起小伙伴们的学习兴趣,后面会在下班后继续完善的,不说了朋友们,继续沟通(吵架)项目过点去了。

### 设置 Element UI `el-progress` 组件环形进度条渐变背景色 为了使 `el-progress` 的环形进度条拥有渐变背景色,可以通过自定义 CSS 和 JavaScript 来实现这一功能。具体方法如下: #### 方法一:利用内联样式与 SASS 预处理器 通过设置 `:color` 属性并结合 SASS 或其他预处理工具来创建不同状态下的颜色变化。 ```html <template> <div class="progress-container"> <el-progress type="circle" :width="70" :stroke-width="10" :color="customGradientColor" :percentage="percentValue" @click.native="handleClick"></el-progress> </div> </template> <script> export default { data() { return { percentValue: 50, customGradientColor: 'linear-gradient(90deg, rgba(255,0,0,.8), rgba(0,255,0,.8))' }; }, methods: { handleClick(event){ console.log('Progress clicked'); } } }; </script> <style lang="scss" scoped> .progress-container /deep/ .el-progress-circle__track{ stroke-dasharray: none; } .el-progress-circle__path { transition: all ease-in-out 0.3s; } /* 使用深度选择器覆盖默认样式 */ /deep/.el-progress-circle path:nth-of-type(odd) { /* 如果需要针对特定实例调整 */ } /* 对于不同的 div 应用独特的渐变色 */ .progress-item:nth-child(1) .el-progress-circle__path { stroke: linear-gradient(to right, red , yellow); } .progress-item:nth-child(2) .el-progress-circle__path { stroke: linear-gradient(to bottom, blue , green); } // ...以此类推... </style> ``` 此段代码展示了如何使用 Vue.js 结合 SASS 实现多个环形进度条的不同渐变效果[^2]。注意 `/deep/` 是用于穿透scoped样式的特殊语法,在某些版本可能已被替代为 `::v-deep` 或者直接移除以支持新的组合式 API 特性。 #### 方法二:直接操作 DOM 修改 SVG 路径填充 如果希望更灵活地控制渐变逻辑,则可以直接访问底层渲染出来的SVG元素,并对其应用CSS线性或径向渐变规则。 ```javascript mounted(){ this.$nextTick(() => { const svgPath = document.querySelector('.el-progress-circle__path'); if (svgPath) { let gradientId = "grad"; var defs = document.createElementNS("http://www.w3.org/2000/svg", "defs"); // 创建一个 LinearGradient 定义 var grad = document.createElementNS("http://www.w3.org/2000/svg","linearGradient"); grad.setAttribute("id",gradientId); // 添加两个颜色停止点 var stop1 = document.createElementNS("http://www.w3.org/2000/svg","stop"); stop1.setAttribute("offset","0%"); stop1.setAttribute("stop-color","#ffcc00"); var stop2 = document.createElementNS("http://www.w3.org/2000/svg","stop"); stop2.setAttribute("offset","100%"); stop2.setAttribute("stop-color","#ee6e73"); grad.appendChild(stop1); grad.appendChild(stop2); defs.appendChild(grad); svgPath.parentNode.insertBefore(defs, svgPath.nextSibling); svgPath.style.stroke = `url(#${gradientId})`; } }); }, ``` 这种方法绕过了框架层面的限制,允许开发者更加精细地定制视觉表现形式[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值