[英]How to modify css inline element produce by a used css framework?
Considering the image below, i am wondering how can i change an inline css produce by the javascript from the framework i am using, MaterializeCSS .考虑到下图,我想知道如何从我正在使用的框架MaterializeCSS更改由 javascript 生成的内联 css 。 In my html
i define this:在我的html
我定义了这个:
<ul id='profile-settings' class='dropdown-content' style="display: block; width: 250px !important; left: 124px !important; top: 87.5156px !important;">
but an output will always replace my code into this style(Maybe due to default style set by the javascript?):但是 output 将始终将我的代码替换为这种样式(可能是由于 javascript 设置的默认样式?):
<ul id='profile-settings' class='dropdown-content' style="display: block; width: 100px; left: 275px; top: 51.5156px; height: 194px; transform-origin: 100% 0px; opacity: 1; transform: scaleX(1) scaleY(1);">
I look the default javascript of the framework and i only find this one:我查看了框架的默认 javascript,我只找到了这个:
{key:"_handleMouseLeave",value:function(t){var e=t.toElement||t.relatedTarget,i=!!h(e).closest(".dropdown-content").length,n=!1,s=h(e).closest(".dropdown-trigger");s.length&&s[0].M_Dropdown&&s[0].M_Dropdown.isOpen&&(n=!0),n||i||this.close()}},{key:"_handleDocumentClick",value:function(t){var e=this,i=h(t.target);this.options.closeOnClick&&i.closest(".dropdown-content").length&&!this.isTouchMoving?setTimeout(function(){e.close()},0):!i.closest(".dropdown-trigger").length&&i.closest(".dropdown-content").length||setTimeout(function(){e.close()},0),this.isTouchMoving=!1}},{key:"_handleTriggerKeydown",value:function(t){t.which!==M.keys.ARROW_DOWN&&t.which!==M.keys.ENTER||this.isOpen||(t.preventDefault(),this.open())}},{key:"_handleDocumentTouchmove",value:function(t){h(t.target).closest(".dropdown-content").length&&(this.isTouchMoving=!0)}}
What should i do to change this default我应该怎么做才能更改此默认值
display: block;
width: 100px;
left: 275px;
top: 51.5156px;
height: 194px;
transform-origin: 100% 0px;
opacity: 1;
transform: scaleX(1) scaleY(1);
into进入
display: block;
width: 250px;
left: 124px;
top: 87.5156px;
height: 194px;
transform-origin: 100% 0px;
opacity: 1;
transform: scaleX(1) scaleY(1);
You should try to put the code in a jquery or javascript code with setTimeout instead of writing it inline to ul.您应该尝试使用setTimeout将代码放入jquery或javascript代码中,而不是将其内联写入 ul。 There's a javascript code overriding your inline style.有一个 javascript 代码覆盖了您的内联样式。
To do this:去做这个:
setTimeout(function(){
$('.profile-settings').css({
'display':'block',
'width':'250px',
'left':'124px',
'top':'87.5156px',
'height':'194',
'transform-origin':'100% 0',
'opacity':'1',
'transform':'scaleX(1) scaleY(1)'
})
},1000);
That should apply the code that you want to apply.那应该应用您要应用的代码。 This is a bad practice in frontend side but if there's no other way just do it for now.这在前端是一种不好的做法,但如果没有其他方法,现在就这样做。
You can try what myonline suggested but with a click listener您可以尝试 myonline 的建议,但使用点击监听器
$(document).ready(function() {
$('.profile-settings').click(function() {
$('.profile-settings').css({
'display': 'block',
'width': '250px',
'left': '124px',
'top': '87.5156px',
'height': '194',
'transform-origin': '100% 0',
'opacity': '1',
'transform': 'scaleX(1) scaleY(1)'
})
});
});
And make sure your script loads after your framework script.并确保您的脚本在您的框架脚本之后加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.