简体   繁体   English

显示平铺的精灵图片以进行网页导航

[英]Displaying a tiled sprite image for webpage navigation

I'm attempting to program my website's navigation bar so when that page is selected the sprite index changes to highlight the background behind it like a button. 我正在尝试对网站的导航栏进行编程,以便在选择该页面时,精灵索引会更改为像按钮一样突出显示其背后的背景。

The sprite is tiled vertically so the first button is highlighted in the first tile and the second in the next etc. 精灵是垂直平铺的,因此第一个按钮在第一个拼贴中突出显示,第二个按钮在下一个拼贴中突出显示,依此类推。

However I'm also using weebly and am trying to program more and more of it myself to learn, so the navigation code was automatically done thus I'm not sure how to implement it so when a page is selected the button behind is highlighted. 但是,我也在使用weebly,并且我自己尝试编程越来越多的代码,因此导航代码是自动完成的,因此我不确定如何实现它,因此当选择页面时,突出显示了后面的按钮。

In theory I understand how to do it, I'm just unsure of what functions to use as I'm completely new to CSS. 从理论上讲,我知道该怎么做,但是我不确定要使用什么功能,因为我是CSS的新手。 How I would do it is: 1. Work out which code returns the current webpage as a variable 2. Calculate the new position for the tiled background by using: (webpage position) * sprite height, or typing out: if webpage = menu sprite_position = 1 * sprite_height 我将如何做:1.计算出哪个代码将当前网页作为变量返回2.通过使用以下内容计算平铺背景的新位置:(网页位置)*精灵高度,或键入:if webpage = menu sprite_position = 1 * sprite_height

The current code regarding to the navigation is: 有关导航的当前代码为:

#navigation {
  font-family: Ethnocentric, arial, sans-serif;
  position: relative;
  width: 1082px; /*For adjusting the navigation's usable width*/
  height: 29px;
  z-index: 2;
  padding: 11px 0px 0px 45px; /*Fourth argument changes the starting navigation postion*/
  background: url(Ngbck.png) no-repeat;
  _bbbackground: none;
  _fffilter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='files/theme/navigationbg.png', sizingMethod='crop');
}

#navigation ul li {
  float: left;
  font-size: 16px;
  text-transform: uppercase;
  padding: 0px;
  margin: 4px 0px 0px 40px;
}

#navigation ul li a {
  color: #0bf;
}

#navigation ul li a:hover, #navigation ul li#active a {
  color: #f00;
}

#weebly-menus .weebly-menu-wrap { z-index: 5000; margin: 13px 0px 0px 0px; }
#weebly-menus .weebly-menu { padding: 0; margin: 0; list-style: none; }
#weebly-menus .weebly-menu li { float: left; clear: left; width: 168px; text-align: left; }
#weebly-menus .weebly-menu li a { position: relative; display: block; width: 148px; background: #001020; border-top:  none; border-bottom: 1px solid #404a51; border-right: 1px solid #404a51; border-left: 1px solid #404a51; text-decoration: none; font-size: 12px; font-weight: normal; line-height:1; padding: 8px 6px 8px 12px; color: #0bf; }
#weebly-menus .weebly-menu li a:hover { background: #131f28; color: #c00; }

Weebly's engine adds Weebly的引擎添加了

#active

identifier to LI element of currently selected menu. 当前所选菜单的LI元素的标识符。 This identifier is applied to list element in menu and this changes depending on what page you are at the moment. 该标识符应用于菜单中的列表元素,并且根据您当前所处的页面而变化。

So I think in order to modify look of such menu you will need to add selector like #navigation ul li#active or #navigation ul li#active a (depending on effect) at the end of CSS file in template editor - so your custom style is picked. 因此,我认为为了修改此类菜单的外观,您需要在模板编辑器的CSS文件末尾添加选择器,例如#navigation ul li#active#navigation ul li#active a (取决于效果)-因此,您的自定义选择样式。

One has not much access to code that renders Weebly's page yet - but there are some specific rules - so people design customer template for Weebly's already (Penguins' templates?) 人们还没有太多访问呈现Weebly页面的代码的权限-但是有一些特定的规则-因此人们已经为Weebly的客户模板(企鹅的模板?)进行了设计。

Peter 彼得

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM