Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        4年前关闭。
                                                                                            
                
        
我正在尝试将divwidth都设置为heightauto设置为垂直和水平位于屏幕中央。这是我目前完成的CSS,请提供任何帮助。

 #popup {
    position: absolute;
    margin: auto;
    height: auto;
    width: auto;
    display: table;
    padding: 10px;
    max-width: 650px;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

最佳答案

你可以这样做:

的CSS

#popup {
    position: absolute;
    margin: auto;
    font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
    height: auto;
    width: auto;
    display: table;
    padding: 10px;
    max-width: 650px;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}


DEMO HERE

关于html - 垂直和水平对齐没有尺寸的div ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33432117/

10-10 01:30