简体   繁体   English

HTML CSS - 在表格单元格中心缩放div,如弹出窗口

[英]HTML CSS -zooming div in center of table cell like popup

I am using Angular.我正在使用角。 In table cell I am using div but I need to show the div like a popup in click event.在表格单元格中,我正在使用 div,但我需要在 click 事件中像弹出窗口一样显示 div。 I made it click event logics but how to show div element like a popup which is placed in between a table cell without using any library like bootsrap or angular material我做了点击事件逻辑,但如何在不使用任何库(如 bootsrap 或 angular material)的情况下显示 div 元素,如放置在表格单元格之间的弹出窗口

 <table>
     <tr>
       <th>Name </tr>
       <th>Age </th>
       <th>Details </th>
       <th> Blood Group</th>
       <th> Phone </th>
     </tr>

     <tr *ngFor= " let details of DetailsList; index as i" >
           <td> {{i + 1}}    <td>
           <td> {{details.name }}    <td>
           <td> {{details.age}}    <td>
           <td> <button (click)="divbox(details)"  > </button> 
           <div *ngIf="details.box" class="boxelement">
                      <button (click)="close(details)" > close</button>

               Address
               No:        {{details.address.no}}
               Area:      {{details.address.area}}
               Pincode:   {{details.address.pincode}}   
           </div>
           <td>
           <td> {{details.bloodgroup}}    <td>
           <td> {{details.phone}}    <td>
     </tr>


 </table

ts part部分

divbox(data){
     data.box = true

}
close(data){
    data.box = false
}


css part css部分

.boxelement{
      background: white;
      border-radius: 2px;
      display: inline-box;
      height: 700px;
      margin: 1rem;
      position: relative;
      width: 70%;
      box-shadow: 0 19px 38px rgba(0,0,0,0.30)
}

I need to this div like a popup in the center of the page is that possible我需要这个 div 就像页面中心的弹出窗口一样是可能的

sample image from internet来自互联网的示例图像

https://wisepops.com/wp-content/uploads/2017/12/Nike-popup-1.png https://wisepops.com/wp-content/uploads/2017/12/Nike-popup-1.png

A simple pop-up which is centered using flex .一个使用flex居中的简单弹出窗口。

You can trigger it by click of button defined to show it and close it using display: none .您可以通过单击定义的按钮来触发它以显示它并使用display: none关闭它。

 function func(){ document.getElementById('container').style.display = "flex"; } function funcClose(){ document.getElementById('container').style.display = "none"; }
 #container { position: fixed; top: 0; left: 0; height: 100vh; width: 100vw; display: none; background-color: rgba(126, 125, 125, 0.5); } #popUP { display: flex; justify-content: center; align-items: center; height: 200px; width: 200px; background-color: rgb(255, 197, 197); margin: auto; position: relative; } #popUP button { position: absolute; right:0; top:0; }
 <button onclick="func()">Pop me UP</button> <div id="container"> <div id="popUP">My first Pop UP <button onclick="funcClose()">X</button> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM