当前阅读教程:CSS入门到精通 > Height和Width 属性 | |||||||||||||||||||
阅读(22555525) 收藏 赞(5685) 分享 | |||||||||||||||||||
上一篇: CSS 尺寸 (Dimension) | 下一篇: line-height | ||||||||||||||||||
浏览器支持表格中的数字表示支持该属性的第一个浏览器版本号 属性定义及使用说明height属性设置元素的高度。width属性设置元素的宽度。 注意:width、height属性不包括填充,边框,或页边距!
属性值
实例代码<!doctype html> <html> <head> <meta charset="utf-8"> <title>Height和Width 属性</title> <!--定义内部样式--> <style> img,p{ border: 1px solid grey;/*定义边框*/ } .css1{ width: auto; /*宽度*/ height: auto;/*高度*/ } .css2{ width:300px; /*宽度*/ height: 100px; /*高度*/ } </style> </head> <body> <!--直接写宽度和高度--> <img src="img/tx01.jpg" width="50" height="50"> <!--样式css1中重新定义宽度和高度,按图片真实高度和宽度显示--> <img src="img/tx01.jpg" width="50" height="50"> <p>黄菊华老师</p> <p>黄菊华老师</p> </body> </html> 效果图 |
|||||||||||||||||||
上一篇: CSS 尺寸 (Dimension) | 下一篇: line-height |