how to center a bootstrap row


I am trying to center this temperature convertor and I am not able to do so. everything in the column seems solid but the row is not. I have attached a picture below.

enter image description here

Here is my code.

<!DOCTYPE html>
<html lang="en">

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Temperature convertor</title>

  <link href="" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

    .content {
      padding-top: 30px;
      background-color: #eeeeee;
    body {
      background: linear-gradient(to left, black, purple);



  <div class="container">
    <div class="row row-sm-offset-5">
      <div class="col-sm-3 text-center content">

          Temperature convertor

        <form action="">
          <div class="form-group">
            <label for="userInput"> Enter the temperature:  </label>
            <input type="number" id="userInput">


          <div class="form-group" style="margin-top: 10px;">

            <input type="button" value="To Celsius" onclick="toCelsius()">
            <input type="button" value="To Fahrenheit" onclick="toFahrenheit()">

        <p id="result"> </p>


  <!-- javascript file placed right before closing tag to reduce log times caused by script -->
  <script src="alert.js"></script>


Please let me know what I’m doing wrong.


Hopefully you do not need to center the Row. You can center the Col within the Row by using mx-auto. That will create auto margins to the left and right and everything will be centered perfectly.

<div class="row">
   <div class="col-sm-3 content mx-auto">
       <!-- Your form -->

Answered By – Cute Code Rob

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.