确定好p标签的位置后,<p><span>这是美女</span></p>,在p标签中加一个span标签,设置span的css时根据p标签的长宽计算好span的margin-top即可
示例代码:
<!DOCTYPE html>
<html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <style> li{list-style:none;} p{position: absolute;top: 0px;left: 48px;background-color: darkgrey;width: 300px;height: 50px;} span{position:absolute;margin-top: 10px;margin-left: 120px;} img{width: 300px;height:300px;margin: 0px;padding: 0px;} </style> <script> </script> </head> <body> <ul> <li> <img src="img/1.jpg"> </li> <li></li> </ul> <p><span>这是美女</span></p> </body></html>