html - How to make div into center using html or css
问题描述
I have divs which is displaying at the left side of the page i want to display them on center of the page I have also attached the screen shot of my divs:
$array = [
'Summary' => [
'data' => '<div align="center"style="display: inline-block;width: 10%;" class="page_sum"><h1>Scan Summary:</h1></div>
<div class="page_summary"><br/>
<div><h3 style="display: inline-block;width: 10%;" class="total_found">Total Files Found: '.$totalFind.'</h3></div>
<div><h3 style="display: inline-block;width: 10%;" class="total_dir">Total Directories: '.$totalIsDir.'</h3><br/></div>
<div><h3 style="display: inline-block;width: 10%;" class="planned_sync">Planned Sync Files: '.$totalShouldFind.'</h3></div>
<div><h3 style="display: inline-block;width: 10%;" class="actual_sync">Actual Synced: '.$totalResolved.'</h3><br/></div/>
<div><h3 style="display: inline-block;width: 10%;"class="missing_sync">Missing Synced Files: '.$forOfor.'</h3><div/>',
'colspan' => 5, 'class' => array('foo', 'bar'),
],
];
and my css:
.page_sum{
width: 100px;
height: 50px;
display: inline-block;
}
.page_sum { /* Using drop shadow, should appear identical to box shadow */
-webkit-box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
background: #cccccc;
}
I have just pasted one div css, instead of making div into center it displaying the text into center which is in div. How can I make my divs into center?
Please also find my screen.
CSS:
.page_sum{
width: 100px;
height: 50px;
display: inline-block;
}
.page_sum { /* Using drop shadow, should appear identical to box shadow */
-webkit-box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 11px 0px rgba(0,0,0,0.75);
background: #cccccc;
}
.summary-center {
margin: auto;
width: 50%;
}
and html:
'<div class="summary-center" style="display: inline-block;width: 10%;" class="page_sum"><h1>Scan Summary:</h1></div>
解决方案
如果您在 div.page_sum
和 div中添加类 .summary-center.page_summary
它应该可以工作。
.summary-center {
margin: auto;
width: 50%;
}
推荐阅读
- c - 如何将指向结构的指针数组传递给函数?
- java - 如何在方法 onClick(View v) 中抛出异常
- c# - NRules:在具有自定义基类的规则上使用 DSL 扩展时出现问题
- peoplesoft - 在 PeopleCode 中为提示表重用 SQL 语句
- java - 使用java从Hadoop的加密区域读取文档
- xamarin - Xamarin iOS MapKit 无法将特定图像显示为 Pin
- myget - 为什么 MyGet 提要中的错误版本被标记为软件包的最新版本?
- kubernetes - 如何在 liveness probe / readiness probe 中忽略 kubernetes 中的 http 请求健康检查?
- sql - SQL Server 2008。仅当先前不同时才重复顺序
- ios - 具有相同设置但结果不同的两个堆栈视图