0

I have a page that is displaying content using bootstrap and I've gotten most of it about where I want it, except that my images, even though centered vertically, are not centered horizontally.

I'm trying to make it so that if someone adds a small image or a huge image, that it is always contained in the column/row and is responsive to that container, but I also want to make sure that if the image is smaller than the container that it sits perfectly in the middle of that container.

What am I missing here to make sure that an image is centered and middle aligned unless specified otherwise?

    html,
    body {
      height: 100vh;
      width: 100vw;
      overflow: hidden;
    }

    iframe{
      height:100% !important;
      width:100% !important;
    }

    .middle p{
      max-height:100%;
    }

    img {
      max-width: 100%; 
      height:auto;
      margin:0 auto;
    }
    .my-container {
      display: flex;
      flex-direction: column;
      justify-content: center;
      height: 100vh;
      width:100vw;
    }

    .my-container>.top [class^="col-"],
    .my-container>.bottom [class^="col-"] {
      background-color: #778899  ;
      color: white;
      text-align: center;
    }

    .my-container>.middle {
      flex-grow: 1;
      padding:30px;
      /*background-image: url('images/bg_green.svg');*/
      background-size: cover;
    }

<div class="row middle" id="middle" style="background-image: url();">
    <div class="col-lg-12" id="fullColumn">
        <div class="fullContent" id="fullContent" style="height: 100%; ">
        </div>
    </div>
</div>

Update:

Here's an image of the current situation (image is too high, though vertically centered) and the output I'm trying to achieve (no matter image size it is centered both vertically and horizontally) enter image description here

UPDATE:

Multiple DIVS

.topLeftContent{
      display:flex;
      justify-content:center;
      align-items:center;
    }
    .bottomLeftContent{
      display:flex;
      justify-content:center;
      align-items:center;
    }
    .rightQtrContent{
      display:flex;
      justify-content:center;
      align-items:center;
    }
    <div class="col-lg-6" id="rightColumnQtrHalf" >
        <div id="rightQtrContent" style=" height: 100%; ">
        </div>
    </div>
Geoff_S
  • 4,917
  • 7
  • 43
  • 133

3 Answers3

1

have you tried display: block for image

if you can give a drawing of the layout you are looking to archive it helps

Buddhi
  • 2,224
  • 5
  • 32
  • 43
1

Please check below link. This might help you. I have added flex property to the parent div. thanks

https://jsfiddle.net/fzod273t/15/enter

Xenio Gracias
  • 2,728
  • 1
  • 9
  • 16
0

You can make the image at center by add class col-lg-3 instead of col-lg-12 and give the div tag style is margin:0px auto to make it at center

<div class="col-lg-3" id="fullColumn" style="margin: 0px auto;">
    <div class="fullContent" id="fullContent" style="height: 100%; ">

    </div>
</div>