2017-02-16 34 views
3

我的页面是活在http://brand2o.com/experience.php不工作,和我使用这个CSS垂直居中图像的链接里:top:50%;在Safari

img { 
    position: relative; 
    top: 50%; 
    width: 80%; 
    padding: 10%; 
    transform: translateY(-50%); 
} 

它在Firefox和Chrome正常工作,但Safari浏览器似乎被忽略top: 50%;,我不知道为什么。

在这里,Activision标志被突出显示,正如你所看到的,所有的图像都太高了。

The Activision logo is highlighted, and as you can see, all the images are too far up.

回答

2

试试这个:

main #experienceLogos li a { 
    display: inline-flex; //switch from block display 
    width: 100%; 
    height: 100%; 
} 


main #experienceLogos li img { 
    position: relative; 
    /* top: 50%; Remove this*/ 
    width: 80%; 
    padding: 10%; 
    /* transform: translateY(-50%); Remove this */ 
    -webkit-align-self: center; //safari 7+ 
    align-self: center; 
} 
+1

这肯定效果更好!但奇怪的是,尽管有'height:100%',但并不是所有的链接都是li的完整高度,所以我还为每个li和'align-self:center;添加了'display:inline-flex;'; '给每个环节,哈哈。谢谢! – Eriyu

+0

保存我的一天!谢谢! – KimCrab