泊头网站优化网络营销成功案例分析
制作网页的时候,为了美观,往往要为网页元素设置特殊形状的背景,比如微信官网的导航栏。最大的问题是,导航菜单栏里面的字数不一样,即背景图需根据内容的长度自动增长,这样就需要用到滑动门的效果。
原理:使用一个a标签,包裹一个span标签。给a标签一个左侧的背景位置,给span标签一个背景右侧的位置。这样两者重合,就会出来滑动门的效果。
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title><style>a{margin: 300px;display: inline-block;height: 33px;background:url("img/sprite/to.png") no-repeat;line-height: 33px;text-decoration: none;color: #fff;font-size: 14px;padding-left: 15px;}span{display: inline-block;height: 33px;background:url("img/sprite/to.png") no-repeat right;padding-right: 15px;}</style>
</head>
<body><a href="#"><span>首页</span></a>
</body>
</html>
效果图: