How to make images within a container div scale with the div in a fluid layout

Hello,

I have a fluid page with 3 column divs, they are fluid (30%) of page width which is also fluid with a minimum size of 1024px.

I'm just trying, and failing miserably, to get the images to scale with the divs both up and down as the window is resized. The images are 700px wide so I want to make that themaximum the columns can scale too also if possible so the overall page never exceeds about 2140px or so.

I am using this withing a POD (PODS CMS) in wordpress. So the images are each callled through a PODS template which is below. IT won't let me apply the style directly onto the image so I am trying to add it as a wrapper div, I think this may be my problem here??


Can anyone suggest the best method for this please?

Cheers :)


This is what I have so far (the divs scale well with the their text content, the images are just full size and cut off):


/* CONTAINER DIV */

#profileBoxes{width:100%;min-width:1020px;margin:70px auto;height:auto;overflow: hidden;}



/* COLUMNS */

#profileLeft{width:31%;max-width:700px;height:auto;float:left;overflow:hidden;}

#profileMiddle{width:31%;max-width:700px;height:auto;float:left;margin-left:3%;display:inline;overflow:hidden;}

#profileRight{width:31%;max-width:700px;height:auto;float:left;margin-left:3%;display:inline;overflow:hidden;}


/* IMAGE CLASS*/

.profileImg {float:left;height:auto;max-width:100%;position: relative;overflow:hidden;}



/*PODS TEMPLATE */

<div class="profileImg" ">
<?php
foreach ($this->get_field('image') as $image) {
  echo "<img src=\"{$image['guid']}\" />";
}
?>
</div>
<div class="profileText">{@text}</div>
igloobobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle HamiltonData ScientistCommented:
The max-width has to applied to the image. You can do this:

.profileImg img{
max-width:100%:
}

This will target images inside the prifileImg div.

However, what do you mean it won't allow you to access the image?

What you should really do is get rid of the wrapper div and add a class to the image that is being generated from the template. Then apply the max-width to that class.
0
igloobobAuthor Commented:
D'oh of course! Thanks kozaiwaniec, sometimes I just get too close to something and miss the obvious!

It is in the code for the PODS template I cannot apply a class to the image code as I would normally as it causes errors. I would imagine I could do this but it doesn't work (unless there's another way to do it in this template code?):


<?php
foreach ($this->get_field('image') as $image) {
  echo "<img class="profileImg" src=\"{$image['guid']}\" />";
}
?>

<div class="profileText">{@text}</div>


So I have kept it like this:

<div class="profileImg" ">
<?php
foreach ($this->get_field('image') as $image) {
  echo "<img src=\"{$image['guid']}\" />";
}
?>
</div>
<div class="profileText">{@text}</div>

and added

.profileImg img{
max-width:100%:
}


as you pointed out.

Thanks!!
0
Kyle HamiltonData ScientistCommented:
you're using the wrong type of quotes.

<?php
foreach ($this->get_field('image') as $image) {
  echo "<img class='profileImg' src=\"{$image['guid']}\" />";
}
?>

Open in new window


or the other way is to escape the quotes:

<?php
foreach ($this->get_field('image') as $image) {
  echo "<img class=\"profileImg\" src=\"{$image['guid']}\" />";
}
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

igloobobAuthor Commented:
Brilliant thanks!!
0
Jason C. LevineNo oneCommented:
@kozaiwaniec Nicely done.  Good work...
0
Kyle HamiltonData ScientistCommented:
Thanks guys.. :)))
0
Kyle HamiltonData ScientistCommented:
/*PODS TEMPLATE */

<!-- <div class="profileImg" "> -->
<?php
foreach ($this->get_field('image') as $image) {
  echo "<img class="profileImg" src=\"{$image['guid']}\" />";
}
?>
<!-- </div> -->
<div class="profileText">{@text}</div>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.