Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-21
3
Medium Priority
?
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Accepted Solution

by:
apathy42 earned 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Suggested Courses

636 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