0

Всем привет! Имеется HTML код:

<div class="opacity-img">
      <div class="container">
        <h1>Evgeniy Sobaka</h1>
        <div class="imgRounded">
          <img class="personPhoto" src="img/iAM.png" />
        </div>
      </div>
    </div>

К нему подключен CSS:

.imgRounded {
  border-radius: 50%;
  width: 300px;
  height: 300px;
  margin: 0 auto;
  overflow: hidden;
  margin-bottom: 20px;
  z-index: 999999 !important;
  opacity: 1 !important;
}

.personPhoto {
  width: auto;
  height: 100%;
  margin: 0 auto;
  margin-bottom: 20px;
  z-index: 999999 !important;
  opacity: 1 !important;
}

.opacity-img {
  background-image: url(img/asphalt.jpg);
  opacity: 1;
  z-index: 2;
  margin: 200px;
  border-radius: 24px;
}

.container {
  padding: 1em;
  background-color: rgb(212, 121, 2);
  border-radius: 24px;
  box-shadow: 4px 4px 8px rgba(28, 29, 28, 0.9);
  opacity: 0.4;
}

Как избежать наложение прозрачности и эффекта от картинки на изображении? Сейчас получается вот так: введите сюда описание изображения

2
  • Может просто не делать фото прозрачным? 23 апр 2022 в 20:34
  • У вас .container opacity: 0.4; , а в контейнере находится картинка: следовательно и картинка прозрачная. Уберите там opacity, и всё 23 апр 2022 в 21:19

2 ответа 2

0

.opacity-img {
  background-image: url(img/asphalt.jpg);
  margin: 200px;
  border-radius: 24px;
  position: relative;
}

.opacity {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 24px;
  opacity: 0.4;
  z-index: -1;
}

.container {
  padding: 1em;
  background-color: rgba(212, 121, 2, 0.4);
  border-radius: 24px;
  box-shadow: 4px 4px 8px rgba(28, 29, 28, 0.9);
  z-index: 1;
}

.personPhoto {
  border-radius: 50%;
  width: 300px;
  height: 300px;
  cursor: pointer;
}
<div class="opacity-img">
  <div class="opacity"></div>
  <div class="container">
    <h1>Evgeniy Sobaka</h1>
    <div class="imgRounded">
      <img class="personPhoto" src="img/iAM.png" alt="photo" />
    </div>
  </div>
</div>

Можно добавить и стилизовать отдельный див.

0

Использова RGBA, указал в нем прозрачность для цвета:

  .personPhoto {
  border-radius: 50%;
  width: 300px;
  height: 300px;
  opacity: 1 !important;
  z-index: 9999 !important;
}

.opacity-img {
  background-image: url(img/asphalt.jpg);
  opacity: 1;
  margin: 200px;
  border-radius: 24px;
}

.container {
  padding: 1em;
  background-color: rgba(212, 121, 2, 0.4);
  border-radius: 24px;
  box-shadow: 4px 4px 8px rgba(28, 29, 28, 0.9);
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.