将屏幕分成两个单独的等份离子3

时间:2018-05-23 10:48:59

标签: html css ionic-framework ionic3

目前,他们并不平等:

<div class="homescreen-content" scroll="false">
  <h2>Top</h2>
  ITEM 1
  <hr>
  <h2>Bottom</h2>
  ITEM 2
</div>

我想平均分割屏幕,并希望它具有响应性和居中性。 有没有办法用SplitPane做到这一点?

enter image description here

3 个答案:

答案 0 :(得分:0)

试试这个html和CSS

&#13;
&#13;
body , html {
  height: 100%;
}
.container {
  height: 100%;
  
}
.upper {
  border-bottom: 2px solid;
  height: 50%;
}
.lower {
  height: 50%;
}
&#13;
<div class="container">
   <div class="upper">
     <h2>Top</h2>
     ITEM 1
   </div>
   <div class="lower">
    <h2>Bottom</h2>
    ITEM 2
   </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

&#13;
&#13;
.homescreen-content {
    height: 100%;
    display: flex;
  }
.split {

    position: fixed;
    z-index: 1;
    top: 0;
    overflow-x: hidden;
    padding-top: 20px;
    
}

.test1 {
    left:0;
    height: 55%;
    width: 100%;
    background-color: $white-love;
    border-bottom: 2px solid;
}

.test2 {
    
    left:0;
    top: 55%;
    height: 50%;
    width: 100%;
    background-color: $white-love;
}

.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
&#13;
This is may work:

<div class="homescreen-content" scroll="false">
        <div class="split test1">
                <div class="centered">
                  <h2>TEST1</h2>
                   </div>
              </div>
              <hr>
              <div class="split test2">
                <div class="centered">
                  <h2>TEST</h2>
                </div>
              </div>
</div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

您可以使用 Flexbox 执行此操作:

&#13;
&#13;
body, hr {margin: 0}

.homescreen-content {
  display: flex; /* displays flex-items (children) inline */
  flex-direction: column; /* stacks them vertically */
  height: 100vh; /* 100% of the viewport height */
}

.homescreen-content > div {
  display: flex;
  justify-content: center; /* horizontally centered */
  align-items: center; /* vertically centered */
  flex: 1; /* each stretches and takes equal height of the parent (50vh) */
}
&#13;
<div class="homescreen-content" scroll="false">
  <div>ITEM 1</div>
  <hr>
  <div>ITEM 2</div>
</div>
&#13;
&#13;
&#13;