Градиентный текст с помощью CSS
Уважаемые читатели, простите меня, что давно не писал, будем считать что эта статья будет считаться за несколько, потому как это просто гениально!
Смысл прост — оформляем обыкновенный текст как конфетку с помощью css.
Cначала просто посмотрите пример и поймите, что это Вам реально пригодиться!
Принцип этого приема
Принцип по своему прост и гениален, накладываем на ваш текст нужный градиент или текстуру, точно также как и в любом графическом редакторе.
Градиент должен быть прозрачной png картинкой.
Плюсы этого способа
- Минимум графики
- Кросс-браузероность
- SEO(Это ТЕКСТ, а не графика, так что его будут учитывать ПС)
- Опциональнасть (Текст можно легко конфигурировать — менять шрифт, цвет, да что угодно...)
Реализация способа
Пишими текст, к пример заголовок(h1) Вставляем в него блок с нашим будущим градиентом(<span></span>).
<h1><span></span>Привет, Я градиентный текст</h1>
Теперь оформляем текст и самое главное блок.
h1 {
font: bold 330%/100% "Lucida Grande";
position: relative;
color: #464646;
}
h1 span {
background: url(gradient.png) repeat-x;
position: absolute;
display: block;
width: 100%;
height: 31px;
}
К сожалению Internet Explorer ниже седьмого, не признает прозрачность png, исправим это добавив следующий код между тегами <head></head>.
<!--[if lt IE 7]>
<style>
h1 span { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='gradient.png', sizingMethod='scale');
}
</style>
<![endif]-->
К примеру Вас запарило вставлять блок с градиентом(span) в текст, это можно легко исправить с помощью jQuery.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//prepend span tag to H1
$("h1").prepend("<span></span>");
});
</script>
Всё! Всем удачного дня!
По мотивам

Получается неудобно выделять текст
Ну а если это же сделать картинкой или флэшем, то будет удобней?
В IE почему-то каша :/
Спасибо! Полезная статья. А про айфон сильно ;)
Версия IE – 6ая.
Просто этот пример, не весь для ie6, только предпоследний пример для шестого.
Каюсь, не увидел, что написано :)
Великолепно! Способ прост и гениален одновременно.
Гм… автор настолько торопился? Ошибки в тексте достаточно детские :(
А прием интересный.
Да, а я было поверил, что градиент одним css сделан… А тут оказывается еще имэдж нужен.
А вообще, да, неплохой подход, хоть можно применять на произвольный текст одной высоты, с градиентом одного цвета :)
Насчет SEO это вы преувеличиваете. Правильный alt к картинке ничуть не хуже.
Заголовок или alt к картинке, да, Вы чертовски правы :-)
В тему про SEO – не забывайте еще про «серп» (если не используется дескрипшн).
Т.е. если это будет альтом к картинке, на странице результатов не будет этого текста. Иногда это может снижать CRT. :)
В гугле будет, но все равно нельзя сравнивать полноценный текст и альт.
Класс! Спасибо!
Жаль, правда, что не подходит для неоднородного фона…
А за что айфончег-то так?)_
Он под руку попался :-)
Спасибо за статейку. И с iPhon’ом повеселили :)
К слову, на сайтеhttp://ru.ab.lv/ применён приём без использования графики
I just want to mention I am just new to weblog and absolutely loved you’re web blog. Likely I’m planning to bookmark your blog post . You definitely come with awesome articles. Regards for revealing your web page.
You made some decent points there. I looked on the internet for the issue and found most individuals will go along with with your website.
Hello There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll definitely comeback.
I as nicely believe thence , perfectly pent post! .
I really like your writing style, great info, thanks for posting :D. «The superfluous is very necessary.» by Francois Marie Arouet Voltaire.
I believe this site has got very good indited content material blog posts.
I view something truly special in this site.
Hello there! Do you know if they make any plugins to assist with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any please share. Cheers!
In That Respect there r undoubtedly a good deal of details like that to take into consideration
Very interesting details you have observed , appreciate it for putting up. «You bluffed me I don’t like it when people bluff me. It makes me question my perception of reality.» by Andrew Schneider.
I see something really interesting about your website so I saved to bookmarks .
I conceive this website contains some rattling fantastic information for everyone :D. «Believe those who are seeking the truth doubt those who find it.» by Andre Gide.
I do accept as true with all the ideas you’ve offered on your post. They’re very convincing and will definitely work. Nonetheless, the posts are too quick for starters. May you please extend them a bit from next time? Thank you for the post.
Yay google is my king helped me to find this outstanding web site ! . «The most dangerous strategy is to jump a chasm in two leaps.» by Benjamin Disraeli.
I enjoy this site, will definitely arrive back. Make sure you carry on writing high quality posts.
I wasn’t positive exactly where to ask this, i wondered if the author could reply. Your weblog looks brilliant and I wondered what theme and program you used? Any help would be a big help and i would be really greatful as I am within the procedure of beginning a blog comparable to this topic!
hello there and thank you for your information – I have certainly picked up something new from right here. I did however expertise a few technical issues using this web site, since I experienced to reload the web site a lot of times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I’m complaining, but slow loading instances times will sometimes affect your placement in google and can damage your high quality score if advertising and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and can look out for a lot more of your respective intriguing content. Ensure that you update this again soon..
Hello, i think that i saw you visited my web site so i came to “return the favor”.I’m trying to find things to improve my web site!I suppose its ok to use a few of your ideas!!
It is critical to purchase a specialist appropriate the ringing ears before you start getting rid of the idea. The majority of the symptoms of tinnitus will also be indicative of much more serious issues. Also, when the diagnosis just isn’t ringing in ears, then you’ll need to medicate or perhaps address it inside of a diverse way in comparison with you’d probably ears ringing. Most people with buzzing in the ears find getting rid of their particular ailment by making use of sound treatments. There’s a basic test you could concept if perhaps noise treatment method will allow you to cope with your own ringing in ears. Song your current airwaves concerning not one but two areas. You need to notice any noise appear for those who have updated the item involving channels. If your interferance good from your stereo goggles a person’s buzzing in the ears or maybe causes it to become fewer apparent (somewhat markers the idea), then audio treatments will probably help your short lived problem.
Simply wanna remark on few general things, The website style is perfect, the subject matter is very excellent : D.
Thanks for all of your effort on this website. My mum enjoys going through research and it is easy to see why. My partner and i notice all concerning the powerful means you offer both interesting and useful guides through this web site and boost participation from other ones on the point and my princess is certainly discovering a whole lot. Enjoy the rest of the year. You’re the one carrying out a really great job.
very nice post, i certainly love this website, keep on it
I conceive you have remarked some very interesting details , regards for the post.
An exciting blog page publish there mate ! Thanks for posting !
I’ve been absent for some time, but now I remember why I used to love this web site. Thanks, I will try and check back more often. How frequently you update your web site?
Thanks for this terrific post, I am glad I observed this website on yahoo.
I just want to say I am just beginner to blogging and site-building and actually enjoyed you’re page. Very likely I’m going to bookmark your blog . You absolutely come with awesome stories. Thanks a bunch for revealing your web page.
I do agree with all of the ideas you have presented in your post. They are very convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a bit from next time? Thanks for the post.
This blog site is extremely neat! How did you make it ?
I just want to tell you that I am very new to weblog and seriously savored you’re blog site. More than likely I’m planning to bookmark your blog . You actually come with very good posts. Regards for sharing with us your web-site.
I really like your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to design my own blog and would like to know where u got this from. thanks a lot