Prevent scrolling for :target selector?
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 */
}
精彩评论