【问题标题】:Possible to display elements outside modal view in ionic可以在离子模式视图之外显示元素
【发布时间】:2018-04-29 09:16:24
【问题描述】:

目前我有一个 HTML 文件,其中包含一些内容,我在单击按钮时会在 modalview 中显示这些内容。我想检查是否可以在模态视图之外的 HTML 中显示元素。

我尝试使用 css 设置元素的样式,但无法将元素移出 modal-wrapper。

请提供建议。

我还不能在帖子中嵌入图片,所以我提供了一个链接。

Modal View Image

【问题讨论】:

  • 为什么要这么做?模态将在移动设备中全屏显示,因此如果它超出模态视图,您的元素将消失
  • 你能附上你想要的图片吗?
  • 嗨 Duannx,我的模态视图不是全尺寸的,它是 50% 的高度,我打算在模态视图之外放一个徽标。
  • 嗨,shashan,我一会儿附上一张图片。
  • 我附上了一个图片链接,在我的原始帖子内容中显示了模态视图。谢谢

标签: html css ionic-framework ionic2 ionic3


【解决方案1】:

通过引用making modals 50% of sizeround icon css。我已经根据您的要求在下面构建了一个示例。 You can find the working version here

希望对您有所帮助,如果您有任何问题,请告诉我。

Modal.html

<ion-content padding class="main-view">
  <div class="overlay" (click)="dismiss()"></div>
  <div class="modal_content">
    <div class="circle"></div>
    <div class="modal-content">
  <h2>Welcome to Ionic!</h2>
  <p>
    This starter project comes with simple tabs-based layout for apps
    that are going to primarily use a Tabbed UI.
  </p>
  <p>
    Take a look at the <code>pages/</code> directory to add or change tabs,
    update any existing page or create new pages.
  </p>
    </div>
  </div>

</ion-content>

Modal.scss

modal-wrapper {
  position: absolute;
  width: 100%;
  height: 100%;
}

@media not all and (min-height: 600px) and (min-width: 768px) {
  ion-modal ion-backdrop {
    visibility: hidden;
  }
}

@media only screen and (min-height: 0px) and (min-width: 0px) {
  .modal-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

.main-view{
    background: transparent;
  }
  .overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: .5;
    background-color: #333;
  }
  .modal_content {
    display: block;
    position: relative;
    top: calc(50% - (50%/2));
    left: 0;
    right: 0;
    width: 100%;
    height: 50%;
    padding: 10px;
    z-index: 1;
    margin: 0 auto;
    padding: 10px;
    color: #333;
    background: #e8e8e8;
    background: -moz-linear-gradient(top, #fff 0%, #e8e8e8 100%);
    background: -webkit-linear-gradient(top, #fff 0%, #e8e8e8 100%);
    background: linear-gradient(to bottom, #fff 0%, #e8e8e8 100%);
    border-radius: 5px;
    box-shadow: 0 2px 3px rgba(51, 51, 51, .35);
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    //overflow: hidden;
  }

  .circle{
  position:absolute;
  height:100px;
  width:100px;
  border-radius:50%;
  border:3px solid white;
  left:50%;
  margin-left:-55px;
  top: -40px;
  background: #d33;
  z-index: 10000;
}

.modal-content{
  padding-top: 5rem;
}

【讨论】:

  • 您好 Raj,感谢您的帮助。我稍微调整了一下,它现在可以工作了。
  • 很高兴它有帮助:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-12
  • 2012-09-08
  • 1970-01-01
  • 2016-07-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多