发布时间:2025-12-09 12:04:52 浏览次数:1
height属性用于设置元素的高度。 height属性不包含元素的边距,边距和边框。
用法:
height:auto|length|initial|inherit;
属性值:
用法:
height:auto;
例:
<!DOCTYPE html> <html> <head> <title> CSS height Property </title> <style> .Geeks { height:auto; color:white; font-size:30px; background-color:green; } </style> </head> <body> <h2>CSS height Property</h2> <p class = "Geeks"> GeeksforGeeks:A computer science portal </p> </body> </html> 输出:
用法:
height:length;
例:
<!DOCTYPE html> <html> <head> <title> CSS height Property </title> <style> .Geeks { height:100px; color:white; font-size:30px; background-color:green; } </style> </head> <body> <h2>CSS height Property</h2> <p class = "Geeks"> GeeksforGeeks:A computer science portal </p> </body> </html> 输出:
用法:
height:initial;
例:
<!DOCTYPE html> <html> <head> <title> CSS height Property </title> <style> .Geeks { height:initial; color:white; font-size:30px; background-color:green; } </style> </head> <body> <h2>CSS height Property</h2> <p class = "Geeks"> GeeksforGeeks:A computer science portal </p> </body> </html> 输出:
支持的浏览器:height属性支持的浏览器如下: