开发者

Prevent scrolling for :target selector?

开发者 https://www.devze.com 2023-03-12 19:16 出处:网络
Is there way to prevent scro开发者_运维技巧lling for :target selector, because when a link is fired, scrolling is not smooth.You can only prevent scrolling by using JS. ... But than :target will no lo

Is there way to prevent scro开发者_运维技巧lling for :target selector, because when a link is fired, scrolling is not smooth.


You can only prevent scrolling by using JS. ... But than :target will no longer work. You could just set a target classname with js and use that. Something like:

<a href="#name" onclick="document.getElementById(this.href.substr(1)).className='target';return false">

css:

:target /* no JS browsers */
, .target /* JS */
{
/* rules */
}
0

精彩评论

暂无评论...
验证码 换一张
取 消