小程序如何通过绑定事件传参和触发事件如何获取参数,注意data-name中的name里面有大写或者烤串命名方式会被转换为小写

您可以将CSS和JS代码直接写入HTML文件的头部和尾部的`<style>`和`<script>`标记内。以下是一个示例: ``` <!DOCTYPE html> <html> <head> <title>轮盘选择器</title> <style> #roulette { width: 200px; height: 200px; border-radius: 50%; background-color: #eee; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; position: relative; } .option { width: 80px; height: 80px; border-radius: 50%; background-color: #fff; display: flex; justify-content: center; align-items: center; position: absolute; font-size: 14px; font-weight: bold; text-align: center; } .option:nth-child(odd) { transform: rotate(36deg) translate(100px) rotate(-36deg); } .option:nth-child(even) { transform: rotate(72deg) translate(100px) rotate(-72deg); } .option:nth-child(1) { transform: rotate(0deg) translate(100px) rotate(0deg); } button { margin-top: 20px; font-size: 16px; padding: 10px 20px; } .selected { background-color: #f00; color: #fff; } </style> </head> <body> <div id="roulette"> <div class="option">汉堡</div> <div class="option">披萨</div> <div class="option">牛肉面</div> <div class="option">炸鸡</div> <div class="option">麻辣烫</div> <div class="option">寿司</div> <div class="option">烤肉</div> <div class="option">火锅</div> <div class="option">烤鱼</div> <div class="option">烤串</div> </div> <button onclick="spin()">开始选择</button> <script> function spin() { var options = document.querySelectorAll('.option'); var selected = Math.floor(Math.random() * options.length); options[selected].classList.add('selected'); } </script> </body> </html> ``` 在这个示例,CSS代码被包含在`<style>`标记内,JavaScript代码被包含在`<script>`标记内。这样做可以使HTML文件更加简洁,但如果CSS和JS代码比较复杂和庞大,建议将它们分别写入独立的文件,然后使用`<link>`和`<script>`标记将它们引用到HTML文件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值