Currently, I am experimenting with implementing a frontend code I discovered online for simulating a dice roll.
If you are interested, you can find the code in this repository: https://codesandbox.io/s/xjk3xqnprw?file=/styles.css:0-4535
Here is the HTML code snippet:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Dice Roll</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<div class="dice">
<ol class="die-list even-roll" data-roll="1" id="die-1">
<li class="die-item" data-side="1">
<span class="dot"></span>
</li>
...
</div>
<button type="button" id="roll-button">Roll Dice</button>
<script src="./app.js"></script>
</body>
</html>
As for the CSS styling:
* {
margin: 0;
padding: 0;
vertical-align: baseline;
}
html {
font-family: system-ui, sans-serif;
}
...
However, when I tried to integrate this code into my web project (which utilizes bootstrap5), I encountered issues with the rendering of the dice images. Upon investigation, I discovered that loading bootstrap alongside the code was causing the problem. The result looked like this: https://i.sstatic.net/mcDVw.png
Here is the code snippet for the problematic rendering:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Dice Roll</title>
<link rel="stylesheet" href="./styles.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
</head>
<body>
<div class="dice">
<ol class="die-list even-roll" data-roll="1" id="die-1">
<li class="die-item" data-side="1">
<span class="dot"></span>
</li>
...
</div>
<button type="button" id="roll-button">Roll Dice</button>
<script src="./app.js"></script>
</body>
</html>
I suspect that bootstrap may be overriding some configurations that are affecting the animation display. If anyone has insights on how to identify and override these configurations, I would greatly appreciate your assistance.