Turn on and off scrolling of DIV content when hovering over it

How can I create a div that automatically scrolls to the bottom on hover? I tried implementing the code below, but it doesn't work as expected. It jumps to the bottom of the div's height on first hover and transitions smoothly on second hover.

.komal {
      overflow: hidden;
      height: 212px;
      position: relative;
  }
  .imgpos {
      position: absolute;
      transition: all 1s ease-out 0s;
  }

<div class="col-12 col-lg-4" id="outgov" style="height: auto;">
  <div class="card card-shadowed card-hover-shadow komal dhiraj">
    <div class="card-block text-center imgpos">
      <img src="assets/home_solutions/outsourcing-governance.png" width="30%" style="margin-bottom: 20px;">
      <h2 class="card-title text-center">Outsourcing Governance</h2>
      <hr class="hr">
      <div class="row" id="outgov_hidden" style="background-color: white; z-index: 9; margin-left:-20px; padding-bottom: 20px;">
        <div class="text-center"><br>
          <h4 class="modal-title" style="color: #000">Outsourcing Governance Practice Made Easy</h4>
          <a style="margin-bottom:5px;" class="btn btn-info" href="#">Learn More</a>
          <br><br>
        </div>
      </div>
    </div>
  </div> 
</div>

$(document).ready(function () {
      var xH
      $('.dhiraj').hover(
      function () {
          xH = $(this).children(".imgpos").css("height");
          xH = parseInt(xH);
          xH = xH - 280;
          xH = "-" + xH + "px";
          $(this).children(".imgpos").css("top", xH);
      }, function () {
          $(this).children(".imgpos").css("top", "0px");
      });
  });

I need help making this work properly and look good like the example at (specifically the "A solution for every role" section on the homepage).

If you have any suggestions or solutions, please assist me in achieving the desired result with my current color scheme.

Answer №1

To ensure a smooth CSS Transition, it is important to specify the value for the top property. Without this, the transition effect will not know which starting point to transition from.

In essence, update your code as follows:

.imgpos {
      top: 0px;
      position: absolute;
      transition: all 1s ease-out 0s;
}

If you need further clarification, feel free to ask.

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

Adjusting the size of a Checkbox with CSS

Adjust the width of the checkbox for the call field to 25 pixels, ensuring it is displayed only when the left margin is clear. I'm having trouble figuring this out, even though it's probably something simple again. I double-checked that my style ...

Problem with Bootstrap-slider not loading correctly

I seem to be facing an issue with selecting DOM elements that are part of bootstrap-slider. When I try to target them with events like click, nothing happens. All events work fine when the page is refreshed. What could be causing this problem? $(document ...

Database kendo ui web does not support the implementation of CRUD operations

I have been utilizing the Kendo grid to display employee data and enable create, update, and delete functionalities. While the read operation is functioning properly, I am facing issues with the remaining operations reflecting back to the database. Below ...

Utilizing AJAX to seamlessly transfer id elements to a database

I have the following working code: <script> function displayUserData(str) { if (str=="") { document.getElementById("userDetails").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLH ...

Step-by-step guide to aligning layout using material design in generator-gulp-angular

I am currently using generator-gulp-angular with angular-material-design and ui-router All views are loaded into index.html in the <div ui-view></div> element However, when I attempt to center the element with material design directives insid ...

What is the best method to eliminate whitespace in mobile view when utilizing the <Image /> tag in Next.js?

I am currently developing a website using Next.js. I have used the <Image /> tag to display images on the site. On mobile view, I noticed some white space around the image components, while on desktop everything looks fine. Upon checking the network ...

Delete Entries in MongoDB Collection According to Unique User Pairs

I have a collection of messages stored in MongoDB and I need to keep only the latest 500 records for each pair of users. Users are identified by their sentBy and sentTo attributes. /* 1 */ { "_id" : ObjectId("5f1c1b00c62e9b9aafbe1d6c&quo ...

Tips for connecting a webpage from a specific date

Is it possible to create a link using a date picker for a specific date, such as today's date being 25/2/2015? If something is updated on a page and someone clicks on that date (e.g. 25/2/2015) in the future, how would they be able to view that page? ...

Leverage the power of AJAX for fetching data from a database in Node.js

As I am utilizing Node.js as the server and Mysql as the database to store logged in usernames, I am curious if it is possible to use AJAX to execute a SQL database query and retrieve a list of usernames. More precisely, I am interested in using XMLHttp r ...

Google Apps Scripts implementation functions successfully in Postman but encounters issues when accessed from JavaScript code

Having created a script for a Google Sheet in Apps Script, I defined it as follows: function doPost(e) { var app = SpreadsheetApp.getActive(); var sheet = app.getSheetByName('Web'); var content = JSON.parse(e.postData.contents) sheet.get ...

JavaScript overlay that does not interact with HTML elements directly

Currently, I am facing the challenge of implementing a javascript overlay upon page load without direct access to the html code. My only options are to upload .js and .css files. I have extensively searched for solutions, but as someone with limited exper ...

Validation of forms - Must include one particular word from a given set

I am in the process of utilizing Javascript to validate an input field with the specific formatting requirements outlined below: "WORD1,WORD2" The input must contain a comma separating two words, without any spaces. The first word (WORD1) can be any word ...

What is the best way to share an array from a component to App.js in React?

I've been experimenting with using an array of "components" in my App.js file, where the array is initially set in the Sidebar.jsx component. Sidebar.jsx : import ... const Sidebar = () => { ... const apps = [ // name - how it appears on the ...

When the mouse is clicked, the character fails to reach the intended destination or moves in the wrong direction on the HTML canvas

UPDATE: RESOLVED I am currently working on a game where the character moves by right-clicking. The character is meant to walk slowly, not teleport, towards the destination set by right-clicking on the canvas. However, I have encountered an issue where the ...

Using Javascript to dynamically swap images within a div as the user scrolls

Can someone help me achieve a similar image scrolling effect like the one on the left side of this website: I am looking to change the image inside a div as I scroll and ensure that the page doesn't scroll further until all the images have been scrol ...

Learn how to utilize the getElementByClassName method in JavaScript to insert checkboxes into two lists that share the same class name

I have a situation where I have two lists sharing the same class name. I need to dynamically create checkboxes in both of these lists based on XML data. My current dilemma lies in how to properly utilize getElementByClassName in JavaScript to add checkbox ...

Tips for implementing a hover effect on the background color of a Bootstrap navbar

I am having trouble changing the background color of links and social media icons when hovering over them. I've tried multiple solutions found through searching, but none seem to work for me. Could someone please assist me with this issue? Thank you! ...

Troubleshooting an issue with dynamically inserted attributes in jQuery

I am currently implementing jqueryMobile: <div id="header"> <h1>content</h1> </div> However, in my .js file: $("#header").attr("data-role","header"); This does not seem to work. But if I manually add the attribute like this: ...

ajax.php form connected to a database using php

Introduction: I am currently working on a server-side datatables library. The code snippet below is not displaying either $stmt or $row, making it difficult to identify the issue. It's frustrating because I was hoping to troubleshoot this without see ...

The carousel spun around, each section moving to the side on its own

One issue I'm facing is that on my page, I have multiple carousel rows. However, when I click on the "next" or "prev" button to navigate through the items in the carousel, it affects all carousels instead of just the one I clicked on. I've attem ...