简体   繁体   English

内联块元素在Safari中未垂直对齐

[英]Inline-block elements not vertically aligning in Safari

my inline-block elements are vertically aligning differently in Safari than Chrome and Firefox. 我的内联块元素在Safari中的垂直对齐方式与Chrome和Firefox不同。

Here in Safari they line up as so: 在Safari中,它们按以下方式排列: 在此处输入图片说明

On chrome and firefox I get the desired results: 在chrome和firefox上,我得到了预期的结果:

在此处输入图片说明

Not so sure as to why. 不确定为什么。

html: HTML:

<div id="image_links">
            <div id="image_links_container">
                <div class="image_link"><a href="/programs/default/index"> <img src="/images/layout/whistle.png" height="75px">
                    <span>Programs</span></a></div>
                <div class="image_link"><a href="/pages/index/Referal%20Rewards"> <img src="/images/layout/trophy.png" height="125px">
                    <span>Referal Rewards</span></a></div>
                <div class="image_link"><a href="/events/default/index"> <img src="/images/layout/hockey_sticks.png" height="125px">
                    <span>Events</span></a></div>
                <div class="image_link"><a href="/client_registration"> <img src="/images/layout/puck.png" height="75px">
                    <span>Register Now</span></a></div>                     
            </div>
       </div>

CSS; CSS;

.image_link{
    display: inline-block;
    height:200px;
    vertical-align:baseline !important; 
}
#image_links_container{
    width:1200px;
    margin:0 auto;
    text-align:center;
    padding-top:30px;
    overflow:hidden;

}
#image_links_container a{
    padding: 0 60px;
    position:relative;
    text-decoration:none;

}
#image_links_container a img{
    width: 140px;
    overflow: hidden;    
}
#image_links_container a span{
    position:absolute;
    padding:5px;
    color: #FFF;
    text-transform: uppercase;
    bottom:-55px;
    left:50%;
    margin-left: -100px;
    width:200px;
    height: 31px;
    background-color: rgb(70,70,70);
    font-family:open_sansbold;
    font-size: 160%;    
}
#image_links{
    clear:both;
    position:relative;
    width:100%;
    height:250px;
    background-image: url("/images/layout/default_banner.jpg");
    overflow: hidden;
}

Any help would be appreciated, thanks :) 任何帮助,将不胜感激,谢谢:)

Use vertical-align: bottom; 使用vertical-align: bottom; as vertical-align: baseline; vertical-align: baseline; is the default and causes issues in Safari. 是默认设置,会导致Safari中出现问题。 Floats is a different solution and not necessary here unless you prefer that technique. 浮点数是一种不同的解决方案,除非您更喜欢该技术,否则在此不需要。 I prefer inline-block for this scenario and use it most of the time. 对于这种情况,我更喜欢使用内联块并在大多数情况下使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM