How to design a CSS for a centered floating confirm dialog?(如何为居中的浮动确认对话框设计 CSS?)
问题描述
我正在寻找一种方法来显示始终位于页面中心并浮动在页面上的确认对话框.
I'm looking for a way to display a confirm dialog that's always centered on the page, and floating over the page.
试过了,但它根本不是始终居中",因为位置是固定的:
Tried that, but it's not 'always centered' at all, since the position is fixed:
.Popup
{
text-align:center;
position: absolute;
bottom: 10%;
left: 27%;
z-index:50;
width: 400px;
background-color: #FFF6BD;
border:2px solid black;
}
有什么想法吗?谢谢
推荐答案
试试这个CSS
#centerpoint {
top: 50%;
left: 50%;
position: absolute;
}
#dialog {
position: relative;
width: 600px;
margin-left: -300px;
height: 400px;
margin-top: -200px;
}
<div id="centerpoint">
<div id="dialog"></div>
</div>
#centerpoint应该是对话框的容器div
#centerpoint should be the container div of the dialog
注意 #centerpoint DIV 应该在 body 元素内或在没有 的元素内>位置:相对;属性
Note that the #centerpoint DIV should be inside the body element or inside elements that don't have a position: relative; property
这篇关于如何为居中的浮动确认对话框设计 CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何为居中的浮动确认对话框设计 CSS?


- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07