Solved

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

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now