简体   繁体   English

平滑转换菜单下划线

[英]Smooth transforming menu underline

I'm trying to create a border-bottom that "scrolls" with the page under the menu. 我正在尝试创建一个在菜单下的页面“滚动”的底部边框。 So basically, I'm using a one page wordpress theme, and when a user press on a menu item I wan't a border-bottom to move under the menu so it's following the page. 因此,基本上,我使用的是一页wordpress主题,当用户按下菜单项时,我不会在菜单下移动边框,因此会跟随页面。 An excellent example can be found on http://vatorsecurities.se/ If you either press on the menu or scroll down on that page you can find a little border that follows your scrolling. 一个很好的例子可以在http://vatorsecurities.se/上找到。如果您按菜单上的或向下滚动该页面,则会在滚动后找到一个小边框。 You can find the website I'm currently working on on http://euronsin.farrabah.se/ 您可以在http://euronsin.farrabah.se/上找到我当前正在使用的网站。

You can see that I have already added a border-bottom under each menu item when I scroll but I want a smooth transformation as it is on http://vatorsecurities.se So it doesn't just jump between menu items. 您可以看到在滚动时我已经在每个菜单项下添加了一个边框底部,但我希望像http://vatorsecurities.se上那样进行平滑的转换,因此它不只是在菜单项之间跳转。

And I'm not quite sure if I'm completly on the wrong direction when adding a border-bottom, I'm thinking about creating a margin-left and a margin-right that changes when scrolling but I'm not quite sure if that's the right move towards achieving both good code and a good look. 而且我不确定在添加边框底部时是否完全朝错误的方向前进,我在考虑创建在滚动时会发生变化的左边距和右边距,但是我不确定是否这是实现良好代码和外观的正确方法。

Any help with this is highly appreciated. 对此,我们将给予任何帮助。

PS. PS。 I've already searched A LOT for examples and haven't found anything like this. 我已经搜索了很多示例,但没有找到类似的东西。 And understanding the code on website #1 is very hard. 而且,了解网站#1上的代码非常困难。

The website that you gave as an example http://vatorsecurities.se/ uses an id called "active_indicator" witch has these css properties: 您以http://vatorsecurities.se/为例给出的网站使用了一个名为“ active_indicator”的id,它具有以下CSS属性:

#active_indicator {
width: 136px;
height: 3px;
background: #FFF;
position: absolute;
left: 0px;
transition: 0.5s;
opacity: 0;

} }

it also has some additional properties for the positions. 它还具有一些仓位其他属性。

For the smooth transformation you can use the same : transition: 0.5s; 为了顺利进行转换,您可以使用以下命令: transition: 0.5s; that this site uses. 该网站使用的内容。

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

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