HTML和CSS:单击按钮后,使用垂直滚动条水平拆分页面

时间:2019-03-29 08:37:40

标签: javascript php html css

<div class="upper">
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>
    <p>1</p>

    <input type="button" name="answer" value="Show Div" onclick="showDiv()" />
</div>

<div id="welcomeDiv"  style="display:none;" class="lower" > WELCOME
   <p>toty</p>
</div>

我想在单击按钮时显示拆分

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找类似this

HTML

<div id="upper-section">

        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>
        <p>1</p>        
      <input type="button" name="answer" value="Show Div" onclick="showDiv()" />
</div>
<div class="lower" id="welcomeDiv"  style="display:none;"></div>

JS

function showDiv() {
   document.getElementById('upper-section').classList.add("upper");
   document.getElementById('welcomeDiv').style.display = "block";
}