如何在div内部水平放置一个Grid块?

时间:2017-01-26 01:00:52

标签: html css zurb-foundation

我正在尝试将div网格放在div中,但是当我应用CSS类时,Block网格不会受到影响。

我有视觉效果(大纲是用Firefox扩展名制作的): Block grid alligment

我想看起来像这样: Block grid alligment

正如您所看到的,我还需要对齐网格内容和div内容,但我不知道如何做到这一点。

这是我目前的代码:

<div class="sitios-amigos">


<div class="wrap row small-up-1 medium-up-4">

    <div class="column column-block tarjeta-material">
        <a src="http://www.conacyt.gob.mx/" target="_blank"><img alt="Página web Conacyt" src="img/conacyt.png"/></a>
    </div>
    <div class="column column-block tarjeta-material">
        <a href="http://www.concytep.pue.gob.mx/" target="_blank">
        <img alt="Página web de Concytep" src="img/concytep.png"></a>
    </div>
    <div class="column column-block tarjeta-material">
    <a href="http://www.viep.buap.mx/" target="_blank">
        <img alt="Página web VIEP BUAP" src="img/VIEP.png"></a>
    </div>           
</div>

</div>

CSS:

.sitios-amigos{

background: red;
max-width:11000px;
width: 100%;
margin: 0 auto; 
}
.wrap{
width:90%;
max-width:11000px;
margin: 0 auto;
}
.tarjeta-material {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
margin: 15px 10px;
text-align:center;
}

.tarjeta-material:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}




.tarjeta-material {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
margin: 15px 10px;
text-align:center;
}

.tarjeta-material:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

2 个答案:

答案 0 :(得分:1)

如果要对齐居中的div是另一个div的子节点。这是你可以做的。

.parent-div {
    text-align: center;

.child-div {
    display: inline-block;
}

您也可以在不引用父div的情况下尝试。

.child-div {
    margin-left: auto;
    margin-right: auto;
}

以绝对中间尝试为中心:

.parent-div {
        position: relative;

    .child-div {
        position: absolute;
        top: 50%;
        /* this will put the left edge at 50%. not the image */
        left: 50%;
        /* do a negative margin-left of half the width of your block so you have to find that.*/
        margin-left: -halfthewidth;
        margin-top: -halfthelength;
    }

答案 1 :(得分:0)

您是否尝试过使用bootstrap grid system?他们有很多样本,而且更容易使用..