Problem with Bootstrap 4 and image centering

Hello, I have decided to build a website with Bootstrap 4, just to test it out.

I am having trouble with as simple a task as centering an image, though.

This is the full code:

<!doctype html>
<html class="no-js" lang="it">

<head>
    <title>Prova</title>

    <!-- BOOTSTRAP 4 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <script src="js/vendor/modernizr-3.5.0.min.js"></script>
    <script src="js/vendor/jquery-3.2.1.min.js"></script>
    <script src="js/vendor/popper.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>

</head>

<body>

        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <div class="text-center logo">
                        <img class="img-fluid" src="img/logo/logo800.png">
                    </div>
                </div>
            </div>
        </div>

</body>

</html>

Open in new window


And this is the test page on my server:
http://test.ilgufoblu.net/ferrari/prova.html

I haven't been able to find a single reason why this image shouldn't be centered, with the text-center class assigned to its containing div.

Can somebody help me understand this?
Daniele BrunengoIT Consultant, Web DesignerAsked:
Who is Participating?
 
Chris StanyonCommented:
In your HTML you have added the col-xs-12 class to your column div:

<div class="col-xs-12">

This has been dropped in Bootstrap 4. You need to use col-12 instead:

<div class="col-12">
0
 
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
Thanks! But has the xs label been dropped altogether, or just for a 12 column row, where it actually is no use?
0
 
Chris StanyonCommented:
Yeah - the xs has been dropped. Basically, Bootstrap is designed to be mobile first, so effectively, the xs size is the defualt, so there's no need to specify it. You only need to specify the breakpoints for larger sizes, so for columns, you have:

// single column on XS devices / 2 columns on SM
<div class="col col-sm-6">content</div>
<div class="col col-sm-6">content</div>

// 2 columns on XS / 3 columns on SM
<div class="col-6 col-sm-4">content</div>
<div class="col-6 col-sm-4">content</div>
<div class="col-6 col-sm-4">content</div>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Chris StanyonCommented:
sorry - above code should be col-12, not col for the single col:

<div class="col-12 col-sm-6">content</div>
<div class="col-12 col-sm-6">content</div>
0
 
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
Thanks again.
0
 
lenamtlCommented:
To center an image you will need Bootstrap helper
https://v4-alpha.getbootstrap.com/content/images/#aligning-images

To center an image here is the code
<img src="..." class="mx-auto d-block" alt="...">

Open in new window

or
<div class="text-center">
  <img src="..." alt="...">
</div>

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.