无法覆盖某些默认图片属性

时间:2020-08-03 10:48:39

标签: html css flexbox

我有一个卡身,并且卡身内,我想要一张封面图片和顶部,那张照片的作者的姓名和照片,但现在,作者图片太大了,几乎无法覆盖整个卡身遮盖了卡片背景图像。如何将作者图片缩小到30x30px左右。现在是160x160px。

<div key={photo.id} className="grid__item card">
        <div className="card__body">
          <img
            src={photo.urls.small}
            alt=""
            onClick={() => setModalIsOpen(true)}
          />
          <div className="card__footer media">
            <img
              src={photo.user.profile_image.small}
              alt=""
              width="30px"
              className="media__obj"
            />
            <div className="media__body">
              <a href={photo.user.portfolio_url} target="_blank">
                {photo.user.name}
              </a>
            </div>
          </div>
        </div>
      </div>

css

.grid__item {
  margin: 0 10px 20px;
  flex: 1 1 290px;
}

.card {
  background-color: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  line-height: 0;
  cursor: pointer;
  position: relative;
}

.card:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.card__body {
  width: 100%;
  height: 215px;
  overflow: hidden;
  background-color: #eee;
  position: relative;
  display: flex;
}

.card__body img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__footer {
  position: absolute;
  bottom: 5px;
  width: 100%;
  padding: 10px 15px;
  display: flex;
  flex-direction: row;
}

.media__obj {
  width: 5px;
  height: 20px;
  border-radius: 50%;
  background-color: #d8d8d8;
  margin-right: 15px;
  background-size: contain;
}

.media__body {
  width: 100%;
  height: 20px;
  line-height: 32px;
  font-size: 12px;
}

.media__body a {
  font-family: Courier, serif;
  font-size: 15px;
  color: #000;
  text-decoration: none;
}

.media__body a:hover {
  text-decoration: none;
}

0 个答案:

没有答案