! DOCTYPE html html head meta charset ="UTF-8" title CSS / title style type ="text/css" #style1 { font-family : "微软雅黑" ; position : absolute ; left : 340px ; top : 123px ; width : 98px ; height : 90px ; background-color : aliceblue
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>CSS</title> <style type="text/css"> #style1 { font-family: "微软雅黑"; position: absolute; left: 340px; top: 123px; width: 98px; height: 90px; background-color: aliceblue; } #style2 { font-family: "微软雅黑"; position: absolute; left: 540px; top: 223px; width: 234px; height: 317px; background-image: url(img/1511498485601.jpeg); } </style> </head> <body bgcolor="aquamarine"> <div id="style1"> 床前明月光,<br> 疑是地上霜。 <br> 举头望明月, <br> 低头思故乡。 </div> <div id="style2"> </div> </body> </html>
width和height用来控制选区的大小;left、right、top用来控制选区在页面中的位置;background-color: 用来设置背景颜色;background-image:用来设置背景图片。