How can I align a responsive image within a fluid container and row using Bootstrap?

I appreciate the community's assistance, although I don't think the answers provided here will significantly impact computer science understanding in the 21st century.

My challenge lies in centering an image within a bootstrap framework. The image is placed inside a .container-fluid, a .row, and a .col-xs-6 with .offset-xs-3. The <img...> itself is styled with .img-responsive. You can view the project on this codepen: http://codepen.io/NotAnAmbiTurner/pen/GrGmaq?editors=1000.

Despite my efforts, I am unable to successfully center the image. I aim to have a scalable image that adjusts with the viewport width like SVG, positioned at the center of the page. Unfortunately, I haven't been able to achieve this as expected.

I suspect the issue could be related to using a "raw" image from Dropbox as my src, or because the image format is .jpg, or perhaps a combination of factors. Due to my limited experience in this area, it's possible that there might be a simple typo that I'm overlooking. I've reviewed the Bootstrap documentation and various Stack Overflow questions without finding a solution. One workaround involves removing the <img...> element from the container and row, then applying ... class="centered-block" .... However, I believe there should be a more straightforward approach, and I'm eager to understand and correct any conceptual errors for personal growth.

On a side note, I have also observed that my <a ...></a> tags do not appear to be clickable. Any insights on this matter would be greatly appreciated as well.

After some investigation, I discovered that CodePen operates on Bootstrap 4, contrary to my initial assumption of Bootstrap 3.

Answer №1

It seems like there is a compatibility issue with your classes from Bootstrap 3 and the stylesheet from Bootstrap 4. The img-responsive class no longer exists, along with the col-xs-* classes. Check out Images and Grid Options for more information.

Also, make sure to validate your HTML markup as it appears some links are invalid and there's an issue with closing h2 with an h3. You can use a tool like HTML Validator to help with this.

View a Working Example:

@media (max-width: 480px) {
  h1 {
    font-size: 5vmax;
  }
  h2 {
    font-size: 3.5vmax;
  }
  h3 {
    font-size: 2.5vmax;
  }
  li {
    font-size: 2.5vmax;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />

<div class="jumbotron">

  <h1 class="text-primary">Dr. Clair Cameron Patterson</h1>

  <h2 class="text-secondary">The man who first learned the age of the Earth, and helped save a civilization from the dangers of its use of lead.</h2>

  <div class="container-fluid">
    <div class="row">
      <div class="col">
        <img src="https://www.dropbox.com/s/91fw6aazyxzb178/image-for-codecamp-tribute-page.jpg?raw=1" alt="Cartoon Image of Clair Cameron Patterson at Congressional Hearing" class="img-fluid mx-auto d-block" style="padding:1.5vmin">
      </div>
    </div>
  </div>

  <h3>Academics</h3>
  <ul>
    <li>Undergraduate, Grinnell College</li>
    <li>PhD, University of Chicago</li>
    <li>Researcher, California Institute of Technology</li>
  </ul>
  
  <h3>Brief Timeline</h3>

  <ul>
    <li><strong>1956</strong>: found the earth to be 4.55 Billion years old using <a href="https://en.wikipedia.org/wiki/Lead%E2%80%93lead_dating">lead-lead dating</a> and
      <a href="https://en.wikipedia.org/wiki/Canyon_Diablo_(meteorite)">a fragment of a metorite that fell in Arizona</a>. This calculation has been largely undisturbed since.</li>
    <li><strong>1965</strong>: began campaign against lead in various products, especially gasoline, which at that time was emitting lead into the atmosphere.</li>
    <li><strong>1978</strong>: wrote a 78-page minority opinion as part of a National Research Council (NRC) panel stating that controls on lead in various products had to start immediately, including gasoline, food containers, paint, glazes, and water distribution
      systems.
    </li>
    <li>by the late <strong>1990s</strong>: levels of lead in Americans' blood has dropped by up to 80%. Though connections with Dr. Patterson's work are not clear, as the leading researcher in the area, and constant campaigner against the use of lead, it
      is likely he was a major antecedant of this change.</li>
  </ul>

</div>

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

Challenges with creating a contact form using bootstrap modal

I'm facing an issue with a bootstrap modal contact form. It works fine on all browsers except for iPad/Safari. Can anyone help me figure out what's wrong? On iPad, the modal is positioned to the right and down the page instead of in the cente ...

Control the Bootstrap carousel with a custom Javascript function for playing and pausing

Having an issue with the carousel class in Bootstrap. I have a button that defaults as a pause button, and then I use a JavaScript function on that button to control the carousel. When clicked, the icon should change to play and the carousel should stop cy ...

Issues with Bootstrap Collapse functionality on an HTML document

Trying my hand at crafting a FAQ dropdown menu using bootstrap collapse. I've set up the collapse like this: <div class="container textcontainer accordion" id="accordionExample"> <div class="card"> <div class="card ...

How can I customize an SVG using CSS when it's being accessed from another directory on my computer?

I find myself in a bit of a bind at the moment. Within my code lies an SVG depicting a map of the United States. Upon clicking on a specific state, the entire country fades away, revealing a separate SVG displaying only that state. Each of the 50 states is ...

The CSS transition is failing to revert to its original state after being combined with animations

My goal is to create a loading animation using CSS transitions and animations. I have managed to achieve the initial loading effect by scaling with transition and then animating it to scale out on the x-axis. However, when attempting to transition back to ...

What is the solution to preventing Prettier in VS Code from breaking up CSS Selectors onto different lines?

I am trying to achieve this code style: h1,h2,h3,h4,h5 { font-weight: 400 !important; } However, Prettier - Code Formatter is splitting each selector into separate lines like this: h1, h2, h3, h4, h5 { font-weight: 400 !important; } The issue of CSS ...

Issue with background image not covering entire div

I am experiencing an issue where the background image of a div element is not occupying the full image. I want to display images side by side with text underneath them. Below is the CSS code: .img-w { position: relative; background-size: cover; ba ...

Obtaining HTML data with ajax within a WordPress post

Greetings! I've been putting together a website and I'm eager to include a unique timeline in each of my posts. I'm utilizing WordPress for this project. However, since the timeline I want to insert will vary from post to post, I am unable t ...

Revamp Your Navbar Links with Bootstrap Color Customization

Even though this topic has been discussed extensively, I still haven't found a solution that works for me. My goal is simple - to change the color of the links in my bootstrap navbar to white. I know that the CSS is correctly applied because I can adj ...

Are Stacked DIVs with Variable Height Top DIV Compatible with CSS?

I am currently experimenting with stacking two boxes on my mobile web application view using HTML/CSS. I prefer not to utilize JavaScript or hardcode values in this basic design. Specifics: The top box must have a dynamic height, with contents that ar ...

Joomla website layout using Bootstrap columns set to MD-6 but not contained within a single

I seem to be experiencing an issue with Joomla SP page builder. After creating a row and adding 2 columns MD-6, they are not lining up properly in one row. Any assistance would be greatly appreciated. You can view the issue at: Here is a screenshot of t ...

Mobile Navigation Bar Reaches Beyond Its Limits

Having some trouble with the mobile view of a website I'm working on. The navbar width seems to be too wide, causing issues with the overall layout. Here's the link to the site - <body data-spy="scroll" data-target="#landingkit-navbar" data- ...

Connecting to a particular destination on an external site

Can I add a link on my website that directs users to a specific location on another website, similar to an anchor tag but without creating the anchor point myself? I have a feeling it might not be possible, but perhaps there is a clever workaround. ...

Utilize Bootstrap 4 classes on multiple td elements within a table

Is there a way to efficiently apply multiple Twitter Bootstrap 4.5 classes to various td tags without repetition or using jQuery? I am looking to streamline the code in order to reduce the amount of data within the HTML document. For example, if there are ...

Menu Options for Websites

Is there a way to create a menu that can be easily linked and displayed on multiple pages within a website? I want to design a menu and have it accessible on index.htm, page2.htm, page3.htm, .. pageN.htm as if it is present individually on each page. In ...

The CSS3 slideshow is displaying distorted and unfocused images

I have a CSS code that controls the timing of my slideshow with 3 images: .slideshow li:child(1) span { background-image: url(../../pic/bg1.jpg); } .slideshow li:child(2) span { background-image: url(../../pic/bg2.jpg); -webkit-animation-de ...

Tracking when jquery (bootstrap) has finished updating the page in Python Selenium using Ajax. Time to capture a screenshot!

I am facing an issue where my screenshot is being taken before jQuery has finished loading completely. While the page loads fine in IE, Edge and Firefox, sometimes the execution of jQuery is a bit slow which results in a transitional image. start_time = ti ...

Validating Email Input Using jQuery

I'm struggling to validate the value of an email input using this code. It's not working as expected and I could really use some assistance, please! HTML <input type="text" name="email" class="emailInput" /> <button class="validateEma ...

Adjust the appearance of primeng's PanelMenu component

I've been attempting to customize the appearance of the PanelMenu component So far, I've successfully changed the overall background color. https://i.sstatic.net/MGIia.png My goal is to set the main menu items to white and the submenus to blac ...

Is there a way to adjust the select2 multiselect field to span the entire page?

I am currently working on creating a stylish multiselect using Thymeleaf and Select2. The data is passed through Thymeleaf to create a multiselect with all the necessary data. However, I am encountering issues with Select2, as it only seems to work under c ...