1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 6 <title>Examples</title> 7 <style type="text/css"> 8 *{margin:0;padding:0;} 9 span{ padding: 0 20px;line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; height: 1px; 10 } 11 </style> 12 </head> 13 <body> 14 <span>分割线</span> 15 </body> 16 </html>
方法二
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>11</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> </head> <body> <div style=" border-top:1px solid #ddd; 100%; margin:100px auto 0; text-align:center;"><p style=" background:#fff; position:relative; height:30px; line-height:30px; top:-15px; margin:0 auto; display:inline-block; padding:0 20px;">标题文字</p></div> </body> </html>