如何从左下角聚焦图像?

时间:2015-04-13 01:22:12

标签: html css image focus

我得到了一切,但我似乎无法超越边缘顶部。我需要第四个孩子从底部而不是从中间聚焦。

.gallerya a:focus img{
width: 350%; 
height: 350%;
margin-left:-120%;
margin-top:-50%;
position: absolute;
opacity: 1; 
z-index: 1; 
-moz-box-shadow: 0 0 5px 1px #4D4D4D;
-webkit-box-shadow: 0 0 5px 1px #4D4D4D;
box-shadow: 0 0 5px 1px #4D4D4D; 
-webkit-transition-duration: 1s; 
-webkit-transition-delay: 0.1s; 
-moz-transition-property: width, height;
-moz-transition-duration: 1s;
-moz-transition-delay: 0.1s;
-o-transition-property:width, height;
-o-transition-duration: 1s;
-o-transition-delay: 0.1s;
cursor: default;
}

.gallerya a:first-child img{
margin-left: 0;
margin-top: 0;
}

.gallerya a:nth-child(3) img{
right:0;
margin-top: 0;
}

.gallerya a:nth-child(4) img{
margin-left:0;
}

Codepen example

2 个答案:

答案 0 :(得分:1)

老实说,你想要达到的目标并不是很清楚。如果您的意思是要重置margin-top:-50%并使用该图像的底部/左侧位置,您可以尝试

margin-top:auto; // reset
margin-left:0px!important;
margin-bottom:0px!important;

答案 1 :(得分:1)

你的意思是底部是这样固定的吗?

margin-top:auto; // reset
margin-left:0px!important;
bottom:0px!important;