콘텐츠 끝에 그라디언트 색상을 적용하는 방법은 무엇입니까? [복제]

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

질문을 이해했는지 잘 모르겠습니다. 샘플 코드 샌드 박스를 수행하면 실제로 마우스를 올리면 확장됩니다. 답을 찾았나?