[英]Change Position of div in javascript
I want to Change Positioning of HTML div Via Javascript in my existing Script 我想通过现有脚本中的Javascript更改HTML div的位置
Currently This My Existing Javascript is generating in front end. 当前,此My Existing Javascript在前端生成。
<div class="navbar navbar-inverse affix" id="SubMenu" style="top: 72px;">
But i want to make positioning to top:8px
但我想定位到
top:8px
JavaScript is as Below. JavaScript如下。
// Sub-navbar affix on scroll
// ------------------------------------------------------------------------
if ($('#SubMenu').length) {
$('#SubMenu').affix({
offset: {
top: function() {
return $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight();
},
}
}).css('top', $('#navbar-main-container').outerHeight());
// Update values on window resize
$(window).resize(function() {
theTop = $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight();
$('#SubMenu').data('bs.affix').options.offset = {
top: theTop
};
});
$('#SubMenu').on('affixed.bs.affix', function() {
$('a.navbar-brand.scrollTop span').text($('#destination-the-title').val());
});
$('#SubMenu').on('affixed-top.bs.affix', function() {
setTimeout(function() {
$('a.navbar-brand.scrollTop span').text('');
}, 600)
});
}
Since you are using jQuery just use the following line of code. 由于您使用的是jQuery,因此只需使用以下代码行。
$("#SubMenu").css("top","8px");
To be more precise instead if this part 更确切地说,如果这部分
.css('top', $('#navbar-main-container').outerHeight());
add .css("top","8px");
添加
.css("top","8px");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.