У меня есть текст, цвет которого я хочу изменить, поэтому я присвоил ему класс div, donate
Вот так:
<div class = "entry-content">
<div class = "donate"><strong>Adsler.co.uk is an entirely free
site, enabling users to post, view and apply for jobs, post, view
and respond to classifieds, post, view and attend events, in
addition to a dating service. We try to keep Adsler free from Google
ads and the site is maintained entirely at the owners expense.</p>
<p>So, if you have enjoyed using Adsler, or have found it beneficial
in some way, you are free to make a donation, or not – as you
see fit. There is absolutely no obligation or pressure to do so and
you are more than welcome to continue using the site without
donating.</p>
<p>If you do wish to donate, however, then you can donate as much or
as little as you want via the form below.</p>
<p>Wishing you a pleasant day from all at Adsler.co.uk.<br />
</strong></div><p>*N.B. Donating does not give you editorial or any
other rights. All donations are non-refundable. For technical
reasons, the only current donation amount is $5.</strong></div>
Затем я использовал css:
.donate {color: yellow !important;}
Не работает. Что происходит, так это то, что текст мигает желтым на секунду, а затем снова становится черным. Также использовал <strong>
, но только половина текста определяется как strong
, а другая половина — нет.
Страница для уточнения: https://adsler.co.uk/if-you-enjoyed-using-the-site/
Это не удалось, я использовал специфичность.
.entry-content>.donate
{color:yellow! important;}
Ничего.
Да все внутри donate
так что это должно работать нормально для вас: .donate {color: yellow !important;}
. он работал нормально, когда я тестировал его. возможно, есть другой код CSS, который переопределяет это свойство.
я могу добавить ответ с рабочим кодом, но я думаю, что проблема в том, что, возможно, другой код CSS переопределяет это
@kareem, этого не может быть, потому что я употребляю important
вы можете проверить ответ, я проверил его на вашей странице с помощью проверки, и он работал нормально
Ваш HTML-код недействителен. У вас закрытие </p>
без открытия <p>
Вот решение. Весь текст теперь выглядит желтым.
.donate {color: yellow !important;}
<div class = "entry-content">
<div class = "donate">Adsler.co.uk is an entirely free
site, enabling users to post, view and apply for jobs, post, view
and respond to classifieds, post, view and attend events, in
addition to a dating service. We try to keep Adsler free from Google
ads and the site is maintained entirely at the owners expense.
<p>So, if you have enjoyed using Adsler, or have found it beneficial
in some way, you are free to make a donation, or not – as you
see fit. There is absolutely no obligation or pressure to do so and
you are more than welcome to continue using the site without
donating.</p>
<p>If you do wish to donate, however, then you can donate as much or
as little as you want via the form below.</p>
<p>Wishing you a pleasant day from all at Adsler.co.uk.</p><br>
<p>*N.B. Donating does not give you editorial or any
other rights. All donations are non-refundable. For technical
reasons, the only current donation amount is $5.</p></div></div>
Спасибо. Я пробовал это, но 1. Он удаляет strong
и 2, только первая часть текста желтая. См. страницу adsler.co.uk/если-вам-понравилось-использование-сайта
.donate {color: yellow}
должно работать нормально. но как только ваша страница * {color: #000000}
загрузится на вашу страницу, ее цвет переопределит.
вы не можете исправить это, добавив !important
, поэтому у вас есть два варианта:
1- удалить * {color: #000000}
из css
2- добавьте этот css:
.donate, .donate * {
color: yellow
}
.donate *
— изменить цвет на .donate
и все его дочерние элементы.
Это сработало, за исключением того, что последний кусочек по-прежнему черный, начиная с NB
и заканчивая $5
потому что он находится за пределами div .donate
вы закрываете div перед этим текстом, проверьте свой код и оберните этот текст внутри .donate
div
какой именно текст должен быть желтым? весь текст или только то, что внутри
.donate
div ?