Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何停止html上的自动样式设置_Javascript_Jquery_Html_Css_Reveal.js - Fatal编程技术网

Javascript 如何停止html上的自动样式设置

Javascript 如何停止html上的自动样式设置,javascript,jquery,html,css,reveal.js,Javascript,Jquery,Html,Css,Reveal.js,我有一些幻灯片,我需要转换成一个单页html。我已经使用jQuery删除了所有添加了reveal.js的类、javascript和样式表的代码。由于某种原因,当我调整页面大小时,一个样式被添加到div中,隐藏了一半的内容 调整大小前的我的代码: <div id="body"> <div id="slides-body"> <section id="slide-Title"> <div id="div-Tit

我有一些幻灯片,我需要转换成一个单页html。我已经使用jQuery删除了所有添加了reveal.js的类、javascript和样式表的代码。由于某种原因,当我调整页面大小时,一个样式被添加到div中,隐藏了一半的内容

调整大小前的我的代码:

<div id="body">
    <div id="slides-body">
        <section id="slide-Title">
            <div id="div-Title">
                <h2>
                    My Title
                </h2>
                <button id="button-Single-Page" style="padding-bottom: 5px" class="smallButton" onclick="singlepagehtmlformat()">Click here for the single page html version.</button>
            </div>
        </section>
    </div>
</div>
<div id="body">
    <div id="slides-body" style="width: 960px; height: 770px; left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%) scale(0.920625);">
        <section id="slide-Title">
            <div id="div-Title">
                <h2>
                    My Title
                </h2>
                <button id="button-Single-Page" style="padding-bottom: 5px" class="smallButton" onclick="singlepagehtmlformat()">Click here for the single page html version.</button>
            </div>
        </section>
    </div>
</div>

我的头衔
单击此处查看单页html版本。
调整大小后的我的代码:

<div id="body">
    <div id="slides-body">
        <section id="slide-Title">
            <div id="div-Title">
                <h2>
                    My Title
                </h2>
                <button id="button-Single-Page" style="padding-bottom: 5px" class="smallButton" onclick="singlepagehtmlformat()">Click here for the single page html version.</button>
            </div>
        </section>
    </div>
</div>
<div id="body">
    <div id="slides-body" style="width: 960px; height: 770px; left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%) scale(0.920625);">
        <section id="slide-Title">
            <div id="div-Title">
                <h2>
                    My Title
                </h2>
                <button id="button-Single-Page" style="padding-bottom: 5px" class="smallButton" onclick="singlepagehtmlformat()">Click here for the single page html version.</button>
            </div>
        </section>
    </div>
</div>

我的头衔
单击此处查看单页html版本。

为什么会这样?如何修复它?

这不是默认行为,必须有一个由@Bas Van Stein在代码中指定的窗口大小调整事件导致

要解决这个问题,您只需从目标div中删除attr“style”

<script>
$().ready(function(){
$( window ).resize(function() {
  $("#slides-body").removeAttr("style");
});
});
</script>

$().ready(函数()){
$(窗口)。调整大小(函数(){
$(“#幻灯片正文”).removeAttr(“样式”);
});
});

示例:

应该是一些javascript onresize事件。这是可行的,但是如果用户没有单击按钮来删除leave.js,就会弄乱leave.js代码。我正在研究一个jquery on refresh函数来解决这个问题。你不需要点击按钮来触发它。这是一个window.resize事件,它将在每次调整窗口大小时执行。我有一个单击按钮来删除discover.js,以防用户不想在该窗体中查看它。我已经知道怎么做了。我动态添加了该脚本以替换leaver.js初始化脚本。谢谢你的帮助!