Is it possible to prevent anchors and buttons from shifting positions when resizing the web-screen?

I have noticed that when I try to resize the webpage, the "read more" anchors/buttons also move. Is there a solution to keep them in place when resizing the web screen? I have already attempted using position fixed.

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

This is the only code related to the issue, and I am using Bootstrap with minimal CSS.

<section class="second-section">
<div class="container-fluid">
  <div class="row text-center">
     <div class="col-md bg-white border">
      <div class="card-1 text-left ">
        <h1>Business <span>Mentoring</span></h1>
        <p>Our mentors are leading professionals and experts in their field with a passion....</p>
        <a href="#" class="readMore-anchor">Read more</a>
      </div>
    </div>
     <div class="col-md bg-white border">
      <div class="card-2 text-left">
        <h1>Business <span>Coaching</span></h1>
        <p>Our coaches are successful professionals and leaders in their field, who ....</p>
        <a href="#" class="readMore-anchor">Read more</a>
      </div>
     </div>
     <div class="col-md bg-white border">
      <div class="card-3 text-left">
        <h1>Personal <span>Mentoring</span> and coaching</h1>
        <p>Is where we have professionals ready to work with a family,...</p>
        <a href="#" class="readMore-anchor">Read more</a>
      </div>
     </div>
     <div class="col-md bg-white border">
      <div class="card-4 text-left">
        <h1>Career <span>Exploration</span></h1>
        <p>Career advice and exploration are vital if you want to maximize your potential in today's....</p>
        <a href="#" class="readMore-anchor">Read more</a>
      </div>
     </div>
  </div>
</div>
</section> 
.card-1 .card-2 .card-3 .card-4 h1{
  width: 100%;  
  font-size: 40px; 
  line-height: 50px; 
  font-family: "Montserrat Bold";
}
.card-1 h1 span{
  display: block;
}
.card-1 .card-2 .card-3 .card-4 p{
  width: 100%;
  max-width: 325px;
  font-size: 16px;
  color: #232020;
  line-height: 28px;;
  font-family: "Montserrat Regular";
} 
.second-section p{
  margin: 0;  
}
.readMore-anchor{
  width: 100%;
  height: 47px;
  font-size: 16px;
  max-width: 161px;
  line-height: 50px;
  padding: 15px 38px;
  background-color: #8cd9f9; ;
} 

Answer №1

If you encounter a similar issue as I did some time ago, here's how I resolved it (although there may be alternative solutions):

  1. Start by adding position: relative to the four container cards (keep in mind this is for the buttons, not the cards themselves). Additionally, apply padding to the bottom of the container cards to create space for the buttons when they are positioned.
.bg-white {
       position: relative;
       padding-bottom: 60px; 
    }
  1. Absolute position the buttons within the space we just created.
.bg-white > .text-left > .readMore-anchor {    
    position: absolute;
    right: 10px;
    bottom: 10px;
}

By following these steps, you should achieve a layout where the white space between the text and buttons adjusts automatically based on the card with the most text content, ensuring consistency across all cards. My implementation may not be as visually refined as yours, but it should serve the functionality you desire.

https://i.sstatic.net/ybqRO.jpg

.card-1 .card-2 .card-3 .card-4 h1{
  width: 100%;  
  font-size: 40px; 
  line-height: 50px; 
  font-family: "Montserrat Bold";  
}
.card-1 h1 span{
  display: block;
}
.card-1 .card-2 .card-3 .card-4 p{
  width: 100%;
  max-width: 325px;
  font-size: 16px;
  color: #232020;
  line-height: 28px;;
  font-family: "Montserrat Regular";
} 
.second-section p{
  margin: 0;  
}
.readMore-anchor{
  width: 100%;
  height: 47px;
  font-size: 16px;
  max-width: 161px;
  line-height: 50px;
  padding: 15px 38px;
  background-color: #8cd9f9; ;
} 



.bg-white {
   position: relative;
   padding-bottom: 60px; 
}

.bg-white > .text-left > .readMore-anchor {    
    position: absolute;
    right: 10px;
    bottom: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

<section class="second-section">
    <div class="container-fluid">
      <div class="row text-center">
         <div class="col-md bg-white border">
          <div class="card-1 text-left ">
            <h1>Business <span>Mentoring</span></h1>
            <p>Our mentors are leading professional and experts in their field with a passion....</p>
            <a href="#" class="readMore-anchor">Read more</a>
          </div>
        </div>
         <div class="col-md bg-white border">
          <div class="card-2 text-left">
            <h1>Business <span>Coaching</span></h1>
            <p>Our coaches are successful professional and leaders in their field, who ....</p>
            <a href="#" class="readMore-anchor">Read more</a>
          </div>
         </div>
         <div class="col-md bg-white border">
          <div class="card-3 text-left">
            <h1>Personal <span>Mentoring</span> and coaching</h1>
            <p>is where have professionals ready to work with a family,...</p>
            <a href="#" class="readMore-anchor">Read more</a>
          </div>
         </div>
         <div class="col-md bg-white border">
          <div class="card-4 text-left">
            <h1>Career <span>exploration</span></h1>
            <p>Career advice and exploration is vital if you want to maximise your potential in today's....</p>
            <a href="#" class="readMore-anchor">Read more</a>
          </div>
         </div>
      </div>
    </div>
    </section> 

Answer №2

include this code in your current stylesheet

.readMore-anchor{
        position :absolute;
        bottom:2%;//adjust as needed//
        left:2%;//adjust as needed//
    }


.container{
 position :relative;
}

**enclose the anchor tag (with class readMore-anchor) inside a div with class container **

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

Is there a way to display x squared as a superscript inside a button element?

In my reactjs project, I am developing a basic calculator. One of the buttons is supposed to calculate x squared, and I tried using the <sup> HTML element for this purpose but it did not work as expected. <Button name = "x<sup>2</sup> ...

Implementing jquery into Angular 2 webpack project is essential as jQuery is necessary for Bootstrap's JavaScript to function properly

I am currently utilizing the angular-cli .net core starter. As I attempt to incorporate my own CSS and JavaScript files, I encounter the following error: An unhandled exception occurred while processing the request. Exception: Call to Node module fail ...

Align two containers centrally using absolute positioning inside a division

I am looking for a way to centrally align two "boxes" within a div using CSS. These boxes are positioned absolutely. For reference, here is the JSFiddle link: http://jsfiddle.net/p4sA3/8/ Is there a method to achieve this alignment without specifying spe ...

What is the best method for incorporating dynamic page transitions when navigating between individual pages?

Let's say I have the following pages: red.html blue.html green.html My goal is to create links from red.html to blue.html and red.html to green.html. When attempting to use page anchors and iframes, I encountered an issue where scrolling from red.h ...

Having trouble using the `.not` function in jQuery

I'm working on implementing a collapsible menu using jQuery. When any header is clicked, the next sibling (the box) should expand while all other boxes collapse. HTML <div class="finbox" id="finbox1"> <div class="finheader" id="finheade ...

The functionality of a switch statement relies on the presence of a React-Router

Is there a way to dynamically change the text in a paragraph based on which Route is currently enabled? I tried using a switch statement, but I'm unsure of how to implement it. Any suggestions or ideas? import React from 'react'; import &ap ...

Achieving left text alignment in CSS for an excerpt using the Ultimate Posts Widget on Wordpress

I've been trying to align the text in the excerpt of a widget called "To-Do List" on the left sidebar. I attempted to set the text-align property to left for the excerpt text, targeting the p tag within the .widget_ultimate_posts, .uw posts using CSS ...

Achieve equal height columns when they are stacked vertically using Bootstrap 5

Can columns be equal height when they become rows on mobile devices? <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="57353838232423253627176279677965">[email protected]</ ...

Trouble getting CSS to load in Webpack

I'm having some trouble setting up Webpack for the first time and I think I might be overlooking something. My goal is to use Webpack's ExtractTextPlugin to generate a CSS file in the "dist" folder, but it seems that Webpack isn't recognizi ...

Is it possible to customize the appearance of specific characters within an input field?

One of our clients has inquired about incorporating the type="number" attribute for a credit card field to ensure the appropriate keyboard is displayed on mobile devices. However, they also want to add padding after every 4th character to mimic the appea ...

When applying styles in Polymer, it's important to take into account the width and height

Having trouble setting the width of elements within container elements in Polymer. Here's a simple example that illustrates the issue: <!doctype html> <html> <head> <base href="https://polygit.org/polymer+:master/webcomponent ...

How do you activate the background color for paragraphs <p> when a bootstrap button is styled with CSS?

In the code snippet provided below, dynamic creation of paragraphs with changing background colors and styles is demonstrated. One challenge faced in this script is maintaining the printed background colors for each dynamically generated paragraph. The is ...

The rounding of my image is uneven across all sides

I'm attempting to give my image rounded borders using border-radius, but I'm unsure if the overflow property is affecting the image. Image 1 shows my current image, while Image 2 depicts what I am trying to achieve. I am utilizing React, HTML, no ...

Having difficulty rendering images in PHP

I'm having trouble displaying images on my web server using php, and I keep encountering a server 500 error. The issue appears to be related to this line of code: echo "<img src='$row["sourchPath"]'>": while ($row = mysqli_fetch_asso ...

Having trouble aligning a div vertically inside another div?

I am struggling to vertically align a div within another div. I have experimented with vertical-align, position: relative; top: 50%, and margin: auto; without success. Take a look at the code below: .main { font-family: "adobe-garamond-pro"; pad ...

Customize CKEditor by automatically changing the font family when the page is loaded

How can I change the font-family of CKEditor to Meiryo based on a JavaScript boolean? I attempted this code in my custom JS within an if condition, but it did not successfully change the font-family: config.font_style = { element : 'span&apo ...

Should CSS properties be applied directly to the html tag?

Surprisingly, I recently discovered that it's possible to set the background-color of the html tag. It seems strange since I always thought the body was responsible for containing the first rendered tag. I used to believe that the html tag was just a ...

Tips for customizing the appearance of a child component using the parent component in Vue.js

I am working on creating a layout using Vuejs and flexbox that includes elements like 'header, sidebar, main-content, sidebar, footer'. I have separated each part of the layout into individual .vue files, such as header.vue and sidebar.vue. In ...

Contingent creation of HTML

I am working on a logic that should display an error message in the form of a label when a certain condition returns false. So far, I have attempted to use Response.Write without success. if (bannedDomainText.Text.Contains(".")) File.AppendAllText(M ...

"Error encountered when attempting to call the requestFocus() method on a Java applet from JavaScript

I'm encountering an issue with calling the requestFocus() method in JavaScript. Uncaught TypeError: Object #<HTMLAppletElement> has no method 'requestFocus' Below is my JavaScript code within the <head> tags: function onLoad() ...