效果图
<html> <head> <meta charset="utf-8"> <title></title> <base target="_blank" /> <style> a{ color: black; text-decoration: none; /*border:solid 1px #000000;*/ /*行内元素转块级元素*/ display: block; width: 100px; height: 40px; /*文本对齐*/ text-align: center; line-height: 40px; /*改为左浮动*/ float: left; /*设置外边距*/ margin: 10px; } /*设置鼠标悬停*/ a:hover{ color: #ffffff; background-color: #FF0000; } </style> </head> <body> <a href="#" class="">首页</a> <a href="#" class="">公司简介</a> <a href="#" class="">产品中心</a> <a href="#" class="">人才招聘</a> <a href="#" class="def">联系我们</a> </body> </html>