div+css基础——9.div其它常用属性
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>div其它常用属性</title> <meta name="keywords" content="自定义关键字"/> <meta name="description" content="自定义描述"/> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <style type="text/css"> #father{ background-color:#FFFF99; width:100%; height:100px; border:1px dashed green; } #son1,#son2,#son3{ background-color:#CC99FF; width:100px; margin-left:5px; margin-top:5px; display:inline; /*三个div显示成一行*/ } #son3{ display:none; /*第三个div隐藏,用于单击展开或隐藏列表*/ } #son2:hover{ /*鼠标上去,改变div背景*/ background-color:#3300FF; cursor:hand; } </style> </head> <body> <div> <div id="father"> <div id="son1">aaaaaaaaaaaaaaaaaaaa</div> <div id="son2">bbbbbbbbbbbbbbbbbbbb</div> <div id="son3">cccccccccccccccccccc</div> </div> </div> </body> </html>
效果截图: