Stop the link height from changing when hovered over

Incorporating Angular, Angular Material, and Angular Flex-Layout, I have designed a collection of links that resemble cards or tiles. The links initially display an icon and title but transition to show informational text upon hovering.

However, for links with extensive informational text, this state change is causing the items to increase in height.

To address this issue, I attempted setting a min-height using percentages instead of pixels, such as 110%. Unfortunately, this did not alter the size of the links. The same outcome was observed for the containing div named .container.

Below is a snippet:

<div class="container" fxLayout fxLayoutAlign="center" fxLayoutGap="10px">

  <a mat-flat-button color="primary" fxFlex href="https://example.com/footprints">
    <div class="hoverOff"><fa-icon [icon]="faToolbox"></fa-icon>Broken</div>
    <div class="hoverOn">Is your request impacting a business-critical function affecting daily production?</div>
  </a>

  <a mat-flat-button color="primary" fxFlex href="https://example.com/divisions/dev/Lists/Requests/NewForm.aspx?isProject=Yes">
    <div class="hoverOff"><fa-icon [icon]="faPuzzlePiece"></fa-icon>Project</div>
    <div class="hoverOn">Is your request related to a new product or service?<br>
      Does it require an RFI or RFP process?<br>
      Is it necessary for more than 500 internal resource hours?<br>
      Involves costs exceeding $100,000?<br>
      Pertains to a new banking center or remodel?<br>
      Related to a new partnership, divestiture, or branch closure?
    </div>
  </a>

</div>

<style>
.mat-flat-button {
    white-space: normal;
    line-height: normal;
}

a {
    color: white !important;
    display: flex;
    justify-content: center;
    align-items: center;
}

fa-icon {
    display: block;
    font-size: 75px;
}

.mat-primary {
    background-color: #00539B !important;
}

a .hoverOn {
    display: none;
}

a:hover .hoverOn {
    display: block;
}

a:hover .hoverOff {
    display: none;
}
</style>

I have provided a demonstration on StackBlitz.

Any suggestions on how I can resolve the height adjustment issue without resorting to hard-coded pixel values?

Answer №1

To prevent the height change on scroll and utilize 45% of the viewport height (vh) in your CSS, add the following code:

.container{
  height:45vh
}

Additionally, to extend the container 10% beyond the vh for a total of 110%, you can use the following code:

.container{
  height:110vh
}

Check out the Stackblitz demo here:

https://stackblitz.com/edit/angular-w1exhe?embed=1&file=src/app/app.component.css

Answer №2

If you are interested in adjusting the css of links, you may consider adding the following code to the a css:

 max-height:60vh; (or use percentage instead of vh but specify a max-height)   
 overflow-y:auto;
 overflow-x:hidden;

I hope this information proves useful.

Example (I adjusted your icon size to 35pt in this)

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 displaying the HTML content within the autocomplete box

My situation involves a text input and an HTML form where users can submit their name to retrieve information. I am using AJAX to display the usernames dynamically. <div class="hidesearch" id="search" style="width:"400px;"> <inp ...

Is there a way to modify the FixedTableHeader jQuery plugin to include a fixed first column in addition to the fixed header?

I've been experimenting with a jQuery plugin I found at to create a stylish table with fixed headers, sorting options, and other interesting features. While the plugin is great, I also considered using jqGrid for its impressive capabilities. However, ...

Is it not possible to collapse in webkit?

Check out this jsfiddle link for a visual example: http://jsfiddle.net/qrbhb/ If you use the following HTML markup: <div>There should be no gap between us</div> <br /> <div>There should be no gap between us</div> along with ...

Display different images based on user selection in vue.js

I am new to working with vue.js and I'm facing a challenge. My goal is to display images of NBA players based on the selected criteria using vue.js. For instance, if the Dunk contest champion is chosen, only images of Kobe and Jordan should be display ...

Hover over CSS sprite

My anchor tag looks like this: <a href="#"> <i class="ico01"></i> <span>Text</span> </a> The ico01 class applies an image using CSS sprite. I want to change the background color of the entire content inside the a ...

Conceal the initial modal beneath the overlay when the second modal is activated

I have a situation where I am using a modal that contains a button to trigger a second modal. The issue is that the overlay of the second modal does not hide the first modal, it simply darkens the background. How can I make the overlay of the second modal ...

What are some ways to incorporate Chakra UI with the after pseudo-class to generate a dark overlay in my video's foreground? (Specifically in the Hero section)

I am working on creating a layer effect in front of a video using Next.js and Chakra UI. I have provided an example in Figma: Here is the code snippet: function Hero() { const videoRef = useRef(); useEffect(() => { setTimeout(()=>{ ...

Switching from a right arrow to a down arrow using jQuery for a collapsible accordion feature

I have developed a unique type of toggle feature similar to an accordion design. When I click on the right-arrow next to an item, such as Area A, it expands to reveal the list of items within Area A. The arrow also changes orientation to point downwards (L ...

Can you explain how to extract information from an API response using res.send?

Utilizing the MEAN stack in JavaScript for my single page application has been seamless. A crucial component of my architecture involves an Angular factory that communicates with my API. app.factory('authorizing', function($resource){ retur ...

transferring double quotation marks and square brackets through a parameter

I have an angularjs (1.x) scope set up as follows: $scope.report = { resource: '/public/emplyACH', params: { "employeeId": [78] } }; When I try to access it using console.log (console.log(scope.parms)) I see the output as ...

Updating data for a heatmap in Angular-Leaflet

My goal is to display a dynamic heatmap using the Angular-Leaflet directive. I have written the following code: getData().then(function (data) { $scope.heat.index = 0; $scope.heat.data = data; $scope.layers.overlays.heat = { name: "Hea ...

CSS: positioning and resizing image while maintaining aspect ratio

Is there a way to center and resize an image in html/css while maintaining its aspect ratio? I currently have a solution that centers the image, but it does not scale up when necessary. Here is the code snippet: http://jsfiddle.net/4Mvan/438/ .container ...

Determine the quantity of characters available in a contenteditable field

I have implemented a directive that allows me to input editable content inside a tag Recently, I made modifications to include a character counter feature. However, I noticed that when I add line breaks, the character count increases erroneously. https: ...

Exploring the contrasts between one-way binding and two-way binding within AngularJS

Can you please elaborate on the distinction between One-way Data Binding and Two-way Data Binding, providing an example of each and explaining when we would use them? ...

An empty space separating the header and the navigation bar

As a beginner in HTML and CSS, I decided to create a basic website. However, I encountered an issue with the layout - there seems to be a gap between my header image and navigation bar, but I can't figure out what's causing it. HTML <!DOCTYPE ...

Exploring scope in an angular service

My goal is to show a success message after clicking a button. Since I need this functionality in multiple controllers, I decided to implement it using a service. However, I am facing issues accessing the scope. index.html <div ng-controller="uploadCon ...

"Kindly complete all mandatory fields" - The undisclosed field is preventing me from submitting

I am facing an issue with my WordPress page that has Buddyboss installed along with Elementor pro as the Pagebuilder. The Buddyboss plugin provides Facebook-like functions on the website. While it is easy to comment on posts within the Buddy Boss system, I ...

How to stop the second function from being executed within the same ng-click event in AngularJS

My ng-click consists of two functions working together. Function1: A directive function that toggles a scope variable Function2: A controller function Currently, Function2 checks the value of the scope variable set by Function1 at the beginning. If it&a ...

Adjust the alignment of text on both ends of the HTML5 canvas

Is there an easier way to align text on both sides of a canvas element besides using CSS? The link below might provide some insight: https://github.com/nnnick/Chart.js/issues/114#issuecomment-18564527 I'm considering incorporating the text into the d ...

Mastering the Art of Utilizing AngularJS to Harness the Power of Keypress and

Currently, I am in the process of developing a calculator utilizing AngularJS. The issue arises when clicking on the '923216' buttons triggers the "updateOutput(btn)" function, successfully appending them and updating the view. However, upon addi ...