How can I float a square to the right in Bootstrap with a col-md-4 size but with a height restricted to only 200 px

Looking to add a small square on the page for users to search and purchase courses directly. The square should be 4 columns wide, follow Bootstrap4 grid template, and be around 200-300 px in length. It needs to remain visible as the user scrolls down the page.

Take inspiration from this site when implementing this feature:

Codepen:

https://codepen.io/ogonzales/pen/QWjmorP

CODE:

Currently facing an issue where the square remains fixed at the top of the page as the user scrolls.

<main role="main" class="container">
        <div class="row">
          <div class="col-md-8">
            /* Content for main section */
          </div>
          <div class="col-md-4" id="LocalSide">

            <form class="search-form" action="/search/" method="post">
              <input type="hidden" name="csrfmiddlewaretoken"
                value="KTlYgVaxnAYKzLle9WWDNIoE0MDSvAVldfbsnKbfpAStWafCb1MVMgwLdArZUEiP">
              <div class="form-group">
                <input type="search" class="form-control search-course" placeholder="Search for course" name="search_term"
                  required="">
                <input type="hidden" value="3" name="course_id">
              </div>
            </form>

            <h2 class="local-side-heading">In this Section:</h2>
            <nav class="local-nav">
              <ol data-local-nav-list=""></ol>
            </nav>


            <a class="pcta" href="/payments/tdd-flask/" data-a-buy-course-cta="tdd-flask">
              <span class="label label-success">
                <span class="pcta-label">Get the</span>
                <span class="pcta-hook">full course</span>
                <span class="sr-only">for</span>
                <span class="pcta-badge" aria-hidden="true">Now Only</span>
              </span>
              <span class="pcta-price">$30</span>
            </a>



            <a href="#TOP" class="local-side-jump" data-back-to-top="">↑ Back to top</a>
          </div>
        </div>
      </main>

BONUS:

Would like to incorporate the green arrow found here:

Ideally looking for a solution that works with Bootstrap 4.4.1 since using Bootstrap 3.4.1 displays the labels but not the arrow as needed.

https://i.stack.imgur.com/ej6KA.png

Answer №1

I've made some updates to the CSS and HTML files. Take a look and let me know your thoughts.

/* New styles for sticky footer
-------------------------------------------------- */
html {
  position: relative;
  min-height: 100%;
  font-size: 14px;
}
#LocalSide {
  border-style:solid;
  border-width: thin;
  border-color: #E8E8E8;
  padding: 10px;
  border-top: none;
  border-right:none;
}

.box {
    margin-right: 5px;
    padding: 10px   
}

.pcta-hook {
font-size:25px;
    font-weight: 200;
}

span.pcta-label {
font-size:25px;
    font-weight: 200;

}
.pcta-price {
  font-size: 50px;
    font-weight: 600;
}

.green {
background-color: #00FF4D;
    color: white;
    font-size:15px;
    padding: 3px;
    z-index: 99;
    position: relative;
}



.triangle{
   width: 0;
    height: 0;
    border-width: 10px 0 10px 36px;
    border-color: transparent transparent transparent #00FF4D;
    border-style: solid;
    float: right;
    top: 1px;
   position: relative;
    right: 18px;
    z-index: 5;


}

.arrow {


  border: solid black;
  border-width: 0 3px 3px 0;
  display: inline-block;
  padding: 3px;
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);

}

.blockHead:after {
  color: #4D81BF;
  border-left: 20px solid;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  display: inline-block;
  content: '';
  position: absolute;
  right: -19px;
  top: 0;
}
.blockHead {
  background-color: #4D81BF;
  /*width: 150px; */
  display: inline-block;
  position: relative;
}
.blocktext {
  color: white;
  font-weight: bold;
  padding-left: 10px;
  font-family: Arial;
  font-size: 11;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin-bottom: 60px; /* Margin bottom by footer height */
  font-family: 'Poppins', sans-serif;
  background: #fafafa;
  padding-top: 70px;
}

.label { border-radius: 0; text-shadow: none; font-size: 11px; font-weight: normal; padding: 3px 5px 3px; background-color: #abbac3!important }
.label[class*="span"][class*="arrow"] { min-height: 0 }

.container {
  max-width: 960px;
}

.pricing-header {
  max-width: 700px;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 80%;
  height: 60px; /* Set the fixed height of the footer here */
  line-height: 60px; /* Vertically center the text there */
  background-color: #f5f5f5;
}

/* NAVBAR TOP */

#top-navbar ul li.active>a
a[aria-expanded="true"] {
  color: #1f1f1f;
  background: #12b556;
}

#top-navbar a:visited {
  color: #fff;
}

#top-navbar a:link {
  color: #fff;
}

#top-navbar a.subitem:link {
  color: 

- // SIDEBAR STYLES HERE -

#content {
// Content styling properties here
}

@media (max-width: 768px) {
// Media queries for smaller screens 
}
    <main role="main" class="container">
          <div class="row">
            <div class="col-md-8">
              {% block content %}
              {% endblock content %}
            </div>
            <div class="col-md-4 float-right" id="LocalSide">

              <form class="search-form" action="/search/" method="post">
                <input type="hidden" name="csrfmiddlewaretoken"
                  value="KTlYgVaxnAYKzLle9WWDNIoE0MDSvAVldfbsnKbfpAStWafCb1MVMgwLdArZUEiP">
                <div class="form-group">
                  <input type="search" class="form-control search-course" placeholder="Buscar curso" name="search_term"
                    required="">
                  <input type="hidden" value="3" name="course_id">
                </div>
              </form>

              <h2 class="local-side-heading">In this Section:</h2>
              <nav class="local-nav">
                <ol data-local-nav-list=""></ol>
                </nav>
<div class="row">
  <div class="box">
 <span class="pcta-label">Get the </span><br>
  <span class="pcta-hook">full course</span> <br>
      <span class="green" >ABC Team </span> <div class="triangle"> </div>
    </div>
          <div class="box">      

              <span class="pcta-price">$30</span> </div>
  </div>



             <div class="mt-3"> <a href="#TOP" class="local-side-jump " data-back-to-top="">↑ Back to top</a> </div> 
            </div>
          </div>
        </main>


        <footer class="footer">
          <div class="container">
            <span class="text-muted">Footer...</span>
          </div>
        </footer>

      </div>
    </div>

Check out this JS Fiddle link for a live demo:

https://jsfiddle.net/hilalrehan/bu96yh17/1/

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

The sidebar in Semantic UI does not have a specified height for the form segment

Need help troubleshooting a button that slides out a vertical sidebar. I want to include a short form for users to input search queries within the sidebar. The issue seems to be with the heights of #search-sidebar and .ui.form.segment. Here is the code s ...

What is the best way to spin a div HTML layer?

I'm trying to modify a Div layer that looks like this: ... <style type="text/css"> <!-- #newImg { position:absolute; left:180px; top:99px; width:704px; height:387px; z-index:1; background-image:url(../Pictures/rep ...

This piece of code is causing my browser to lag

I am encountering an issue with fetching and adding values from a weather API to my HTML elements. My goal is to display the hourly forecast for today, starting from the current hour until midnight of the next day. In order to optimize space, I implemente ...

Retrieving data from the database and presenting it in HTML div elements

As a newcomer to PHP and MySQL, I am still learning the ropes. My goal is to extract data from the database and organize it into different divs based on unique IDs. For instance, div assigned to ID 1 will display the corresponding entry, div with ID 2 will ...

Ways to create a sequential appearance of elements through CSS animations

Can you help me achieve a wave effect for elements appearing one by one using CSS animation (jQuery)? Currently, all the elements show up at once and I want to create a wave-like motion. Any assistance would be greatly appreciated. $(window ...

Tips for transferring a value from a function in ASPX to a CS file

I seem to be overlooking a small detail. I have a dropdown list (DDL) and a function in my C# file. I want to pass the 'value attribute' of a selected DDL option to my function, but I can't seem to retrieve the value attribute. I checked the ...

How can I ensure a DIV is shown on every sub-page?

Is there a way to dynamically display a <div id="chatbox"> in all subpages without needing to manually edit each one? For example, adding this code to the main index.html file and having it appear on /products/index.html. ...

Tips for effectively showcasing the counter outcome amidst the increase and decrease buttons

Currently, I am in the process of learning Angular and have created a component called quantity-component. Within the quantity-component.component.html file, I have implemented 2 buttons for increment (denoted by +) and decrement (denoted by -). The decrem ...

Discovering the proper method to reach the parent element in jQuery while within the click event

How can I use jQuery to access the parent element within a click event? $(document).ready(function () { $(".lv1 li").click(function (event) { this.parentElement.parentElement.textContent = this.textContent; $.ajax({ type: 'post&apo ...

How to access a PHP include using data retrieved from a MySQL database?

I am currently in the process of developing a website that will be powered by a MySQL database. To simplify the structure of the URLs, I have decided to rewrite them to point to a single file. The file's layout is as follows: <html> <head&g ...

Getting the value of an HTML tag returned from an Ajax request

After making an AJAX call in VBScript, I am receiving the following HTML: <html> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td width="100%" ...

Set the size of the website to remain constant

Is it possible to keep your website at a consistent size so that when viewed on a larger screen, it simply adds more background or space to the page? (I prefer not to use media queries to change the style as the screen size increases) ...

Having trouble getting a DIV to appear on top of another DIV containing an image

I need help with positioning an "InfoBox" above the main header image on my website. Despite trying z-indexes and adjusting position, I can't seem to get it right. If anyone has any suggestions, please share. Thank you! For reference, here is the HTM ...

Is there a way to create a blurred background effect while the popup is in use?

I prefer my popup to have a dark or blurred background when active. The popup itself should remain the same, with only the background being darkened. I would like a dark layer overlaying the entire page. This script should be compatible with any website wh ...

Material UI AppBar fixed position that is not part of a grid container

Hey everyone, I'm really struggling with this issue. I recently set my AppBar to have a position of "fixed". However, now the appbar is no longer contained within its container and instead spans the entire screen. I've been trying to figure it ou ...

How can we utilize CSS floats to achieve maximum widths?

I currently have 5 divs that I need to structure in a specific way: Each div must have a minimum size of 100px The parent container should display as many divs as possible on the first row, with any remaining divs wrapping to new rows if necessary If the ...

What is the best method for inserting space between two divs?

I need to create more space between the last two cards and the image at the bottom, but this spacing should increase as I resize the browser window. Can anyone help me with this? https://i.stack.imgur.com/rq9t2.png https://i.stack.imgur.com/tOikx.png Th ...

Use Backbone.js to dynamically insert partial views based on specific routes, similar to how ng-view works in AngularJS

After gaining experience with AngularJs, I am now looking to dive into Backbone.js. However, I am struggling to understand how this library handles routes and partial views/templates "injection". In Angular, we can easily set up static components like th ...

Automate the process of filling up and activating a bootstrap dropdown upon a click, and clearing it out when it is

Is there a method to reveal the dropdown content only upon clicking instead of displaying all content at once and increasing the lines of HTML code? Perhaps using an onclick attribute on the button and incorporating a function inside? var data = [{ " ...

CLS notifies about an Unrecognized CSS Element in Page Insights' Core Web Performance

My experience with Google PageSpeed Insights has been quite frustrating due to the numerous alerts I'm receiving about Unsupported CSS Properties. The importance of avoiding non-composited animations: Animations that are not composited can appear gli ...