Discuss the difference between 'object-fit' and 'background-size' properties in CSS.
Instruction: Explain how 'object-fit' and 'background-size' differ and their appropriate use cases.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
object-fit sizes the replaced content of an element such as an img or video within that element's content box. It does not set the element's own layout dimensions. background-size sizes a background image within its background positioning area, which is controlled by background-origin and is normally the padding box.
<!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> .photo { width: 120px; height: 120px; object-fit: contain; border: 1px solid;...