Centering a Div within Div (I can't get My Div to Center)

I can not get my div centered within a div. I’ve tried everything and I just can’t get it to work. The outer div is the “container” div, and the interior div is within another div entitled or classed as “background image”.

<!--Intro-->
<div class="container">

<!--Portfolio-->
<div class="background-image">
<div class="picture-row">
      <div class="col-xs-4">
        <img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/freecodecamp/original/3X/5/0/50c0147bbe0ad7038df7d3d80e836cc95a8918bc.jpg' class="img-responsive" width="75%" />
      </div>
      <div class="col-xs-4">
        <img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/freecodecamp/original/3X/5/0/50c0147bbe0ad7038df7d3d80e836cc95a8918bc.jpg' class="img-responsive" width="75%"/>
      </div>
      <div class="col-xs-4">
        <img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/freecodecamp/original/3X/5/0/50c0147bbe0ad7038df7d3d80e836cc95a8918bc.jpg' class="img-responsive" width="75%" />
      </div>

The weird thing is that the background image is centered within the “container” div, but the images within the “picture-row” div won’t center within the “container” div, as how the “background image” div does…

Here’s the CSS code for how I attempted to center the “picture-row” div:

.picture-row {
margin-left: auto;
margin-right: auto;
}

And here is the link to my code pen: https://codepen.io/IDCoder/pen/OWbXLw?editors=1100

Try adding the center-block class to your images.

Would I put that in the CSS?

No. That class is part of Bootstrap :wink:

Haha never seen that term before! And what I’m trying to do is center that row of “Coming Soon” images between the border lines of the container…“center-block” will do that?

If I understood it correctly, what you want is to center the images in their respective divs/columns. Am I correct?

The “coming soon” image boxes are already centered within it’s own div, but it’s not centered within the main “container” div…for example, on the left side of the “coming soon” boxes, there is less of a space than there is on the right side of the “coming soon” boxes…that’s what I want to fix…

Try using CSS
.classB{
position: relative;
margin: 0 auto ;
}
html:

Actually, they weren’t.

I forked your pen and added red outlines to your columns.

I think the real problem is that the images are not centered. Giving them the center-block class should center them.

Hey! I FIXED IT! YAY! I had to add align=“center” to the “container” div! OMG! That was so easy!