以正确的分割显示页面

时间:2018-10-08 21:38:28

标签: javascript electron

我想创建一个电子应用程序,基本上我想将窗口拆分为左侧,我要显示链接,而右侧,无论我单击到哪个链接,都显示在那里,我认为这只是html和css stuf,但我电子的新功能,这就是我的代码:

<style>
   .split {
      height: 100%;
      position: fixed;
      z-index: 1;
      top: 0;
      overflow-x: hidden;
      padding-top: 20px;
    }

    .left {
      left: 0;
      background-color: #111;
      width: 25%;
    }

    .right {
      right: 0;
      background-color: red;
      width: 75%;
    }

</style>
<script>
    function test() {
    document.getElementById("content").innerHTML = '<object 
    type="text/html" data="add.html" ></object>';
    }
</script>

<div class="split left">

    <h1>Hi</h1>
    <h2>test </h2> <a href="javascript:test()">Some text.</a>
</div>

<div class="split right">

    <div id="content">

    </div>
</div>

1 个答案:

答案 0 :(得分:0)

以下是您提出问题的页面

<!DOCTYPE HTML>
<html>
<head>
    <style>
        .split {
            width: 100%;
            position: fixed;
            z-index: 1;
            top: 0;
            overflow-x: hidden;
            padding-top: 20px;
            height:100%;
        }

        .left {
            left: 0;
            background-color: #111;
            width: 25%;
            float: left;
            height: 100%;
        }

        .right {
            right: 0;
            background-color: red;
            width: 75%;
            float: right;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="split">
        <div class="split left">

            <h1>Hi</h1>
            <h2>test </h2> <a href="javascript:test()">Some text.</a>
        </div>

        <div class="split right">

            <div id="content">

            </div>
        </div>
    </div>
    <script>
        function test() {
            var p = document.createElement("p");
            p.innerText = "This is the test element text";
           
            document.getElementById("content").innerHTML = p.innerHTML;
        }
    </script>

</body>
</html>