繁体   English   中英

Safari在我的图片下显示空白?

[英]Safari shows white space under my image?

我不知道为什么Safari在我正在处理的此网站上的图像底部添加空白。

它可以在Firefox和Chrome中正确显示。 图像应固定在页面底部,包括调整大小时。

这是一些HTML

<!-- Page Content -->
<div class="container-fluid">


    <div class="span12">

        <div id="headImage">

            <img class="center fit" src="images/Dale2.png" onmousedown='return false;' ondragstart='return false;'>
        </div>

    </div>

    <!-- ./container -->


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

    <script src="http://code.jquery.com/jquery-latest.js"></script>

    <script type="text/javascript" language="JavaScript">
        function set_body_height() { // set body height = window height
            $('body').height($(window).height());
        }
        $(document).ready(function () {
            $(window).bind('resize', set_body_height);
            set_body_height();
        });


        $('img').bind('contextmenu', function (e) {
            return false;
        });


        $(document).ready(function () {
            $(".center").hover(function () {
                $(this).attr("src", "images/DaleBlurWithText.png");
            }, function () {
                $(this).attr("src", "images/Dale2.png");
            });
        });
    </script>

</body>

和CSS

body {
 max-height:100%;
 min-height: 100%;
 background-color: white;
 padding-top: 50px;
 overflow: hidden;
 -webkit-overflow-scrolling: touch;
}

.navbar {
 background: white;
 border: none;
}

.navbar-brand nav navbar-nav {
 text-align: center;
}

.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
margin: 0;
}

.navbar navbar-collapse {
text-align: center;
}

* {
padding: 0;
margin: 0;
}

.fit {
/* set relative picture size */

max-width: 100%;
max-height: 100%;
}

.center {
 display: block;
 margin: auto;
 bottom-fixed: 0;
 vertical-align: bottom;
}

我将我的.center类的css更改为如下,它解决了该问题:

.center {
    display: block;
    position:fixed;

    /* Center the image */
    right: 0;
    left: 0;

    margin-right: auto;
    margin-left: auto;
    bottom: 0;
    /* set relative picture size */ 
    max-width: 100%;
    max-height: 90%;

}  

尝试将图像设置为display: block

暂无
暂无

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

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