2017-02-16 63 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