首页 > 编程知识 正文

超链接如何实现像按钮一样的功能,超链接动作按钮

时间:2023-05-03 11:32:31 阅读:214855 作者:1949

效果图:(点击好现实按钮效果)



HTML菜单栏布局源代码

<!doctype html><html><head><meta charset="utf-8"><title>无标题文档</title></head><body><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">首页</a><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">心情日记</a><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">学习心得</a><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">工作笔记</a><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">生活琐碎</a><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">其他</a></body></html>

后加CSS样式

<style type="text/css"> a{ font-family:Arial; font-size:.9em; text-align:center; margin:3px; } a:hover{ /* 边鼠标经过的效果 */ color:#821818; padding:5px 8px 3px 12px; /* 改变文字位置 */ background-color:#e2c4c9; border-top:1px solid #717171; border-left:1px solid #717171; border-bottom:1px solid #EEE; border-right:1px solid #EEE; } a:link, a:visited{ /* 边鼠标点击后效果 */ color:#A62020; padding:4px 10px 4px 10px; background-color:#ecd8db; text-decoration:none; border-top:1px solid #EEE; /* 边框实现阴影效果 */ border-left:1px solid #EEE; border-bottom:1px solid #717171; border-right:1px solid #717171; } </style>

其中, 鼠标经过超链接的时候 设置的样式 。padding属性意在通过内边距微调来改变文字位置

padding:5px 8px 3px 12px; 

通过设置边框。将边框上边和左边、下边和右边分别设置不同的颜色。制造阴影效果

border-top:1px solid #717171; border-left:1px solid #717171; border-bottom:1px solid #EEE; border-right:1px solid #EEE;

如图   为鼠标经过的效果 边框颜色与上图相反。文字位置也稍作改动
同理 也可以设置鼠标点击后的效果,此时边框颜色恰恰相反


版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。