What is the role of the 'aspect-ratio' property in CSS, and how does it enhance responsive design?
Instruction: Explain the 'aspect-ratio' property and its benefits in creating responsive web elements.
Context: This question tests preferred aspect-ratio sizing, its interaction with explicit dimensions and its use in responsive media layouts.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
aspect-ratio supplies a preferred width-to-height ratio for sizing a box. It helps derive an automatic dimension from another dimension; it does not override every explicit size or min/max/content constraint.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> .preview { width: 240px; max-width: 100%; aspect-ratio: 16 / 9; background: #ddd; } .fixed { height: 100px;...