平滑滚动生成:目标div上的活动属性

时间:2013-12-12 22:28:00

标签: jquery wordpress twitter-bootstrap scroll

我正在使用jQuery滚动条滚动到页面上的某个元素。在这种情况下,它是Navbar。但是我遇到了一个奇怪的问题。单击按钮以滚动到元素后,结果元素将生成focus属性。

enter image description here

当我单击并取消单击该元素时,这会消失并重新出现。它只在我单击按钮滚动到此位置后才会出现。我尝试使用焦点标记定位div并声明它.navbar:focus { box-shadow: none;}但它不起作用

我正在使用以下内容生成滚动效果并定位元素 <a href="#navigationtop" class="anchorLink">

jQuery(function($) {

  var scrollElement = 'html, body';
 $('html, body').each(function () {
  var initScrollTop = $(this).attr('scrollTop');
  $(this).attr('scrollTop', initScrollTop + 1);
   if ($(this).attr('scrollTop') == initScrollTop + 1) {
  scrollElement = this.nodeName.toLowerCase();
  $(this).attr('scrollTop', initScrollTop);
  return false;
    }    
   });

  // Smooth scrolling for internal links
  $("a[href^='#']").click(function(event) {
  event.preventDefault();

var $this = $(this),
target = this.hash,
$target = $(target);

$(scrollElement).stop().animate({
  'scrollTop': $target.offset().top
}, 500, 'swing', function() {
  window.location.hash = target;
});

});

});

1 个答案:

答案 0 :(得分:0)

在master.css文件中,您有一个样式定义:

.navbar-default {background: #F7F7F7!important; 
border: none!important;
box-shadow: 0 0 10px #888
-moz-box-shadow: 0 0 10px #888;
-webkit-box-shadow: 0 0 10px #888;
font-family: 'Oswald', sans-serif!important;
}

试试这个:

outline: none;添加到此样式定义。

相关问题