【发布时间】:2016-02-25 07:40:57
【问题描述】:
我尝试将存在于带有深色类的 div 标签中的元素对齐设置为居中。我有一个图像和一个带有 img-circle 类的 div 元素,它们大部分位于中心(垂直、水平)。请指教。
请参阅
css:
.img-circle img {
top: 50%;
left: 50%;
border: 6px solid #b9b7b7;
-ms-border-radius: 50%;
border-radius: 50%;
-webkit-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
-ms-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
}
.dark {
position: relative;
z-index: 2;
overflow: hidden;
}
div.dark:after {
position: absolute;
content: '';
top: 50%;
left: 50%;
height: 100%;
width: 100%;
-ms-border-radius: 50%;
border-radius: 50%;
-webkit-box-shadow: 0px 0px 0px 200px rgba(0, 0, 0, 0.3);
-ms-box-shadow: 0px 0px 0px 200px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 0px 200px rgba(0, 0, 0, 0.3);
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
-o-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-transition: all 0.4s;
-moz-transition: all 0.4s;
-ms-transition: all 0.4s;
-o-transition: all 0.4s;
transition: all 0.4s;
}
div.dark:hover:after {
height: 0%;
width: 0%;
}
html:
<div class="dark img-circle">
<div>
<div id="dnn_ctr428_ContentPane" class="img-circle">
<h3>نام من</h3>
<p>توضیحات من </p>
<button class="btn btn-primary">بیشتر ...</button>
<!-- Start_Module_428 --><div id="dnn_ctr428_ModuleContent" class="DNNModuleContent ModDNNHTMLC">
<div id="dnn_ctr428_HtmlModule_lblContent" class="Normal">
<img class="img-responsive" alt="" src="http://www.dnnskin.net/portals/631/team3.png" height="279" width="446">
</div>
</div><!-- End_Module_428 --></div>
</div>
</div>
如果你需要改变这个标签的位置
<h3>نام من</h3>
<p>توضیحات من </p>
<button class="btn btn-primary">بیشتر ...</button>
做吧,没问题
【问题讨论】: