12 августа 2008 ~ 3720 Комментариев

Динамический css

Browsers-small

При подгонке сайтов до единого вида во всех браузерах, верстальщик использует не один css хак.

Но зачем обычному пользователю с IE получать избыток кода для других браузеров firefox, opera, safari?!

Это проблема легко решается с помощью динамического css.

Первый раз я услышал о динамических css стилях на сайте cms «ModX», но так как эта cms меня не устраивала, я не стал вникать и в динамические стили.

На сегодняшний день существует отличное готовое решение для генерирования динамических css файлов под названием «Conditional-CSS». Оно имеет открытый код и распространяется под лицензией CDDL license.

Приведу пример css кода с использованием «Conditional-CSS»:

[if IE].container {
     height: 100%;
     width: 100%;

     [if IE 7]background: url('ie7.png') no-repeat center center;
     [if lte IE 6]background: url('ie.jpg') no-repeat center center;
}

[if Webkit].container {
     height: 70px;
     width: 400px;
     background: url('webkit.png') no-repeat center 30px;

}

[if Opera].container {
     height: 60px;
     width: 100%;

     background: url('opera.png') no-repeat center 10px;

}

Это работает так — для пользователя, к примеру, браузера opera будет отдаваться код только для браузера опера.

Основные конструкции:

  • [if {!} browser]
  • [if {!} browser version]
  • [if {!} condition browser version]

Поддерживаемые браузеры:

  • IE - Internet Explorer
  • Gecko - Gecko браузеры (Firefox, Camino etc)
  • Webkit - Webkit браузеры (Safari, Shiira etc)
  • Opera
  • IEMac - Internet Explorer для Mac
  • Konq - Konqueror
  • IEmob - IE мобайл
  • PSP - Playstation Portable
  • NetF - Net Front

Ну и конструкции для версии:

  • lt - Ниже
  • lte - Ниже или равно
  • eq - Равно
  • gte - Выше или равно
  • gt - Выше

Conditional-CSS написан на трех языках: PHP, С, С#. Мой выбор конечно падает на родной любимый php.

Более подробно с этой библиотекой вы можете ознакомится на офиц. сайте, ссылка указана ниже.

Пример использования

Официальный сайт «Conditional-CSS»

3720 Комментариев для “Динамический css”

  1. Дмитрий 12 августа 2008 at 16:50 Permalink

    Спасибо, добавим в копилку опыта)
    Полезно.

  2. dip 12 августа 2008 at 20:06 Permalink

    Усложнение по-моему, дополнительные стили для ИЭ прописываются очень легко и без такой заморочки, а во всех остальных можно добиться максимального совпадения…

  3. Алексей 13 августа 2008 at 0:37 Permalink

    спасибо. интересно.
    Только не совсем понял юмор по-поводу «обычного пользователя IE» и «избыток кода для других браузеров».
    В моей практике получается совсем наоборот. Пишеться код для «обычного пользователя для FF, Op, Sa» а потом добавляется «избыток кода» для не совсем «обычных» пользователей IE.

    P.S. Правда, я тут тоже погорячился: «не совсем обычный пользователь IE» – это я про IE6 говорил ;)

  4. Я собственной персоной 13 августа 2008 at 11:56 Permalink

    спасибо. интересно.
    Только не совсем понял юмор по-поводу «обычного пользователя IE» и «избыток кода для других браузеров».
    В моей практике получается совсем наоборот. Пишеться код для «обычного пользователя для FF, Op, Sa» а потом добавляется «избыток кода» для не совсем «обычных» пользователей IE.

    P.S. Правда, я тут тоже погорячился: «не совсем обычный пользователь IE» – это я про IE6 говорил ;)

    Ну это был простой пример.
    К примеру, пользователю IE не нужен хак для сафари, так же как и Safari хак для IE ;-)

  5. marapper 13 августа 2008 at 12:40 Permalink

    Да, вещь отличная. Конечно, можно заморочиться и сделать верстку одинаковой для большего количества браузеров, но это не спасает. И все же двойная ситуация. Абстракция от кроссбраузерной верстки – одновременно плюс, но так же и минус.

  6. jeenart 14 августа 2008 at 2:38 Permalink

    Спасибо. Пригодится.

  7. Sicon 22 августа 2008 at 3:34 Permalink

    ррр… месяц назад то же самое написал на пхп :)

  8. Bart 4 сентября 2008 at 0:07 Permalink

    Неплохая статья, возьму на заметку.
    Кто то сталкивался с отправкой заголовков для CSS файлов?
    (для кеширования документов браузерами)

  9. Chuuuvi 17 октября 2008 at 0:17 Permalink

    Очень много времени трачу на подгонку верстки и дизайна под различные браузеры. Знающие люди, дайте ссылку на какой нибудь полезный архив по хакам и тому подобным вещам, чем сами пользуетесь.

  10. Кос 26 ноября 2008 at 20:02 Permalink

    Очень много времени трачу на подгонку верстки и дизайна под различные браузеры. Знающие люди, дайте ссылку на какой нибудь полезный архив по хакам и тому подобным вещам, чем сами пользуетесь.

    ничем особым не ользуюсь, опытом разве что.

    А статья гут! делаем в моске закладочку ))

  11. Klewer 7 июня 2009 at 18:15 Permalink

    Статье год, а я только что ее нашел, сайт перекосило в эксплорере. В опере и мазиле все ок, нашел эту статью, но пока не понял что к чему в динамических css. пойду искать дальше :) успехов!

  12. Patriott 23 ноября 2009 at 13:03 Permalink

    оперу на помойку! Сначала не понравилась как пользователю, через 3 года как сайтоделателю. В общем лажа полная.

  13. param-pam-pam 3 августа 2010 at 19:01 Permalink

    ерунда! слишком большая заморочка. проще миритьсяс багами

  14. blvl 22 марта 2011 at 5:42 Permalink

    фигня по-моему. костыли только для ie надо применять. остальные браузеры более-менее корректно всё отображают

  15. Иван 7 августа 2011 at 0:01 Permalink

    Обясните подробней как оно работает !!!!
    Что куда закидовать и что где прописовать очень срочно !!!

  16. Columbus Secky 24 февраля 2012 at 14:48 Permalink

    Valuable information. Lucky me I found your website accidentally, and I’m stunned why this twist of fate didn’t happened earlier! I bookmarked it.

  17. Meghann Kuenzi 25 февраля 2012 at 13:01 Permalink

    Many thanks for this article. I’d also like to express that it can become hard while you are in school and just starting out to create a long credit history. There are many learners who are just simply trying to live and have an extended or good credit history can occasionally be a difficult element to have.

  18. Portable Digital Audio Recorders 25 февраля 2012 at 17:28 Permalink

    I’m truly experiencing and enjoying the layout and format of the site. It is just a very easy about the eyes so that it is considerably more enjoyable will appear the following as well as check out more regularly. Do you employ away a new designer to generate your own design? Excellent work!

  19. Best Male Vitamins 25 февраля 2012 at 17:57 Permalink

    Right after researching a few of the weblog posts on your own web site currently, and that i really much like your method associated with blogging and site-building. We saved this for you to my personal save internet site listing and might become looking at again quickly. Please try out my site while efficiently and also let me know what you think.

  20. Consumer Report On Juicers 25 февраля 2012 at 18:15 Permalink

    I must say i appreciate this Scary Network Video game post. I’ve been recently looking around with this! Thank goodness I found that on the search engines. You’ve created our day time! Thanks again.

  21. How to Fall Pregnant 25 февраля 2012 at 18:29 Permalink

    I like that will. An individual handled our cardiovascular!

  22. Moshe Sawallich 25 февраля 2012 at 22:43 Permalink

    Hiya, I am really glad I have found this information. Nowadays bloggers publish just about gossips and internet and this is actually irritating. A good blog with exciting content, this is what I need. Thanks for keeping this website, I will be visiting it. Do you do newsletters? Cant find it.

  23. Alfredo Willegal 26 февраля 2012 at 3:13 Permalink

    Hi dear, me and my mom are also watch humorous movies but after I completed my homework

  24. Tod Joles 26 февраля 2012 at 5:06 Permalink

    I simply want to mention I am beginner to blogging and site-building and honestly savored your blog site. More than likely I’m want to bookmark your blog post . You absolutely come with good stories. Appreciate it for sharing your blog.

  25. Tod Joles 26 февраля 2012 at 5:31 Permalink

    I just want to say I am just new to blogging and definitely liked this web site. Very likely I’m going to bookmark your blog . You actually have perfect articles and reviews. Bless you for sharing your webpage.

  26. Emil Latiker 26 февраля 2012 at 5:34 Permalink

    I simply want to mention I am newbie to weblog and honestly enjoyed you’re page. Almost certainly I’m going to bookmark your blog . You definitely have remarkable well written articles. Thanks a lot for sharing with us your blog.

  27. Wayne Longworth 26 февраля 2012 at 9:30 Permalink

    I just want to tell you that I’m all new to blogging and site-building and actually enjoyed this blog site. Almost certainly I’m planning to bookmark your website . You definitely come with outstanding articles. Kudos for revealing your blog.

  28. Best Home Theater System 26 февраля 2012 at 22:26 Permalink

    I really like in which. You carressed my heart!

  29. Providencia 29 февраля 2012 at 7:02 Permalink

    I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but certainly you are going to a famous blogger if you are not already

  30. Ponce 29 февраля 2012 at 7:04 Permalink

    Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  31. Orozco 29 февраля 2012 at 7:30 Permalink

    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.

  32. Jack 29 февраля 2012 at 7:52 Permalink

    Have you ever considered about adding a little bit more than just your articles? I mean, what you say is valuable and everything. However just imagine if you added some great images or videos to give your posts more, “pop”! Your content is excellent but with images and clips, this site could certainly be one of the best in its niche. Wonderful blog!

  33. Olson 29 февраля 2012 at 7:53 Permalink

    Do you mind if I quote a few of your posts as long as I provide credit and sources back to your webpage? My blog is in the exact same niche as yours and my visitors would genuinely benefit from a lot of the information you provide here. Please let me know if this ok with you. Thank you!

  34. Stewart 29 февраля 2012 at 8:13 Permalink

    Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you helped me.

  35. Kristeen 29 февраля 2012 at 8:25 Permalink

    Spot on with this write-up, I truly think this website needs much more consideration. I’ll probably be again to read much more, thanks for that info.

  36. Joaquina 29 февраля 2012 at 8:28 Permalink

    Hello there, I found your website via Google while searching for a related topic, your site came up, it looks great. I have bookmarked it in my google bookmarks.

  37. Willena 29 февраля 2012 at 10:16 Permalink

    Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but instead of that, this is fantastic blog. A great read. I will certainly be back.

  38. is MaleExtra a Scam 29 февраля 2012 at 13:07 Permalink

    Aren’t getting Scamed purchasing Male Extra

  39. Towanda Zartman 29 февраля 2012 at 15:30 Permalink

    Outstanding slim weight patch,,Most effective slimweight patch,examination of the slim weight patch ,2012 slimweight patch review ,slim weight patchhottestreview,

  40. Buy xrumer list 29 февраля 2012 at 15:40 Permalink

    you’re in reality a excellent webmaster. The web site loading pace is incredible. It seems that you’re performing any distinctive trick. Also, The contents are masterpiece. you might have performed a amazing task on this subject!

  41. Isabel Kemmis 29 февраля 2012 at 15:42 Permalink

    Best slim weight patch,,Most desirable slimweight patch,review of the slim weight patch ,2012 slimweight patch review ,slim weight patchmost innovativereview,

  42. Cheap scrapebox list 29 февраля 2012 at 17:38 Permalink

    undoubtedly like your web website but you require to check the spelling on several of your posts. Several of them are rife with spelling troubles and I locate it extremely troublesome to tell the truth nevertheless I will definitely come back once more.

  43. montre gps cardio 29 февраля 2012 at 17:48 Permalink

    I like this web blog its a master peace ! Glad I found this on google. «Irrationally held truths may be more harmful than reasoned errors.» by Thomas Huxley.

  44. Julia 29 февраля 2012 at 18:17 Permalink

    Thank you so much with regard to giving me an update on this theme on your web site. Please realise that if a fresh post appears or in the event that any changes occur to the current submission, I would be thinking about reading a lot more and learning how to make good using of those tactics you reveal. Thanks for your time and consideration of other folks by making this website available.

  45. black hat seo 29 февраля 2012 at 18:40 Permalink

    Gratitude for building this send! I in reality recognize the no cost information.

  46. disque dur externe ssd 29 февраля 2012 at 21:40 Permalink

    You are my inspiration , I own few web logs and often run out from to brand.

  47. vps hosting 29 февраля 2012 at 23:48 Permalink

    I like the valuable info you provide in your articles. I’ll bookmark your blog and check again here frequently. I’m quite sure I’ll learn lots of new stuff right here! Best of luck for the next!

  48. chaussure de foot 1 марта 2012 at 0:27 Permalink

    Some truly excellent info , Glad I observed this. «The problem with any unwritten law is that you don’t know where to go to erase it.» by Glaser and Way.

  49. camescope hd 1 марта 2012 at 0:31 Permalink

    Hey There. I found your blog the use of msn. That is a really neatly written article. I’ll be sure to bookmark it and come back to learn more of your useful information. Thanks for the post. I will definitely return.

  50. schutzhund obedience training 1 марта 2012 at 0:49 Permalink

    Doo you mind iff I quote a couple of your posts as long as I provide credit and sources back to your website? My website is in the very same area of interest as yours and my visitors would genuinely benefit from some of the information you present here. Please let me know if this okay with you. Many thanks


Оставить комментарий

p-gs astov holika 7265.ru rfbuilder.ru