注意目录和修改相同的字符编码

滑动门--------实现导航栏背景图自适应文字内容多少

制作网页时,为了美观,常常需要为网页元素设置特殊形状的背景,比如微信导航栏,最大的问题是里面的字数不一样多,咋办?

为了使各种特殊形状的背景能够自适应元素中文本内容的多少,出现了CSS滑动门技术。它从新的角度构建页面,使各种特殊形状的背景能够自由拉伸滑动,以适应元素内部的文本内容,可用性更强。 最常见于各种导航栏的滑动门。

 

实现步骤:

1 <a>
2     <span>首页</span>
3 </a>
4 <a>
5     <span>公司详情</span>
6 </a>
 1 a {
 2     padding-left: 15px;
 3     height: 33px;
 4     line-height: 33px;
 5     display: inline-block; 
 6     background: url(./img/to.png) no-repeat;
 7     text-decoration: none;
 8 }
 9 a span {
10     display: inline-block;
11     height: 33px;
12     color: #fff;
13     padding-right: 15px;
14     background: url(img/to.png) no-repeat right;
15 }
16 a:hover,
17 a:hover span {
18     background-image: url(./img/ao.png);
19 }

效果:

 

 

 

posted @ 2021-07-12 12:08  黑使  阅读(83)  评论(0编辑  收藏  举报