im making a shoe customizer and im having trouble with placing my canvas (of threejs) next to my div (the shoe customizer), i made a post asking the same question, but it didn’t get resolved, i did adapt a few things based on the answers, but now the canvas is on top of the div, instead of next to it. PLEASE help.
Main question is: how do i get my canvas-container next to the customizer-container
html
<body>
<img class="logo-image" src="/public/SWEAR-logo.png" alt="SWEAR logo">
<div class="wrapper">
<div class="canvas-container"></div>
<div class="customizer-container">
<img id="close-window" src="/public/close.png" alt="close-window">
<h1 id="name"></h1>
<div class="color-palette-container">
<p>Colors</p>
<div id="color-palette-laces">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-sole">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-sole-top">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-outside1">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-outside2">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-outside3">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<div id="color-palette-inside">
<div><div class="box red" style="background-color: red;"></div> Red </div>
<div><div class="box green" style="background-color: green;"></div> Green </div>
<div><div class="box blue" style="background-color: blue;"></div> Blue </div>
<div><div class="box yellow" style="background-color: yellow;"></div> Yellow </div>
<div><div class="box purple" style="background-color: purple;"></div> Purple </div>
<div><div class="box pink" style="background-color: pink;"></div> Pink </div>
</div>
<p>Fabrics</p>
<div id="color-fabrics-laces">
<div><div class="box-fabric plastic" style="background-color: red;"></div> Plastic </div>
<div><div class="box-fabric metallic" style="background-image: url('/textures/metallic.jpg');"></div> Metallic </div>
<div><div class="box-fabric polyester" style="background-image: url('/textures/polyester.jpg');"></div> Polyester </div>
<div><div class="box-fabric leather" style="background-color: yellow;"></div> Leather </div>
</div>
</div>
<div class="size-container">
<label for="size">Size</label>
<select name="size" id="size">
<option value="" disabled selected>Select</option>
<option value="size-36">36</option>
<option value="size-37">37</option>
<option value="size-38">38</option>
<option value="size-39">39</option>
<option value="size-40">40</option>
<option value="size-41">41</option>
<option value="size-42">42</option>
</select>
</div>
<button id="orderButton" disabled>Order now</button>
</div>
</div>
<script type="module" src="/main.js"></script>
</body>
css
body {
margin: 0;
text-align: center;
font-family: 'Helvetica', sans-serif;
text-transform: uppercase;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.wrapper {
display:flex;
width: 100%
}
.customizer-container{
width: 500px;
height:100vh;
background-color: black;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.canvas-container {
flex: 1;
height: 100vh;
position: relative;
}
javascript
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
const canvas = document.querySelector('.canvas-container');
canvas.appendChild(renderer.domElement);
what it looks like right now:
enter image description here
so now they are stacked on top of eachother, but i want them side by side (canvas on the left, and customizer on the right), without the canvas being compressed
Link to full code: https://github.com/milanaismail/sneaker
2
Answers
I can’t see any canvas tag from your code.
You can render the 3D models in canvas tag only not on div tag.
So you can try like this.
look at this