Solved

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

Posted on 2013-05-21
3
326 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

809 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