Solved

is there a way to make the image the same width as the div

Posted on 2013-05-21
3
325 Views
Last Modified: 2013-05-23
<style>
    div.col1{width:10%;border-width:1px;border-color:'.$row_color.';border-style:solid;float:left;}
    div.col2{width:50%;border-width:1px;border-color:'.$row_color.';border-style:solid;float:left;}
    div.col3{width:40%;border-width:1px;border-color:'.$row_color.';border-style:solid;float:left;}
</style>

images appear in the div larger than the div width

is there a way to make the image the same width as the div

<img src="pic.jpg" width="40%">
0
Comment
Question by:rgb192
3 Comments
 
LVL 11

Accepted Solution

by:
apathy42 earned 250 total points
ID: 39186321
Check out this thread, I think it has some helpful options:

http://stackoverflow.com/questions/3029422/image-auto-resize-to-fit-div-container
0
 
LVL 10

Assisted Solution

by:Ishaan Rawat
Ishaan Rawat earned 250 total points
ID: 39186498
Add the following style...

.fitParent{
width: 100% !important;
height: auto;
}

Open in new window


and then wrap it with the div which you want the image to resize with ...

For eg...

<div class="col1">
   <img class="fitParent" src="imagePath.imgFormat" alt="">
</div>

Open in new window


What it will do is it will make the image width equal to the width of the parent tag that is div.col1....

Try this and if any problem is there comment below....
0
 

Author Closing Comment

by:rgb192
ID: 39191672
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question