asp.net IE下div背景圖片100%拉伸填充,可以縮放

暖楓無敵發表於2012-08-02

看到CSDN上有人提問,就簡單做了個,僅在IE下測試可用,其它瀏覽器未測試!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $(window).resize(function () {
                var width = $(this).width();
                var height = $(this).height();
                $("#div1").height(height - 30);
                $("#div1").width(width - 10);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="div1" style="filter: progid:dximagetransform.microsoft.alphaimageloader(src='Images/sms_logo.png', sizingmethod='scale');">
    </div>
    </form>
</body>
</html>


相關文章