div内容上下左右居中

<!-- 遮罩层 -->
        <div id="test" >
            <div style="position:absolute;top:50%;left:49%;">
                <font color="red" size="24" style="line-height: 100%;top: 50%">上传中请稍后......</font>
            </div>
        </div>

因为div是块级元素,而font是行级元素,所以,要用div来布局

时间: 2024-08-10 21:29:23

div内容上下左右居中的相关文章

div块上下左右居中

实现div块的上下左右居中: <!DOCTYPE html> <html> <head>     <meta charset="utf-8" />     <title>div块上下左右居中</title> </head> <body>     <div id="div2">     </div>     <style>     *{p

div元素上下左右居中

1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>div元素上下左右居中</title> 6 <style type=

div内容上下居中

今天无聊闲逛技术群,听一哥们说要在div里面居中span内容. 第一印象:vertical-align: middle; 结果失效.百度一下是因为 vertical-align 只对一些特定的样式生效,例如:图片,单元格显示(table-cell) 故此代码修改如下: div{ width: 200px; height: 50px; border: 1px solid; display: table-cell; vertical-align: middle; } 把div渲染成表格形式,类似于

未知宽高元素如何在一个div中上下左右居中对齐

<body> <div id="div1"> <img src="../06图片懒加载/img/img1.png"/> </div></body> 那么,img元素如何在div中居中对齐呢? 第一种方法:第一步:在img标签后面添加一个span元素 <body> <div id="div1"> <img src="../06图片懒加载/img/im

css:子元素div 上下左右居中方法总结

最近在面试,不停地收到了知识冲击,尤其是对于一些基础的css.html.js问题居多,所以自我也在做反思,今天就css问题,如何让一个子元素div块元素上下左右居中 (以下总结方法,都已得到验证). 情景一:一个浏览器页面中,只有一个div模块,让其上下左右居中 解决方案:  { position:fixed;  left:0; right:0; top:0; bottom:0; margin:auto; } 备注:此处小编使用position:fixed为最佳方案,因为position:fix

css div上下左右居中

相信大家都会遇到这样的问题,要求一个块上下左右居中,在这里我总结了几个好用的方法 1.已知要居中的块width height 假设  content 要在f里上下左右居中 <div class="f"><div class="content"></div></div> <style> .f{ width: 800px; height: 800px; position:relative; } .content

css div中内容绝对居中(多行内容)

div中的内容绝对居中(不适合IE6哦,IE6我已经不考虑了),直接看代码吧. <!DOCTYPE HTML> <html> <head> <title>绝对居中 </title> <style type="text/css"> h1, h2, h3, h4, h5 { margin:0px; padding:0px; } .panel { width:300px; height:150px; background

Div内容居中

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn"> <head> <meta ht

元素div 上下左右居中方法总结

情景一:一个浏览器页面中,只有一个div模块,让其上下左右居中 解决方案:  { position:fixed;  left:0; right:0; top:0; bottom:0; margin:auto; } 情景二:一个父元素div,一个已知宽度.高度的子元素div(200*300) 解决方案: 1.position布局 { position:absolute/fixed; top:50%; left:50%; margin-left:-100px; margin-top:-150px;}