开发者

Variable width webpage displayed in a div

me and a friend are working on a html app for smartphone (part of an internship). Im trying to get a webpage to display in a seper开发者_C百科ate div. I can get this done easily enough with an iframe but the problem is the divs width can be expanded.

What would be the simplest way to get a webpage in a div that resizes to fit the dimensions of the div it is in?

My mate is doing all the javascript and is using jquery and I am focusing on the html and css work. I have very little experience with js.


You can use CSS or width and height attributes of an <iframe> to match its width with the div it is placed in. But whether the webpage resizes exactly to fit in the div so that you don't get horizontal scrollbars depend upon the webpage itself. It will fit if the div is big enough for the webpage or if the webpage has a fluid layout i.e. the width of its contents is defined in %.


Another way would be to send a server side request to another server, then use an XML phaser to get only the body content and then write that HTML to the div. Then you would have to adjust width with css and/or javascript. But I would advice to do with Iframe, because it's its nature ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜