The alignment of the elements within the jumbotron is off

Hey there! I'm currently struggling to align the jumbotron with my calendar icon. Unfortunately, the elements of the jumbotron are not lining up properly. Could someone lend a hand in guiding me through this issue? Any ideas would be greatly appreciated! I am fairly new to studying bootstrap and CSS.

Here's a snapshot for reference:

https://i.sstatic.net/Inz3W.png

Below is the snippet of my HTML code:

 <div class="events">
   <div class="container">
     <div class="row">
       <div class= "col-sm-4 col-xs-25">
         <h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
         <hr class="carved">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
         <div class="container">
           <div class="jumbotron">
             <h4>Sample Title</h4>
             <p>IT Thesis defense</p>
             <h6>7:00 AM - 8:00 PM</h6>
           </div>
         </div>
         <hr class="divider">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
         <hr class="divider">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
       </div>
       <div class= "col-sm-8 col-xs-25">
         <h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
         <hr class="carved">
       </div>
     </div>
   </div>
 </div>

And here is my custom CSS code:

#event {
  color: #a92419;
}
hr.carved {
  clear: both;
  float: none;
  width: 100%;
  height: 2px;
  border: none;
  background: #ddd;
  background-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      color-stop(0.5, rgb(126,27,18)),
      color-stop(0.5, rgb(211,45,31))
  );
  background-image: -moz-linear-gradient(
      center top,
      rgb(126,27,18) 50%,
      rgb(211,45,31) 50%
  );
}
.date {
  display: block;
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  background: #fff;
  text-align: center;
  font-family: 'Helvetica', sans-serif;
  position: relative;
}
.date .month {
  background: #a92419;
  display: block;
  padding-bottom: 5px;
  padding-top: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  border-bottom: 2px solid #a92419;
  box-shadow: inset 0 -1px 0 0 #a92419;
}

.date .day {
  display: block;
  margin: 0;
  padding-bottom: 10px;
  padding-top: 5px;
  text-align: center;
  font-size: 20px;
  color:#a92419;
  box-shadow: 0 0 3px #ccc;
  position: relative;
}

.date .day::after {
  content: '';
  display: block;
  height: 95%;
  width: 96%;
  position: absolute;
  top: 3px;
  left: 2%;
  z-index: -1;
  box-shadow: 0 0 3px #ccc;
}

.date .day::before {
  content: '';
  display: block;
  height: 90%;
  width: 90%;
  position: absolute;
  top: 6px;
  left: 5%;
  z-index: -1;
}
.jumbotron {
  width: 300px;
  height: 100px;
  margin:none;
}
.jumbotron p {
  font-size:12px;
}

Answer №1

The .container class comes with predefined width settings and is designed to serve as an outer container for your layout. As a result, it may not nest well with other elements, such as the .date class in your case, which is causing layout issues.

Regarding the spacing of the contents within the .jumbotron class, Bootstrap applies significant padding by default. You may want to customize this padding in your own .jumbotron rule. Additionally, the problem of the contents overflowing the boundaries of the .jumbotron is caused by the height: 100px you have set. To contain the contents within the .jumbotron, consider adjusting the overflow property. It is generally recommended to avoid setting a fixed height in CSS and let the content determine the container size, especially in cases where the content is dynamically generated.

If you remove the .container, you will still face the issue of the .date and .jumbotron elements stacking vertically. To address this, you can treat the Date element as a .row with separate columns for the .date element and the respective event(s).

<hr class="carved">

<div class=“row”><!-- Date wrapper -->

  <div class="col-sm-4">

    <div class="date">
      <span class="month">August</span>
      <h1 class="day">28</h1>
    </div>

  </div>

  <div class="col-sm-8"><!-- Events column -->

    <div class="jumbotron">
        <h4>Sample Title</h4>
        <p>IT Thesis defense</p>
        <h6>7:00 AM - 8:00 PM</h6>
    </div>

  </div>

</div>

Note: The new structure may require adjustments to your CSS width properties, and the col- sizes specified for the Date and Event columns are just examples — modify as needed.

Answer №2

<div class="container">
    <div class="row">
         <div class="col-md-2">
         <h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
         <hr class="carved">
        <div class="date">
        <span class="month">August</span>
        <h1 class="day">28</h1>
    </div><!-- date -->
</div><!-- md2 --> 

<div class="col-md-10">
<h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
<hr class="carved">
    <div class="jumbotron">
    <h4>Sample Title</h4>
    <p>IT Thesis defense</p>
    <h6>7:00 AM - 8:00 PM</h6>
    </div><!-- jumbo -->
</div><!-- md10 -->

</div><!-row>
</div><!-- container -->

+

#event {
  color: #a92419;
}
hr.carved {
  clear: both;
  float: none;
  width: 100%;
  height: 2px;
  border: none;
  background: #ddd;
  background-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      color-stop(0.5, rgb(126,27,18)),
      color-stop(0.5, rgb(211,45,31))
  );
  background-image: -moz-linear-gradient(
      center top,
      rgb(126,27,18) 50%,
      rgb(211,45,31) 50%
  );
}
.date {
  display: block;
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  background: #fff;
  text-align: center;
  font-family: 'Helvetica', sans-serif;
  position: relative;
}
.date .month {
  background: #a92419;
  display: block;
  padding-bottom: 5px;
  padding-top: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  border-bottom: 2px solid #a92419;
  box-shadow: inset 0 -1px 0 0 #a92419;
}

.date .day {
  display: block;
  margin: 0;
  padding-bottom: 10px;
  padding-top: 5px;
  text-align: center;
  font-size: 20px;
  color:#a92419;
  box-shadow: 0 0 3px #ccc;
  position: relative;
}

.date .day::after {
  content: '';
  display: block;
  height: 95%;
  width: 96%;
  position: absolute;
  top: 3px;
  left: 2%;
  z-index: -1;
  box-shadow: 0 0 3px #ccc;
}

.date .day::before {
  content: '';
  display: block;
  height: 90%;
  width: 90%;
  position: absolute;
  top: 6px;
  left: 5%;
  z-index: -1;
}

Click here for the displayed result

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 implementing CSS transitions

I've been delving into CSS3 transitions, and I'm encountering some confusion. I can't tell if I'm misunderstanding something or if it's the browsers causing issues. Initially, I believed Opera had transition support starting from ...

Using a URL in the fill property is a simple process that involves specifying

Here is the snippet of the code I'm working with: <?xml version="1.0" standalone="no"?> <html> <head> <style> .someClass { fill:"url(#Pattern)"; } </style> ...

What is the best way to showcase the outcome using the <table> tag in HTML with columns containing 50 records each, except for the final column?

I have developed a program that is currently creating 540 different numbers. My goal is to present these 540 distinct numbers in columns with 50 records each (except for the last column where there may be fewer than 50 records) using the HTML <table> ...

Showcasing a JavaScript array retrieved through JSON on a web page

Apologies if I am causing any inconvenience again =x Thanks to the assistance from everyone, especially Scott Harwell, I successfully passed my php array to a js array using the code below: var horse_array = <?php echo json_encode($horse_info);?>; ...

Empty the password field

<input name="e_password" id="e_password" type="password" autocomplete="off" /> The password field above is causing some trouble as it gets automatically filled in Mozilla, but not in Chrome and IE11. This seems to be retaining values from previous a ...

Turn off scroll bar to create a seamless browsing experience on your website

As I work on creating the frontend for a single-page website with seamless scrolling between divs, I'm looking to eliminate mouse scrolling altogether. I understand that using overflow:hidden; can hide scroll bars, but my goal is to make the page scr ...

What is the best method to prevent next.js components from overlapping one another?

I recently created a website using next.js and noticed an issue in my index.js file. There is a div that houses the main components of the site: class Page extends Component { render() { return ( <div className={styles.container}> ...

Postponing the activation of toggleClass in jQuery until the completion of a slide animation

Having some trouble with the jQuery delay() function. I'm using it to pause a toggleClass action until after a slideUp animation on one of my divs, but it doesn't seem to be working as expected. I want a bar with rounded corners that expands whe ...

Tips for implementing a checkbox (with tick/untick functionality) as a replacement for a plus/minus toggle using HTML

Is it possible to use checkboxes instead of plus and minus signs for expanding and collapsing sections? Can the plus and minus symbols be incorporated into the checkbox itself, so that clicking on the checkbox toggles between plus and minus states? Any hel ...

I'm encountering an issue trying to launch bigbluebutton HTML5. I attempted to initiate it using "npm start" after installing it with "meteor npm install," but unfortunately, it failed to

I've been attempting to launch the Development environment for bigblubutton-html5, but unfortunately, I encountered an error message after executing this command: npm start Please refer to the tutorial I used: Here's the error message that was ...

Tips on preventing the opening of a new browser tab by using Ctrl + click

Hey there, I've got a list of products that can be selected using the Ctrl key. $(parentSelector).on("click", function (evnt) { evnt.stopImmediatePropagation(); var item = $(evnt.delegateTarget) ...

Pass a jQuery value to a PHP variable

I am looking to send a value when I click a button. For example, when I click on <a id="link1"> Page Home </a>, it should send the value to a custom variable php. Here is an example: <?php $linkredirect = ''; // This will be sent ...

Generating dynamic divs in parallel

Despite encountering numerous posts related to the issue at hand, none of them have solved my specific problem. I am aiming for 3 divs to display in each row, but the current code is causing each div to show up on a new line vertically: JQuery ...

default radio option with pre-selected value

Below is a radio option list, but I'm having trouble getting the desired default selection on first render: <label class="radio normalFontWeight"> <input type="radio" name="Criteria" data-ng-value="EVERYONE_REVIEWED" data-ng- ...

Toggle Divs with jQuery (Rotate images depending on link)

I am currently using the following code to toggle the visibility of div elements. http://jsfiddle.net/XwN2L/3120/ In addition, I would like to have a unique image sprite for each link when it is selected. I attempted to assign individual IDs to each link ...

The PNG logo will display with white borders when viewed on Internet Explorer 9

My current project involves developing an asp.net mvc web application. In the upper top navigation bar, we have a blue area where I am trying to display our logo using the code snippet below: <a class="brand" href="~/Home/Index/"> <img alt="Group ...

A method of submitting by simply pressing the enter key alongside clicking on a Bootstrap button

Here is the HTML code I am using to input prompts into a chatbot: <div class="input-group mb-3"> <input type="text" class="form-control" id="chat-input"> <div class="input-group-append ...

The scope of JavaScript's dynamic object

Can created objects be utilized in a different scope? var iZ = 0; var pcs = {}; function Pc(_name, _os) //Constructor { this.name = _name; // Pc Name this.os = _os; //Pc Os this.ausgabe = function() { //Do something }; ...

Excess space noted at the bottom of tablet and mobile versions of the page

I'm struggling to troubleshoot an issue with the mobile and tablet versions of a web-shop I'm designing for university. Some pages have excessive space after the HTML tag, but only on certain pages. I've tried commenting out CSS lines relate ...

The `forEach` method cannot be called on an undefined node.js

I have been developing a small study website but encountered an issue with the title. Despite extensive internet research, I have not been able to find a solution. The system I am using is Ubuntu with node.js, express, and mysql. app.js var fs = requir ...