max-width on

后端 未结 7 1354
轻奢々
轻奢々 2021-02-13 18:57

I have a strange problem. On a site that were currently building we have a gallery function throuh the jQuery plugin, Gallerific. The gallery opens in a modal window. What I nee

7条回答
  •  长发绾君心
    2021-02-13 19:28

    IE8 requires that a container be placed around the image, with it's width either set to the max width you are looking for, or to 100% width (seems to work better on absolutely positioned divs). IE8 seems to be happy as long as a width is defined on that container.

    For your example you can set the container div to the maximum width you're looking for, while setting the max-width property of all images to 100%:

    .container { width: 765px;}
    img { max-width: 100%;}
    

    which forces the images to be no more than the width of the container in which they are found.

    Make sure you declare an HTML5 doctype; IE doesn't like XHTML doctypes.

    Kind regards, Larry

提交回复
热议问题