Обводка текста с помощью CSS+JS
Появилась такая задача (передаю привет дизайнеру =)). Как в html сделать обводку текста? После хождения по Интернету, был рожден такой велосипед.
Идея банальна. Берем текст, делаем его копии цветом обводки и абсолютно позиционируем с соответствующими смещениями относительно основного текста. Получился такой код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Обводка текста с помощью css + js</title> <style type="text/css"> body{ padding:100px; background:#09F; color:#000; font-family:Arial, Helvetica, sans-serif; font-size:36px; } .textBorder{ position:relative; z-index:1; } .textBorder strong{ position:relative; z-index:5; } .textBorder span{ position:absolute; z-index:1; top:0; left:0; color:#FFF; font-weight:bold; } /* С помощью значений top и left регулируем толщину обводки */ .textBorder span.b1{top:-3px;} .textBorder span.b2{left:3px;} .textBorder span.b3{top:3px;} .textBorder span.b4{left:-3px;} .textBorder span.b5{top:-2px;left:2px;} .textBorder span.b6{top:2px;left:2px;} .textBorder span.b7{top:2px;left:-2px;} .textBorder span.b8{top:-2px;left:-2px;} </style> </head> <body> <div class="textBorder"> <strong>Привет! Я текст с обводкой!</strong> <span class="b1">Привет! Я текст с обводкой!</span> <span class="b2">Привет! Я текст с обводкой!</span> <span class="b3">Привет! Я текст с обводкой!</span> <span class="b4">Привет! Я текст с обводкой!</span> <span class="b5">Привет! Я текст с обводкой!</span> <span class="b6">Привет! Я текст с обводкой!</span> <span class="b7">Привет! Я текст с обводкой!</span> <span class="b8">Привет! Я текст с обводкой!</span> </div> </body> </html> |
И быстро написанная функция на jquery, чтобы автоматизировать этот процесс:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Обводка текста с помощью css + js</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(document).ready(function (){ var text = $('.textBorder strong').html(); var textinner = '<span class="b1">'+text+'</span>'+'<span class="b2">'+text+'</span>'+'<span class="b3">'+text+'</span>'+'<span class="b4">'+text+'</span>'+'<span class="b5">'+text+'</span>'+'<span class="b6">'+text+'</span>'+'<span class="b7">'+text+'</span>'+'<span class="b8">'+text+'</span>'; $('.textBorder').append(textinner); }); </script> <style type="text/css"> body{ padding:100px; background:#09F; color:#000; font-family:Arial, Helvetica, sans-serif; font-size:36px; } .textBorder{ position:relative; z-index:1; } .textBorder strong{ position:relative; z-index:5; } .textBorder span{ position:absolute; z-index:1; top:0; left:0; color:#FFF; font-weight:bold; } /* С помощью значений top и left регулируем толщину обводки */ .textBorder span.b1{top:-3px;} .textBorder span.b2{left:3px;} .textBorder span.b3{top:3px;} .textBorder span.b4{left:-3px;} .textBorder span.b5{top:-2px;left:2px;} .textBorder span.b6{top:2px;left:2px;} .textBorder span.b7{top:2px;left:-2px;} .textBorder span.b8{top:-2px;left:-2px;} </style> </head> <body> <div class="textBorder"> <strong>Привет! Я текст с обводкой!</strong> </div> </body> </html> |
Вот и всё. Посмотреть пример
Fatal error: Call to undefined function wp_related_posts() in /home/k/kazanets/htmlcssinfo/public_html/wp-content/themes/htmlcsstheme/single.php on line 70