0

http://www.kuwaitjournals.org/test

我怎样才能<div>用顶部的图像来固定主图像的宽度,或者使顶部图像的宽度像主图像一样动态<div>

4

1 回答 1

1

我不确定你想要完成什么,但我想说你只需要使用百分比作为宽度。像这样的HTML:

<html>
    <head>
    </head>
    <body>
        <div id="wrapper">
            <img src="foo/bar.jpg" />
            <div id="content">
            </div>
        </div>
    </body>
</html>

这对于 CSS:

*, html, body {
    margin: 0px;
    padding: 0px;
}

#wrapper {
    width: 900px;
    margin: 0px auto;
}

img {
    width: 100%; //Sets the image width to 900px
}

#content {
    width: 100%; //Sets the content divs width to 900px
}

这是我认为的问题的答案。如果不是,请告诉我。

于 2013-04-25T07:33:36.760 回答