Complete the code to make the box positioned absolutely.
div {
position: [1];
width: 100px;
height: 100px;
background-color: red;
}The position property set to absolute makes the element positioned absolutely relative to its nearest positioned ancestor.
Complete the code to move the absolutely positioned box 20px from the top.
div {
position: absolute;
[1]: 20px;
width: 100px;
height: 100px;
background-color: blue;
}The top property moves the absolutely positioned element 20px down from the top edge of its positioned ancestor.
Fix the error in the code to make the child box positioned absolutely inside the parent.
.parent {
position: [1];
width: 200px;
height: 200px;
background-color: lightgray;
}
.child {
position: absolute;
top: 10px;
left: 10px;
width: 50px;
height: 50px;
background-color: green;
}The parent must have a position other than static (default) for the absolutely positioned child to be positioned relative to it. relative is commonly used.
Fill both blanks to create an absolutely positioned box 30px from the right and 40px from the bottom.
div {
position: absolute;
[1]: 30px;
[2]: 40px;
width: 100px;
height: 100px;
background-color: purple;
}The right and bottom properties position the box 30px from the right edge and 40px from the bottom edge of its positioned ancestor.
Fill all three blanks to create a dictionary in Python that maps CSS properties to their values for an absolutely positioned box 10px from top, 15px from left, and 100px wide.
css_styles = {
'[1]': 'absolute',
'[2]': '10px',
'[3]': '15px'
}
width = '100px'The dictionary keys are CSS properties: position, top, and left. The values set the box to absolute position and offsets from top and left.