Примените градиентный фильтр яркости к изображению - PullRequest
0 голосов
/ 01 октября 2019

У меня есть серия фотографий, отображаемых в классе начальной загрузки card. Изображения должны иметь белый текст поверх них, поэтому я добавил темный фильтр к фотографиям filter: brightness(60%);, чтобы текст был четким для чтения.

Посмотрите, как изображение выглядит в настоящее время https://i.ibb.co/TTTdrDP/card-image.jpg

Белый текст расположен только внизу фотографий, поэтому я хотел бы применить filter: brightness(60%); только к нижней части изображения и затемнить с нормальной яркостью.

I 'Вы пробовали много форм градиента, но все, что нужно, это применить к фотографии жесткий цвет (полностью удалив фотографию), а не прозрачный (градиентный) фильтр поверх изображения?

Мой CSS

<style>
    .card {
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
        transition: 0.3s;
        width: 100%;
    }

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

    /* Card image dark filter */
    .card-img-top {
        width: 100%;
        height: 220px;
        object-fit: cover;
        filter: brightness(60%);
    }

    /* Align heading text to bottom of photo */
    .bottom {
        position: absolute;
        right: 0;
        left: 0;
        padding: 10px;
        bottom: 0px;
        padding-bottom: 40px;
    }

    .card-footer {
        font-size: 12px;
        font-weight: normal;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        color: grey;
        background-color: #eeeeee !important;
    }
</style>

Имиджевая карта

<div class="card" style="width:100%;">
    <img class="card-img-top" src="PHOTO HERE" alt="Card image">
    <div class="card-img-overlay">
        <div class="bottom text-light">
            <h2>Hiking in Eastbourne for all who want to join.</h2>
        </div>
        <a href="example_group" class="stretched-link"></a>
    </div>
    <div class="card-footer p-2">
        <div class="d-flex">
            <div>
                <i class="fa fa-calendar-alt fa-fw"></i><a>&nbsp</a><a>4th June</a>
            </div>
            <div class="ml-auto">
                <a>3421</a><a>&nbsp</a><i class="fa fa-user-friends fa-fw"></i>
            </div>
        </div>
    </div>
</div>


  [1]: https://i.ibb.co/TTTdrDP/card-image.jpg

1 Ответ

0 голосов
/ 01 октября 2019

Вы имеете в виду что-то подобное?

.card {
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
        transition: 0.3s;
        width: 100%;
    }

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

    /* Card image dark filter */
    .card-img-top {
        width: 100%;
        height: 220px;
        object-fit: cover;
        filter: brightness(100%);
    }

    /* Align heading text to bottom of photo */
    .bottom {
        position: absolute;
        right: 0;
        left: 0;
        bottom: 35px;
        padding-top: 90px;
        padding-left: 10px;
        padding-right: 10px;
        height: 150px;
        background: linear-gradient(to top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
    }
    

    .card-footer {
        font-size: 12px;
        font-weight: normal;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        color: grey;
        background-color: #eeeeee !important;
        /*filter: brightness(100%); */
    }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="card" style="width:100%;">
    <img class="card-img-top" src="https://media-cdn.tripadvisor.com/media/photo-s/0f/3d/89/4d/foto-com-dome.jpg" alt="Card image">
    <div class="card-img-overlay">
        <div class="bottom text-light">
            <h2>Hiking in Eastbourne for all who want to join.</h2>
        </div>
        <a href="example_group" class="stretched-link"></a>
    </div>
    <div class="card-footer p-2">
        <div class="d-flex">
            <div>
                <i class="fa fa-calendar-alt fa-fw"></i><a>&nbsp;</a><a>4th June</a>
            </div>
            <div class="ml-auto">
                <a>3421</a><a>&nbsp;</a><i class="fa fa-user-friends fa-fw"></i>
            </div>
        </div>
    </div>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...