繁体   English   中英

如何使用CSS调整jQuery的load方法加载的内容的大小

[英]How to resize the content loaded by jQuery's load method using CSS

我正在使用load方法在我的网站中加载网页。

// main.js
$(document).ready(function ()
{
    $("#content").html("<object data='http://tired.com/'>");
});

// index.html
<html>

<head>

    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script src="scripts/main.js"></script>

    <style type="text/css">

#container{
    width: 100%;
    height: 100%;
}

#content{
    margin-top: 10;
    margin-left: 100;
    margin-bottom: 10;
    margin-right: 10;

    width: 500px;
    height: 500px;
}

    </style>

</head>

<title>
Testing loading a html page into a div
</title>

<body>

    <div id="container">

        <div id="top">
            <p> Top </p>
        </div>

        <div id="content">
        </div>

        <div id="bottom">
            <p> Bottom </p>
        </div>

    </div>

</body>

</html>

尽管为content div设置了500px的高度和宽度,但是网页仍以其原始大小加载。

如何放大?

谢谢。

它确实有效,请检查此小提琴。 JSFiddle演示链接

您可能还想将px添加到边距中。

#content{
    margin-top: 10px;
    margin-left: 100px;
    margin-bottom: 10px;
    margin-right: 10px;
    background:skyblue;
    width: 500px;
    height: 500px;
    padding:10px;
}

我建议尝试在对象标签本身上设置样式:

#content object {
    width: 500px;
    height: 500px;
}

暂无
暂无

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

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