I'm puzzled as to why the text-align center doesn't seem to be functioning correctly when combined with margin 0

Jsfiddle (expand the window) https://jsfiddle.net/aq9Laaew/5793/ The phrase hello world isn't centered below the image. By switching to a larger image https://i.sstatic.net/F79On.jpg, this problem can be avoided. What's the best way to resolve this issue?

 <div class="img-thumbnail blogborder">
<div class="row">
<div class="col-md-6">
    <div class=bodytitle>Title</div>
  <img class="rounded img-fluid img-thumbnail" src="https://i.imgur.com/6DcuZx6.jpg">
</div>
</div>
<div class="content">Hello World</div>
</div>

CSS

.col-md-6{
    margin: 0 auto;
    padding: 0;
}

    .content {
        text-align: center;
        font-family: 'Josefin Sans', sans-serif;
    }

Answer №1

Your content is center-aligned, but to ensure your col-md-6 items are also aligned properly, consider adjusting your HTML markup like this:

<div class="col-md-6 text-center">
      <div class=bodytitle>Title</div>
      <img class="rounded img-fluid img-thumbnail" 
       src="http://i.imgur.com/VjHAT.jpg">
    </div>

By adding text-center class to the div element, you can easily align its contents to the center. For more information, refer to the Bootstrap documentation here. Additionally, it's recommended to eliminate any style overrides on col-md-6 and use justify-content and align-items in line with Bootstrap grid system.

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

Having trouble with a static CSS file not loading correctly in the Django admin interface

Currently, I am attempting to replace the base.css file with my own custom CSS file in order to personalize the appearance of Django Admin. {% extends "admin/base.html" %} {% load static %} {% block title %}Custom Django Admin{% endblock %} {% block bran ...

On initial loading, Materialize JS seems to experience technical difficulties

Struggling to develop a Vue.js SPA chat application, encountering issues with Materialize CSS and JS. The JS doesn't function properly on initial load and requires a page reload to work. No errors are appearing in the console, making it challenging to ...

Effective methods to prevent the `translate` transform from triggering an element to be perceived as position relative?

I am encountering an issue with an absolutely positioned div that is nested within a statically-positioned parent container. I noticed that when I apply the transform: translateY(-50%) property to the container, the child element behaves as if it were bein ...

Placing a div in the corner of an image

Is there a way to position a meta-data div in the corner of every post image, even with different image sizes? For example: This is what I currently have in my loop: <div id="images"> <?php wp_get_attachment_image(); ?> </div> < ...

Guide to declaring variables using jQuery

Currently tackling a school project, I stumbled upon some online example solutions and managed to decipher most of the code. However, there is one line that has me puzzled. var $newTweet = $('<div class=tweet></div>'); My assumption ...

Desktop displays do not show images, only mobile devices

My website displays multiple retailer images as affiliate links. I am facing an issue where the images are not visible on desktop for some users, even though I can see them on my end. I have tried clearing cache, cookies, and using different browsers, but ...

What could be the reason for the lack of responsiveness in my input box?

http://jsfiddle.net/4ws3L6kn/1/ Can anyone help me figure out why this isn't responsive? What mistake did I make? <div id="DIV_1"> <div id="DIV_2"> <div id="DIV_3"> <button id="BUTTON_4"> ...

Tips on incorporating a repeating gradient instead of a linear gradient

I have the following code for a linear-gradient. Click here to view the code Is there a way to modify it to use a repeating gradient instead? The goal is to maintain the same image but with a repeating gradient effect. background-image: repeating-linear ...

The advice I received was to avoid using max-width and instead utilize min-width when styling with CSS

With @media screen and (max-width:700px) { Link to image 1 Whenever I use @media screen and (min-width: 700px) { it messes up. How can I adjust it for min-width without causing issues? Link to image 2 ...

Exploring the concept of overflow and minmax behavior in CSS grid

Summary: Example of overflow in nested grid layout on Codepen, and attempts to fix it using CSS grid-template-columns: repeat(16, minmax(0,1fr)); Within the element called container, there are two main elements - summary-wrapper and stats-wrapper The gri ...

Remove padding in Twitter Bootstrap table cells

One of my current projects requires making a button that fills the entire width and height of the TD element. I have attempted setting the normal .btn-warning with -Xpx!important, but it did not produce the desired result. Here is what I currently have: ...

Unforeseen Firefox Problem Arises with display: table CSS Property

The ultimate visual aim is to create a horizontal menu with links that can span multiple lines but are all vertically centered. In modern browsers, this effect can be achieved using CSS with the display: table property. Here is an example of how it can be ...

Tips for creating a dynamic menu with animated effects

Check out my fiddle here: http://jsfiddle.net/k3AHM/23/ $(document).scroll(function () { var y = $(this).scrollTop(); if (y > 110) { $('.menu-container').addClass( "fix-menu" ).animate('top', '-3px&a ...

Positioning elements within a Bootstrap column: Fixed versus Absolute positioning

Striving to maintain the absolute positioning of the right column as users scroll through the left column has proven to be a challenging task. Despite exploring various solutions from stackoverflow and google, none seem to effectively address this issue. ...

Converting a 'div' element into a dropdown menu with CSS and Jquery

I am facing a challenge where I have a collection of buttons enclosed in a div that I want to resemble a dropdown: <div id = "group"> <label> Group: </ label> <div value =" 1hour "> 1h < / div> <div value =" 2hou ...

`The background video is not being displayed on the transparent PNG`

I have created a transparent PNG image featuring a theater setup and I am attempting to overlay a 1-second video as a background element, similar to a GIF. However, when I try to display the video, instead of seeing it, the background color appears. Additi ...

Animating the menu's height using CSS when it is being displayed or hidden

Currently, I am in the process of developing a horizontal navigation bar with a collapsible menu. For this project, I am utilizing bootstrap 4 and angular. The collapsing and showing functionality is operating as expected when clicking on the menu icon. Ho ...

D3 Treemap for handling extensive sets of data

I am uncertain if there exists a method to incorporate the desired feature. I am seeking a solution similar to zoomable treemaps, but to initially load a limited number of child levels and then dynamically add more child nodes without requiring a node clic ...

What is the best way to set inner text using jQuery?

The code snippet below demonstrates a specific issue: <span id="test1">some text</span> <span id="test2">some text</span> Upon loading the content, the following JavaScript is executed: alert($('test1').text(); $(' ...

Safari has a unique feature where margins are not factored into the scroll width calculation

I am facing an issue with a container that scrolls horizontally. Inside this container, there are multiple items and I have added a margin to the last item on the right. However, in all browsers except for Safari, the margin is included in the scroll width ...