SimpleModal containerCSS not working in Firefox or Chrome

别说谁变了你拦得住时间么 提交于 2019-12-11 06:06:37

问题


I tried to override the settings in the default stlyesheet that comes with the simplemodal jquery plugin with containerCSS which is working fine in IE7 but not Firefox or Chrome. Not sure if this is a bug or I am doing something wrong.

jQuery code:

$(document).ready(function() {
    $("#ButtonPopup").click(function() {
        $("#addEditTask").modal({
            onOpen: modalOpen,
            persist: true,
            containerCss: ({ width: "300", height: "200", marginLeft: "-150" })
        });
        return false;
    });
});

HTML code:

<button id="ButtonPopup">Popup</button>
<div id="addEditTask" style="display:none;">
     <p>Aliquam nonummy adipiscing augue. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
     Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada
     libero, sit amet commodo magna eros quis urna.</p>
     <button id="ButtonSave">Save</button>
     <button id="ButtonCancel">Cancel</button>
</div>

Please see this for a working demo and zip download of the code that you can test for yourself.


回答1:


Gecko and WebKit based browsers really like their units. Make sure you always tell it how to measure your values.

Also as a note, if you want to override inline styles from a css file, you can do so by adding !important to the end of the value.

height: 300px !important;

will override the inline styles.

Cheers!




回答2:


Eric Martin answered this via the jquery mailing list.

http://groups.google.com/group/jquery-en/browse_thread/thread/90e58bb317002361

I left out the units which worked find in IE but not in firefox.




回答3:


I would have a look at jqModal instead.



来源:https://stackoverflow.com/questions/238536/simplemodal-containercss-not-working-in-firefox-or-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!