Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
css悬停:在底部对齐:如何在顶部对齐?_Css_Css Float - Fatal编程技术网

css悬停:在底部对齐:如何在顶部对齐?

css悬停:在底部对齐:如何在顶部对齐?,css,css-float,Css,Css Float,下面是css: .divPhoto { border:1px solid #999; width:140px; height:140px; border-radius:3px; background-color:#EEE; display:inline-block; margin:10px; transition:0.5s; overflow:hidden; } .divPhoto:hover { border:1p

下面是css:

.divPhoto {
    border:1px solid #999;
    width:140px;
    height:140px;
    border-radius:3px;
    background-color:#EEE;
    display:inline-block;
    margin:10px;
    transition:0.5s;
    overflow:hidden;
}
.divPhoto:hover {
    border:1px solid #0000FF;
    background-color:#CCC;
    cursor:pointer;
    height:175px;
}



foreach($photos as $photo) { ?>

    <div class="divPhoto" >
        <a class="fancybox" data-fancybox-group="gallery" href="upload/<?=$photo->filename?>"><img class="img-polaroid" src="upload/thumb/<?=$photo->filename?>"></a>
        <input type="button" class="btn btnEffacer" value="effacer" style="margin-left:30px;" data="<?=$photo->id?>" />
    </div> 


<? } ?>
.divPhoto{
边框:1px实心#999;
宽度:140px;
高度:140像素;
边界半径:3px;
背景色:#EEE;
显示:内联块;
利润率:10px;
过渡:0.5s;
溢出:隐藏;
}
.divPhoto:悬停{
边框:1px实心#0000FF;
背景色:#CCC;
光标:指针;
高度:175px;
}
foreach($photos作为$photo){?>

由于您将悬停时的高度从140px更改为175px,因此需要在未覆盖状态下添加一些额外的边距底部,以将悬停时的高度填充到175px。

您应该使用
显示:内联表;
用于
.divPhoto
div

.divPhoto {
    border:1px solid #999;
    width:140px;
    height:140px;
    border-radius:3px;
    background-color:#EEE;
    display:inline-table;  /* <= this line */
    margin:10px;
    transition:0.5s;
    overflow:hidden;
}
.divPhoto{
边框:1px实心#999;
宽度:140px;
高度:140像素;
边界半径:3px;
背景色:#EEE;

display:inline table;/*A
垂直对齐:top
.divPhoto
规则应该足够了。

由于元素是内联块,您只需使用
垂直对齐:top

.divPhoto {
    border:1px solid #999;
    width:140px;
    height:140px;
    border-radius:3px;
    background-color:#EEE;
    display:inline-block;
    margin:10px;
    transition:0.5s;
    overflow:hidden;
    vertical-align: top;
}