gpt4 book ai didi

jquery - 如何使用 IE8 的 jquery 或 javascript 将 marginTop 设置为 Div

转载 作者:行者123 更新时间:2023-11-28 07:56:33 25 4
gpt4 key购买 nike

我在 ascx 页面中有一个如下所示的 div 标签

  <div class="MC_LYT_LOS_Email_DialogCommands" id ="LOS_Email_DialogCommands">
<Button runat="server" PhraseID="1427" ID="btnSend" WaitStyle="BlockButton" />
<Button runat="server" PhraseID="label:COMMON:PREVIEW" ID="btnPreview" Type="Secondary" />
</div>`

下面是CSS:

.MC_LYT_LOS_Email_DialogCommands { margin-top: 25px !important; clear: none; }

以上内容适用于所有浏览器,除非在 IE8 中将网站语言从英语更改为西类牙语。我需要将 margin-Top 从 25px 更改为 5px。我尝试了以下方法似乎都没有用:

 var mydiv = document.getElementById("LOS_Email_DialogCommands");
$('#mydiv').css('cssText', 'margin-top: 5px !important;');
$('#mydiv').css('clear', 'none');

在发布答案之前,它应该只能在 ie8 中工作。

最佳答案

如果你正在使用 jquery,你可以尝试:

 var mydiv = $("#LOS_Email_DialogCommands"); // selects the div
mydiv.css('margin-top', '5px').css('clear', 'none'); //sets style

或者您可以使用一个 css 调用并设置两者:

mydiv.css({'margin-top':'5px', 'clear' : 'none'});//设置两个 css 属性

如果您需要将样式设置为重要,则需要使用attr

mydiv.attr('style', 'margin-top: 5px !important;');//设置为 !important

关于jquery - 如何使用 IE8 的 jquery 或 javascript 将 marginTop 设置为 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30080207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com