简体   繁体   English

如何根据其嵌套框调整图像大小

[英]how can I shape the image size according to its nested box

there is a web site called: SPAM I am trying to make the same home page of this web site using js, jquery and some css. 有一个名为: SPAM网站。我正在尝试使用js,jquery和一些CSS制作该网站的同一主页。

Now, the question is how to fix the image size according to the box in the center. 现在,问题是如何根据中间的框确定图像尺寸。 How can I create best user experience as if SPAM has. 如何像SPAM一样创造最佳的用户体验。

You may experience by viewing the web site of SPAM in different resolution or small and big windows size of explorer. 您可以通过以不同分辨率或大小不同的SPAM查看SPAM网站来体验。

How can I do it? 我该怎么做? Answers and code help or suggestions for the best user experience for SPAM ? 答案和代码帮助或建议,以获得最佳SPAM用户体验?

This is flash... but you can do the same with some jQuery: 这是Flash ...但是您可以使用一些jQuery进行相同操作:

html: 的HTML:

<div id="container"></div>

css: CSS:

#container {
    min-width: 500px;
    width: 100%;
    height: 100%;
    position: relative
    background: url('path') 0 0 no-repeat;
}

jQuery: jQuery的:

$(window).bind("resize", function() {
    var $winwidth = $(window).width(); //specify some padding here
    $("#container").attr({
        width: $winwidth
    });
});

To start, make the <did id='main'> to take the width of the screen 首先,使<did id='main'>成为屏幕的宽度

#main { width:100% }

then, the image(s) inside should have a similar styling: 然后,内部的图像应具有类似的样式:

#main img { width:100% }

please note that the image height is not set, to make it automatically scale with the right proportions. 请注意,未设置图像高度,以使其以正确的比例自动缩放。

This should help to obtain an effect similar to the mentioned site. 这应该有助于获得类似于所述站点的效果。

You can use 您可以使用

margin: 0 auto;

on the inner element so it is horizontally aligned. 在内部元素上,使其水平对齐。

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

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