コンテンツの最後にグラデーションカラーを適用するにはどうすればよいですか?[複製]

Aug 18 2020

以下に追加した画像UI(udemy.comコースの説明セクションから取得)を複製しようとしています。下の画像に示すように、コンテンツの一部のみに同様のグラデーションUIを作成する方法を探していました。

これが私が実験してきたサンプルコードサンドボックスです https://codesandbox.io/s/fervent-einstein-doeql?file=/src/Demo.js。この正確なUIをmaterial-uiカードのコンテンツに適用しようとしています。これが私Demo.jsがカードの内容を定義しているところです

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"
        >
          Lizards are a widespread group of squamate reptiles, with over 6,000
          species, ranging across all continents except Antarctica Lizards are a
          widespread group of squamate reptiles, with over 6,000 species,
          ranging across all continents except Antarctica Lizards are a
          widespread group of squamate reptiles, with over 6,000 species,
          ranging across all continents except Antarctica Lizards are a
          widespread group of squamate reptiles, with over 6,000 species,
          ranging across all continents except Antarctica Lizards are a
          widespread group of squamate reptiles, with over 6,000 species,
          ranging across all continents except Antarctica Lizards are a
          widespread group of squamate reptiles, with over 6,000 species,
          ranging across all continents except Antarctica Lizards are
        </Typography>
      </CardContent>
      <div className="button">
        <Button size="small">Read more</Button>
      </div>
    </Card>
  );
}

と私 styles.css

.content {
  max-height: 100px;
}

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

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

どんな助けでも大歓迎です。ありがとう🙂

回答

Adam Aug 18 2020 at 18:00

質問を理解できるかどうかわかりません。サンプルコードのサンドボックスを実行すると、実際にはホバーすると展開されます。多分あなたは答えを見つけましたか?