Reputation: 386
I have an image in a DIV at the top, as a header. There is another DIV with text to the right side of it. When I resize my Google Chrome browser to a certain size, the image breaks out of the div and goes into the text DIV. I want to know how I can force the image to stay the same size as the DIV when it wants to break out and not mix with other elements.
Upvotes: 0
Views: 5124
Reputation: 419
You can set a width of 100% for the image to make it fit the div:
div {
width: 40% /* or whatever */
}
img {
width: 100%;
height: auto;
max-width: 100%;
}
Upvotes: 1
Reputation: 154
I think I understand your question enough, although it would help to see some code. Here is something that works for me though.
img.resize {
width:100px;
height: auto;
}
Upvotes: 0