Issues with divs not aligning properly

Having trouble centering the results of freeCodeCamp's Twitch.TV project? Even though you've tried using margin: auto and class='text-center', the section containing the results remains left-aligned. How can you ensure that the results are centered within the section?

HTML:

<html>

<head>
  <title>Twitch.tv Guide</title>
</head>

<body>
  <div class='container-fluid'>
    <div class='content'>
      <div class='row'>
        <div class='col-12 text-center'>
          <h1 class='text-center header'>Twitch.tv Guide</h1>
        </div>
      </div>
      <div class='row menu'>
        <div class='col-4 text-center'>
          <button class='btn all-btn'>All</button>
          <button class='btn online-btn'>Online</button>
          <button class='btn offline-btn'>Offline</button>
        </div>
      </div>
      <div class='row results text-center'>
      </div>
    </div>
  </div>
</body>

</html>

CSS:

html, body, .container-fluid {
  background: black;
  padding: 0;
  margin: 0;
  width: 100%;
}
body {
  padding: 5em;
}
.container-fluid div {
}
.header {
  width: 8.2em;
  padding: .25em;
  margin: 0 auto 1em auto;
  background: #643FA5;
  color: white;
  box-shadow: 0 0 5px 0 white;
}
img {
  width: 5em;
  height: 5em;
  border-radius: 50%;
  margin: auto;
  box-shadow: 0 0 5px 0 white;
}
.menu {
  margin: auto;
  padding: 0;
}
button {
  margin: .125em auto;
  width: 5em;
  background: #643FA5;
  color: white;
  box-shadow: 0 0 5px 0 white;
}
.online, .offline {
  margin: 1em auto;
  width: 18em;
  height: 15em;
  padding: .5em;
  box-shadow: 0 0 5px 0 white;
}
a, a:hover {
  text-decoration: none;
}

...

JS:

var channels = [
  "ESL_SC2",
  "OgamingSC2",
  "cretetion",
  "freecodecamp",
  ...
];
...

Answer №1

If you want to evenly distribute row items, consider adding the following snippet to your .row class:

justify-content: space-between; 

Alternatively, to center-align the entire row, use this code:

justify-content: center; 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adjusting font sizes for both multiline text within a <p> element and labels based on the number of lines

Whenever I have multiline paragraphs or labels, the font size seems to adjust depending on the number of lines. All I want is to keep the font size consistent regardless of the lines. The labels all have the same CSS styling and inheritance. Here is a vis ...

Is the menu item a little crooked?

Working on designing a menu, and I noticed that the 'Book Now' option is slightly misaligned (pushed down) after adding a border. This seems to disrupt the horizontal alignment. Is there a way to correct this issue? Check out my Codepen Here is ...

The div element is unable to activate the modal due to tabindex issues

Seeking Assistance with a Specific Scenario I have a specific layout where a div is enclosing an image. The desired functionality is that when the div is clicked with a mouse, a small tooltip modal should appear displaying address information. This can be ...

Using ASCII 3D text can create a stunning visual effect on a website, but it can sometimes appear

My website is displaying ASCII 3D Text with glitchy lines, but this issue is not present on other websites. Example 1: Glitchy lines visible on my website Example 2: A different website using the same text without any glitchy lines. No glitches detected h ...

Using $(document).ready() can sometimes cause issues with the functionality of the datatable

Currently, I am facing a challenge with initializing an empty table in the <tbody> section and sending parameters to the server using $.getJSON. The intention is to populate the table with the returned JSON data inside the <tbody>. It seems th ...

Can a hyperlink be generated by simply inputting the URL once?

As I add numerous links to my website, I can't help but feel like a novice using the <a href>. I want users to see the URL of each link immediately without needing to hover over it first. Right now, I am structuring my links like this: <a h ...

When Css is incorporated within a text, it prevents the use of " " from functioning properly

I am currently developing a GUI application using Qt 4.8. I have a label that displays text in white (the stylesheet has already been set up for this) and I want to change the color of the word "UPDATE" to red. Here is my initial code: //all text in whit ...

How to align text to the bottom of a div using CSS

I am struggling to position the text 'About' at the bottom of an image. The red line marks the spot where I want the text aligned at the bottom. However, every method I try results in inconsistent outcomes when viewed on desktop and mobile device ...

Listening for server updates with jQuery

I am currently working on a web application that communicates with a server for database updates. The issue I am facing is that the update process can vary greatly in time, ranging from milliseconds to tens of seconds for larger updates. I would like to im ...

Struggling with CSS issues in ASP.NET 4.6

For the past few months, I've been diligently working on a project that suddenly hit a snag today. Upon inspecting my website, I noticed that all my button sizes appear to be uniform. I typically use Chrome's developer tools to troubleshoot my we ...

Halt scrolling news feed when hovering over with the mouse

I'm currently working on a news ticker on this jsfiddle, but it's not functioning as I'd like. Here are the issues I'm facing: When I increase the width and height of all the divs, it doesn't work properly as the last divs over ...

Maintain the original order of rows in the table while shuffling the columns they appear in randomly

I need help with my table setup. The left column contains words in English, while the right column has the same words translated into Korean. Is there a way to keep the rows intact while randomizing the order of the columns? Here's an example: <ta ...

The dropdown feature in AngularJS experiencing sporadic malfunctions on Google Chrome

HTML: <select id="bId" ng-options="b as b.name for b in books" ng-model="selectedBook" ng-change='onBookChange()'> </select> The issue: The options are not always displaying and the selected option is not visible. List ...

Animating a CSS overlay

My goal is to design an overlay using the following HTML and CSS code snippets div.relative { position: relative; width: 400px; height: 200px; border: 3px solid #73AD21; } div.absolute { position: absolute; top: 50%; right: 0; width: 20 ...

What is the best way to show a left and right arrow on a mobile website page?

I'm experiencing a strange issue with my webpage, specifically a post in Wordpress. When I try to insert the left right arrow character (U+2194) either by copying from a character map or using the html code, I end up with an icon instead of the actual ...

Add-on Group for Form Inputs - Is a style element missing? (Bootstrap 4)

I am looking for a way to incorporate a Bootstrap4 input group label between two input fields. While there are "prepend" and "append" styles available, in this scenario, I require a "center" style which seems to be missing. Does anyone have a solution for ...

"Implementing JavaScript Validation for Textboxes: A Step-by-Step Guide

I need some help with restricting the input of a textbox within a gridview to only 'X' or 'O'. I am not very familiar with javascript, so any guidance on how to accomplish this would be greatly appreciated. It's worth noting that t ...

Unexpected output from nested loop implementation

Having some arrays, I am now trying to iterate through all tab names and exclude the values present in the exclusion list. json1 ={ "sku Brand": "abc", "strngth": "ALL", "area ...

Configure the input to accept integer values

This page that I have developed is designed for entering Latitude and Longitude values. <div class="container "> <form class="entry"> <div class="aligncenter"> <h5 style="color:MediumTurquoise; font ...

Jquery Autocomplete with Dynamic Text Updates

I am having an issue with the autocomplete feature on my website. Whenever I enter a search and select an option, the text in the box changes to the selected value instead of keeping what I originally entered. How can I prevent this from happening? <sc ...