My web page features a striking design with a white background and a tilted black line cutting across. The main attraction is an image of a red ball that I want to stay perfectly aligned with the line as the window is resized, just like in the provided gif.
https://i.sstatic.net/6vnpF.gif
I'm wondering if there's a way to achieve this effect using HTML/CSS alone, although I am open to incorporating JavaScript for a more straightforward solution.
Below is a snippet of my current code:
HTML:<html>
<body>
<img class="image" src="./assets/ball.png">
</body>
</html>
and the CSS:
body {
margin: 0;
padding: 0;
display: flex;
align-items: center;
height: 100vh;
width: 100%;
flex-direction: column;
background-image: url('./assets/bg.png');
background-repeat: no-repeat;
background-size: cover;
}
.image {
margin-top: 42%;
}