The elements within the HTML, CSS, and Bootstrap are all clashing and

Website Output

https://i.sstatic.net/5JVyg.jpg

I've been working on a small website with a bootstrap carousel, and in this specific section of the program, the Bootstrap and HTML/CSS elements overlap by default. I'm not sure how to separate them. The code is attached below, and I've also provided a live output here on CodePen.

HTML Code

<div id="myCarousel" class="carousel slide" data-ride="carousel">
      <div class="slider">
        <div class="centering_the_slider_contents">
          <!-- Nut 1-->
          <div class="carousel-item active">
            <figure class="images_in_nuts">
              <img src="images/almonds.jpg" />
            </figure>
            <div class="nut_text">
              <h2>Almond</h2>
              <h3 class="rich_in">Rich In</h3>
              <p>
                Vitamin E, Monounsaturated fats, Fiber, Biotin, <br />Calcium,
                Phosphorus, Magnesium, Copper, <br />
                Phytonutrients, specifically flavonoids, plant sterols,<br />
                phenolic acids
              </p>
            </div>
          </div>
          <!-- Nut 1 Ends-->
          <!-- Nut 2-->
          <div class="carousel-item">
            <figure class="images_in_nuts">
              <img src="images/almonds.jpg" />
            </figure>
            <div class="nut_text">
              <h2>Almond 2</h2>
              <h3 class="rich_in"&§gt;Rich In§/h3§>
              §<p§>§
                §Vitamin E, Monounsaturated fats, Fiber, Biotin, <br />Calcium,
                Phosphorus, Magnesium, Copper, <br />
                Phytonutrients, specifically flavonoids, plant sterols,<br />
                phenolic acids
              </p>
            §&£€/div>
          &´Ø/div))&))}{0;         Ø}Ä*==Ö@ê ="><point size=""></point</pre>;

Cascading Style Sheets (CSS)

.centering_the_slider_contents {
  margin: auto;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  position: absolute;
}

.images_in_nuts {
  border-radius: 50%;
  width: 250px;
  height: 250px;
  display: inline-block;
}

.nut_text {
  display: inline-block;
  vertical-align: top;
  margin-top: 30px;
}

.last_contact_us {
  background: #ffffff !important;
  // margin-top: 300px;
}

.footer_contact_us  {
  margin-top: 10px;
  text-align: center;
  font-size: 25px;
  font-family: "Poppins";
  font-weight: bold;
}

.footer_contact_us_expl {
  text-align: center;
  font-family: "Poppins";
}

If a margin value of 300px is given then they get aligned. Is that the right way to do it? Is there a solution to align these contents one below another without giving a fixed margin? Please share if you have a solution for this issue. Thanks!

Answer №1

.centering_the_contents {
      margin: auto;
      width: 100%;
      text-align: center;
      margin-top: 10px auto;

     /* position: absolute;*/
    }

    .images_in_nuts {
      border-radius: 50%;
      width: 250px;
      height: 250px;
      display: inline-block;
    }

    .nut_info {
      display: inline-block;
      vertical-align: top;
      margin-top: 30px;
    }

    .last_contact {
      background: #ffffff !important;
      // margin-top: 300px;
    }

    .footer_section  {
      margin-top: 10px;
      text-align: center;
      font-size: 25px;
      font-family: "Poppins";
      font-weight: bold;
    }

    .contact_explanation {
      text-align: center;
      font-family: "Poppins";
    }
<link
          rel="stylesheet"
          href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
          integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
          crossorigin="anonymous"
        />

    <!-- Information about nuts - Carousel-->
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
          <div class="slider">
            <div class="centering_the_contents">
              <!-- Nut 1-->
              <div class="carousel-item active">
                <figure class="images_in_nuts">
                  <img src="images/almonds.jpg" />
                </figure>
                <div class="nut_info">
                  <h2>Almond</h2>
                  <h3 class="rich_in">Rich In</h3>
                  <p>
                    Vitamin E, Monounsaturated fats, Fiber, Biotin, <br />Calcium,
                    Phosphorus, Magnesium, Copper, <br />
                    Phytonutrients, specifically flavonoids, plant sterols,<br />
                    phenolic acids
                  </p>
                </div>
              </div>
              <!-- Nut 1 Ends-->
              <!-- Nut 2-->
              <div class="carousel-item">
                <figure class="images_in_nuts">
                  <img src="images/almonds.jpg" />
                </figure>
                <div class="nut_info">
                  <h2>Almond 2</h2>
                  <h3 class="rich_in">Rich In</h3>
                  <p>
                    Vitamin E, Monounsaturated fats, Fiber, Biotin, <br />Calcium,
                    Phosphorus, Magnesium, Copper, <br />
                    Phytonutrients, specifically flavonoids, plant sterols,<br />
                    phenolic acids
                  </p>
                </div>
              </div>
              <!-- Nut 2 Ends-->
              <!-- Nut 3-->
              <div class="carousel-item">
                <figure class="images_in_nuts">
                  <img src="images/almonds.jpg" />
                </figure>
                <div class="nut_info">
                  <h2>Almond 3</h2>
                  <h3 class="rich_in">Rich In</h3>
                  <p>
                    Vitamin E, Monounsaturated fats, Fiber,Biotin, <br />Calcium,
                    Phosphorus,Magnesium,Copper,<br />
                    Phytonutrients, specially flavonoids,plant sterols,<br />
                    phenolic acids
                  </p>
                </div>
              </div>
              <!-- Nut 3 Ends-->
            </div>
          </div>
          <script
          src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
          integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
          crossorigin="anonymous"
        ></script>
        <script
          src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
          integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
          crossorigin="anonymous"
        ></script>
        <script
          src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
          integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
          crossorigin="anonymous"
        ></script>
        </div>
      </div>
    </div>
    </div>
        
        <!-- All Details on nuts conclude here - Carousel Complete-->
      
        <div class="last_contact" id="last_contact">
          <p class="footer_section">Get in Touch</p>
          <p class="contact_explanation">
            Reach out for the best quality Nuts and Spices <br />
            at competitive prices.
          </p>
        </div>
    <script
          src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
          integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
          crossorigin="anonymous"
        ></script>
        <script
          src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
          integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
          crossorigin="anonymous"
        ></script>
        <script
          src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
          integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
          crossorigin="anonymous"
        ></script>

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

Tips for effectively utilizing the display: inline property in conjunction with ng-repeat

I am struggling to create a timeline with a broken structure on my website. I suspect that the issue lies in using display:inline. When attempting to apply this to my site: https://i.stack.imgur.com/4Ur7k.png the layout gets distorted: https://i.stack.i ...

Separating Vue.js 2 - taking out the HTML snippet from a single file component and placing it in its own

I was pondering if there is a method to divide a Single File Components file into smaller segments. What do I mean by this? Let's take a look: <template> ... </template> <script> export default { name: 'my-component&a ...

Using html tags in JTextArea in Java is a simple process that involves setting

Is there a way to change the color of text in a JTextArea similar to how it can be done for JLabel or JButton? When I attempt to change the color using: textArea.setText("<html><font color=\"red\">Hi</font></html>"); The ...

Bootstrap relies on jQuery for its JavaScript functionality, so jQuery must be loaded before using Bootstrap's JavaScript

I encountered an issue while trying to load the Bootstrap library, consistently receiving this error message: Uncaught Error: Bootstrap's JavaScript requires jQuery Even though I have ensured that jQuery is loaded before attaching the Bootstrap li ...

Chrome compatibility problem with scroll spy feature in Bootstrap 3

Having trouble with scroll spy for boosters using the body method " data-spy="scroll". It seems to be working for some browsers like Edge and Google Chrome, but after multiple attempts, it still doesn't work for me. Even after asking friends to test i ...

A method designed to accept an acronym as an argument and output the corresponding full name text

Having trouble with my current task - I've got an HTML file and external JS file, and I need a function that takes an element from the 'cities' array as input and returns a string to be used in populating a table. I've set up a functio ...

Failure to receive results from $.getJSON request

I am currently working on developing a web page that allows users to search and retrieve Wikipedia pages based on their search results. Below is the relevant HTML code for the search feature: <form class='search-form' onsubmit='return f ...

React state update not triggering a component re-render

I've been attempting to toggle the visibility of a div by clicking on another div, but I'm encountering an issue. The div becomes invisible on the first click only if it was visible initially. After that, it remains invisible and does not update. ...

What is the best way to save newly added elements on a webpage that were submitted by the

I am looking for a way to save the changes made by users on my webpage so that they can navigate to different pages and come back without losing any added elements. These changes should be retained even when the user goes back to edit the webpage, but I pr ...

Concealing the Footer on Mobile Websites in Muse UI When the Keyboard Appears

In this project, I am using vue.js along with muse.ui and only incorporating JavaScript and CSS without the jQuery library. Currently, the footer position always ends up on top of the keyboard whenever an input field is focused. Is there a way to ensure th ...

Setting the initial height of a textarea dynamically by binding it to the content with knockout data-binding

I need help with a JavaScript solution for expanding and collapsing the height of a text area on keyup event, while also initializing its height when a value is bound to it via a knockout custom binding. Any ideas on how to achieve this without using jQuer ...

What is causing my css elements to appear larger compared to other instances?

As someone who is not a designer, I find myself doing a lot of cutting and pasting for my side hustles. I believe many others can relate to this experience. Currently, I am working on a personal project that involves using tailwindcss, appwrite, and svelte ...

The CDN version of Font Awesome is not displaying the necessary icon

Struggling to incorporate Awesome icons into my Laravel/Vue project, the icon refuses to display correctly no matter what I try. As a last resort, I attempted the most basic approach with Awesome: a straightforward HTML page using a CDN. Here is the code: ...

Tracking Time Spent in a Tab using HTML and JavaScript

I have a unique issue that requires a specific solution. Despite my extensive search across the internet, no useful answers were found. This is the snippet of HTML code in question: <form action="/timer.php" method="POST"> <span>Fir ...

"Why does adding a new span create space between it and the previous ones, and what can be done to prevent this from

Essentially, it creates the equation "a + b = c". However, I need to create "a + b = c" instead. HTML: <div class="container"> <span id="b__value">+b</span> <span id="c__value">=c</span> &l ...

Move your cursor over a div element while utilizing NgClass

I'm currently working on implementing a hover effect on a div using an Angular ngClass directive. Within the template file, I have a div element with the class "list-item-container" that includes another div with the class "list-item." This "list-item ...

simultaneous image hover effect for all images

I am experiencing an issue with my CSS and Bootstrap hover effect. The overlay tags are enclosed within a div class, but they all hover simultaneously. Each overlay belongs to a different Bootstrap grid, yet the effect extends even to the empty spaces betw ...

Safari browser experiencing issues with JQuery Slider functionality

I am facing an issue with a slider that works perfectly in all browsers except Safari. I have been struggling to figure out the root cause of this problem. You can view the fiddler code here: http://jsfiddle.net/sjramsay/UyvvL/ It appears that when the co ...

The hover effect is failing to impact a child element during a transition

I created a link with an arrow next to it that should move 20px to the right when hovered over, using a transition of 1s. However, for some reason the transition is not affecting the arrow. Can anyone please assist me in figuring out why this is happenin ...

Ensure that the method is passed a negative number -1 instead of the literal number 1 from an HTML error

This is an example of my HTML code: <button (mousedown)="onMouseDown($event, -1)"></button> Here is the TypeScript code for handling the mouse down event: onMouseDown(e: MouseEvent, direction: 1|-1) { this.compute.emit(direction); ...