you create two vertical line, positioned at the top and middle of div. you specified rotate origin at the top rather than the middle.
the angle box are absolute, so you are placing all based the top left corner of the container. basically the 4 quadrants 1 & 2 are 10% from top and 10% from right and left respective. you probably want to transfer to middle, then offset:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vertical Angles with Textboxes</title>
<style>
.container {
position: relative;
width: 200px;
height: 200px;
margin: 50px auto;
}
.line1, .line2 {
position: absolute;
width: 2px;
height: 200px;
background-color: black;
top: 0;
left: 50%;
transform-origin: center;
}
.line1 {
transform: rotate(45deg); /* First line at 45 degrees */
}
.line2 {
transform: rotate(-45deg); /* Second line at -45 degrees */
}
.angle-box {
position: absolute;
width: 40px;
height: 20px;
text-align: center;
font-size: 14px;
border: 1px solid #000;
background-color: #f9f9f9;
}
/* Positioning each angle box (which are twice as wide as high) */
.angle1 { transform: translate(-50%, -150%) translate(100px, 100px); }
.angle2 { transform: translate(25%, -50%) translate(100px, 100px); }
.angle3 { transform: translate(-50%, 50%) translate(100px, 100px);}
.angle4 { transform: translate(-125%, -50%) translate(100px, 100px);}
/* Additional styling to show vertical angle relationships */
.angle-box {
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<div class="line2"></div>
<div class="line1"></div>
<!-- Angle Textboxes -->
<div class="angle-box angle1">∠1</div> <!-- Angle 1 at top left -->
<div class="angle-box angle2">∠2</div> <!-- Angle 2 at top right -->
<div class="angle-box angle3">∠3</div> <!-- Angle 3 at bottom left -->
<div class="angle-box angle4">∠4</div> <!-- Angle 4 at bottom right -->
</div>
</body>
</html>