I am struggling with my website creation as I encounter issues with the .Main div. Despite setting background-color: orange;
in the CSS, the color is not visible on the page. The inspector shows that it is positioned at 1440 x 0. Any assistance would be greatly appreciated.
Here is the code snippet I have so far...
const cursor = document.querySelector('.cursor')
const main = document.querySelector('.Main');
let cursorSize = 50;
document.addEventListener('mousemove', (event) => {
cursor.style.left = `${event.clientX - cursorSize / 2}px`;
cursor.style.top = `${event.clientY - cursorSize / 2}px`;
const isSelectable = event.target.tagName === 'P' || event.target.tagName === 'H2';
if (isSelectable) {
cursor.classList.add('hide'); // Hide the cursor when mouse is over text or text is selected
main.classList.add('cursor-text');
} else {
cursor.classList.remove('hide'); // Show the cursor when mouse is not over text and no text is selected
main.classList.remove('cursor-text');
}
});
document.addEventListener('mousedown', (event) => {
cursorSize = 20;
pointerStyle(event, cursorSize)
});
document.addEventListener('mouseup', (event) => {
cursorSize = 50;
pointerStyle(event, cursorSize)
});
let pointerStyle = (event, size) => {
let newX = event.clientX - size / 2;
let newY = event.clientY - size / 2;
cursor.style.width = `${size}px`;
cursor.style.height = `${size}px`;
cursor.style.left = `${newX}px`;
cursor.style.top = `${newY}px`;
}
body {
font-family: 'Montserrat', sans-serif;
overflow-x: hidden;
width: 100%;
}
.Main{
cursor: none;
background-color: orange;
}
.cursor{
position: absolute;
width: 50px;
height: 50px;
top: 0;
left: 0;
background-color: #84E6BC;
border-radius: 50%;
pointer-events: none;
}
.cursor.hide {
opacity: 0;
pointer-events: none;
}
.cursor-text {
cursor: text;
}
.banner {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60%;
height: 40%;
background-color: #FFFFFF;
border-radius: 60px;
box-shadow: 0px 6px 20px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 2em;
font-weight: bold;
text-align: center;
margin-bottom: 40px;
}
.subheading {
font-size: var(--p-size);
text-align: center;
margin-bottom: 40px;
}
.smiley {
fill: #84E6BC;
}
<div class="Main">
<div class="banner">
<h2 class="title">Thank you!</h2>
<p class="subheading">I really appreciate you contacting me. I will be in touch shortly.</p>
<svg class="smiley" xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM7 6.5C7 7.328 6.552 8 6 8s-1-.672-1-1.5S5.448 5 6 5s1 .672 1 1.5zM4.285 9.567a.5.5 0 0 1 .683.183A3.498 3.498 0 0 0 8 11.5a3.498 3.498 0 0 0 3.032-1.75.5.5 0 1 1 .866.5A4.498 4.498 0 0 1 8 12.5a4.498 4.498 0 0 1-3.898-2.25.5.5 0 0 1 .183-.683zM10 8c-.552 0-1-.672-1-1.5S9.448 5 10 5s1 .672 1 1.5S10.552 8 10 8z"/>
</svg>
</div>
<div class="cursor"></div>
</div>