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

Issues with the alignment of columns using Bootstrap framework

I've created a design in Photoshop using the Bootstrap 12-column guide, but when I try to implement it using Bootstrap, the results are completely off. https://i.stack.imgur.com/vQwOt.png Here's my HTML code: <!DOCTYPE html> <html lan ...

Determine the dimensions of a div element in IE after adjusting its height to auto

I am currently working on a JavaScript function that modifies the size of certain content. In order to accomplish this, I need to obtain the height of a specific div element within my content structure. Below is an example of the HTML code I am dealing wit ...

A simple guide on how to surround every incorrect input index in mapped inputs with red borders

I am incorporating a modal that corresponds each element of the object newCompanies to a specific row: {newCompanies.map((company, index) => { return ( <div> <div className="side- ...

What is the best way to ensure that a div appears below, rather than alongside, another one

I need help positioning my divs on the webpage. Currently, my map div is appearing next to the list instead of below it. The height of the list can vary as it is generated dynamically. I want the map div to be on the right side with the list displayed on t ...

Scrolling horizontally to display dynamic columns based on a search query in AngularJS

I am facing a challenge with implementing search functionality in a table that has multiple dynamic columns with a horizontal scrollbar. The goal is for users to be able to search for a specific column name or data, and if a match is found, the scrollbar s ...

Switch out the content within a div upon selection

I'm currently working on a palette board project and facing some challenges when switching to a different theme. The initial page is set to have a Warm color palette, but I intend to alter this once the user clicks on the All theme option. Users wil ...

The lower text box on the page being covered by the virtual keyboard on IOS

Our website features a fixed header and footer with scrollable content. We have 20 text boxes on the page, but the ones at the bottom, like Zip and Telephone, are obscured by the iOS virtual keyboard that appears when a text box is clicked. If we could d ...

Maintaining the position of the screen as you type in information that is located outside of the container

I am encountering an issue with the input/text-area element in absolute position extending halfway outside the container. The screen position seems to follow the caret as I type, but I'd prefer to keep writing and have part of the text hidden beyond t ...

Persistent button positioned at the bottom of the page, remaining visible even when scrolling to the very end of the content

I am looking to add a floating button that remains in the same position relative to the content until the window is scrolled to a certain point, after which it sticks to the end of the content. In simple terms, I want the element to act as 'relative& ...

Incorporate text onto an image using Semantic UI

Currently, I am utilizing Semantic UI to display images. While it is functioning well for me in terms of adding text near the image, I desire to have the text positioned on top of the image. Ideally, I would like it to be located on the lower half of the i ...

Chrome and Firefox browsers are not supporting HTML simple anchor links

Creating a portfolio page at this link (http://198.96.94.51/v2/) and encountering an issue with the navigationMenu. When rapidly clicking on the links on the side, they do not redirect to the correct anchor point (some don't move the page at all). I h ...

Display flex causing Mui LinearProgress Bar to disappear

Looking for a way to create a unique bullet graph using material UI? How about two MuiLinearProgress bars placed side by side with a vertical Divider in between them. Struggling to get them displayed next to each other? <div className={classes.bulletGra ...

Animation failing to be queued properly

Here is a snippet of code that moves a heading icon back and forth when you hover over the heading: jQuery('h1.heading').hover( function(){ $icon = jQuery('.heading-icon', this); if( ! $icon.is(':animated') ){ ...

Incorporate a map (using leafletjs or Google Maps) as a subtle backdrop

I am currently working on a one-page website and I would like to include a map as a background behind the "contact" section. The map can be set to float, draggable, or positioned at the back. I have experience using both the Google Maps API and LeafletJS, ...

Tips for implementing an image as a background in AngularJS

Struggling with a Dilemma: This issue has been driving me insane for the past three days... I am eager to utilize an angularJS variable as a background image without relying on a directive. My objective is to load images of any shape (square, rectangle, ...

Using CSS to conceal an element when a different element is also invisible

My inquiry is as follows: I currently possess a code that conceals class element 1 when it possesses a specific value (which varies across different sites). Now, my objective is to also conceal class element 2 ONLY IF class element 1 is already hidden. ...

Issues arise when implementing ReactJS transitions for progress bars

As a newcomer to the world of ReactJS, I have been exploring the FB documentations and online tutorials to kickstart my test project. Within this project, I wanted to implement a progress bar that visually represents the user's progression through fi ...

I'm having trouble getting my accordion menu to work properly. Whenever I click on the question title, the answer doesn't seem to show up or collapse. What could be causing this issue?

I am currently working on a project to create an accordion menu where the answers are hidden and only revealed upon clicking the question. However, when I test it out, nothing happens when I click on the question. Here is my code: .accordion-Section ...

I am attempting to make the fade in and out effect function properly in my slideshow

I've encountered an issue where the fading effect only occurs when the page initially loads and solely on the first image. Subsequently, the fading effect does not work on any other images displayed. This is the CSS code I have implemented by adding ...

Guide on exporting Excel data using Angular and TypeScript

My project involves managing a table of information that includes fields for FirstName, LastName, PhoneNumber, Age, and Date. I've created a function that allows me to export the data to an Excel file, but I only want to export specific fields like Fi ...