문제

I have set up 2 div tags, the outer one with display:table and the inner one with display:table-cell. Inside these I have an image.

When I resize the box using jQuery UI's resizable() API, I am unable to shrink it smaller than the image.

Markup:

<div class="resizebox">
    <div class="content">
        <img src="http://placehold.it/300x60">
    </div>
</div>

CSS:

.resizebox {
    border:1px solid black;
    height:100px;
    width:320px;
    overflow:hidden;
    display:table;
}
.resizebox .content {
    display:table-cell;
    vertical-align: middle;
    text-align: center;
}

jsFiddle

I've added another example under the top resizable box to demonstrate the kind of behavior I'm trying to achieve (while keeping the CSS Table)

도움이 되었습니까?

해결책

You beat me to it. Just using regular 'ol width: 100%;

img {
  width:100%;
}

Fiddle Example

다른 팁

Try adding the following css

.resizebox .content img {
   width:100%;
   max-width:100%;
 }

JsFiddle

Feeling a big silly now.

Fixed this by adding these CSS Styles:

.resizebox img {
    max-width:100%;
    max-height:100%;
}

jsFiddle

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top