What is the best way to add a gradient color to the bottom of your content?

Seeking assistance in replicating the unique UI design featured in the image below, taken from a course description section on udemy.com. The goal is to create a gradient effect on specific parts of the content, similar to what is shown in the image.

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

To experiment with this design, I have set up a code sandbox where I am working: https://codesandbox.io/s/fervent-einstein-doeql?file=/src/Demo.js. My current focus is on applying this same UI style to a content card using material-ui. Below is my Demo.js file containing the definition for the card content:

import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import CardMedia from "@material-ui/core/CardMedia";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";

const useStyles = makeStyles({
  root: {
    maxWidth: 345
  }
});

export default function ImgMediaCard() {
  const classes = useStyles();

  return (
    <Card className={classes.root}>
      <CardMedia
        component="img"
        alt="Contemplative Reptile"
        image="https://images.unsplash.com/photo-1503803548695-c2a7b4a5b875?ixlib=rb-1.2.1&w=1000&q=80"
        title="Contemplative Reptile"
      />
      <CardContent>
        <Typography gutterBottom variant="h5" component="h2">
          Lizard
        </Typography>
        <Typography
          className="content"
          variant="body2"
          color="textSecondary"
          component="p"
        >
          // Content details here
        </Typography>
      </CardContent>
      <div className="button">
        <Button size="small">Read more</Button>
      </div>
    </Card>
  );
}

In addition, here is my styles.css file for additional styling:

.content {
  max-height: 100px;
}

.content:hover {
  max-height: none;
}

.button {
  display: flex;
  margin-top: 5px;
  justify-content: flex-end;
  width: 100%;
  background-color: grey;
}

Any support or guidance on achieving this design would be highly appreciated. Thank you! 🙂

Answer №1

It's unclear to me what the question is asking. When I tested the code in the sample sandbox, it seemed to expand when hovered over. Have you been able to find a solution?

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

`After compilation, the Material UI component `theme.spacing` was not found in the definition

Currently, I am developing a text editor using Material-UI and draft.js, where the functionality is enclosed in Material-UI components. I have been comfortably working with version ~3.9, but for this specific project, I decided to upgrade to 4.0. Although ...

Tips for positioning buttons in a row below dynamic text using Bootstrap 3

Is there a way to align buttons under a variable piece of text in Bootstrap 3? Currently, when the code example is viewed in full screen, the three buttons do not align horizontally. Current Behavior: https://i.sstatic.net/lEQ7o.png My goal is to have t ...

What is the best way to remove "autocomplete= off" from JavaScript?

Struggling with using selenium to remove the autocomplete = off attribute. This code snippet is causing me some trouble. input type=text id=searchInput autocomplete = off placeholder="输入城市名称、拼音查询天气"><span cla ...

React Tinymce Editor losing content after Drag and Drop and failing to regain focus

Currently utilizing the following packages: react-beautiful-dnd, tinymce-react Below is the complete implementation. The goal is to arrange the Tinymce Editor using drag and drop functionality. The default content of the editor is obtained from the list c ...

Retrieving information from Firebase after updating it

My goal is to automatically navigate to a specific ID after adding an item to my realtime database. Despite following the documentation's proposed solution, I am encountering issues with its implementation. Following the use of the push().set() meth ...

JS backbone require global models in js

I am looking to implement a UserSession model that will handle loading and saving session IDs into cookies using the jQuery cookie plugin. Below is the code for my UserSession model module: define(['jQuery', 'Underscore', 'Backbo ...

Ensure that each child li in the responsive dropdown menu has a width equal to the longest

Hello! I am currently working on a responsive dropdown menu and have a question regarding the width of the child li elements. Is it possible to make all the child li elements have the same width as the longest child li element? If so, what do I need to cha ...

Angular - custom font styles for ui grid

I recently added "angular" and "angular-ui-grid" to my app and made sure to include the necessary files: angular.min.js ui-grid.min.js ui-grid.min.css Although the table is displaying properly, the arrows in the row header show up as "Korean symbols." D ...

Using external URLs with added tracking parameters in Ionic 2

I am looking to create a unique http link to an external URL, extracted from my JSON data, within the detail pages of my app. Currently, I have the inappbrowser plugin installed that functions with a static URL directing to apple.com. However, I would lik ...

Is it possible to access a comprehensive list of URLs required to download packages from the node modules?

After cloning a project and running npm install, I am interested in obtaining a comprehensive list of all the URLs used to download the files. Is there a method to retrieve this list? ...

Issues with the execution of Jquery functions

My website is currently running on the latest version of Jquery, but I am experiencing two issues: Upon initially loading the site, the content slider displays correctly. However, if you navigate to another page and then return, the slider fails to load ...

The "useState" React Hook is restricted from being used in a class component. To utilize React Hooks, they can only be invoked within a React function component or a custom React Hook function

I am relatively new to React frontend development and I am currently working on adding a temporary drawer to my Material-UI NavBar. Here is the code snippet where I added the drawer: class Navbar extends Component { render() { const { authentic ...

Problem with Pinia: nested array in an object

My unique store located within a vue3 application, contains an object called currentReservation with a property named pricings which is an array. Each pricing includes an id and quantity. When I add a new pricing, it is added to both the store and compone ...

The resolution of the images in jspdf is unsatisfactorily low

Hello there! I've been working on a ReactJs project and using the jsPDF package to generate PDFs. However, I've been facing an issue with image quality when adding images to the PDF. I've checked the base64 code for the image and it seems f ...

Unable to update to the most recent version of React-Bootstrap

I'm facing an issue while trying to upgrade to the newest version of react-bootstrap. When I run: npm install --save react-bootstrap The following message appears: npm notice created a lockfile as package-lock.json. You should commit this file. npm ...

Need help triggering Ajax code upon clicking a link?

Can someone help me find the issue with my script? Below is the code snippet: <script> $(".icross").click(function(e){ e.preventDefault(); var obj = $(this); $.ajax({ type: "GET", url: "supprimer.php", data: 'id=&a ...

Is there a way to identify the specific Struts action being rendered in my JSP file?

One thing I am struggling with is creating a menu that highlights the current page when navigating through my site. For example, if I am on Page 1, I want the "Page 1" link in the menu to stand out. I have been attempting different methods found on Stack O ...

Exploring the process of integrating and registering local components within the App.vue file

Currently, I am working with Laravel 10, Vite, and Vue I would like to incorporate two components into my App.vue file Below is the content of my App.vue file : <template> <div> <AppHeader></AppHeader> ...

Observing an array being stored in Vuex within a VueJS application

I currently have a list of customers stored as an array of objects in Vuex. When rendering this list in my component, each row includes a checkbox using Keen-UI: <tr v-for="customer in customers" :class="{ selected: customer.selected }"> <td ...

Is there a way to adjust the quantity of items in the shopping cart without the need to reload the webpage?

Currently, I am working on a test project using React & Redux. The project involves implementing a basket feature where I receive an array of products structured like this: products: [ { name: "Product one", count: 1, ...