Динамический css
![]()
При подгонке сайтов до единого вида во всех браузерах, верстальщик использует не один css хак.
Но зачем обычному пользователю с IE получать избыток кода для других браузеров firefox, opera, safari?!
Это проблема легко решается с помощью динамического css.
Первый раз я услышал о динамических css стилях на сайте cms «ModX», но так как эта cms меня не устраивала, я не стал вникать и в динамические стили.
На сегодняшний день существует отличное готовое решение для генерирования динамических css файлов под названием «Conditional-CSS». Оно имеет открытый код и распространяется под лицензией .
Приведу пример 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.
Более подробно с этой библиотекой вы можете ознакомится на офиц. сайте, ссылка указана ниже.

Спасибо, добавим в копилку опыта)
Полезно.
Усложнение по-моему, дополнительные стили для ИЭ прописываются очень легко и без такой заморочки, а во всех остальных можно добиться максимального совпадения…
спасибо. интересно.
Только не совсем понял юмор по-поводу «обычного пользователя IE» и «избыток кода для других браузеров».
В моей практике получается совсем наоборот. Пишеться код для «обычного пользователя для FF, Op, Sa» а потом добавляется «избыток кода» для не совсем «обычных» пользователей IE.
P.S. Правда, я тут тоже погорячился: «не совсем обычный пользователь IE» – это я про IE6 говорил ;)
Ну это был простой пример.
К примеру, пользователю IE не нужен хак для сафари, так же как и Safari хак для IE ;-)
Да, вещь отличная. Конечно, можно заморочиться и сделать верстку одинаковой для большего количества браузеров, но это не спасает. И все же двойная ситуация. Абстракция от кроссбраузерной верстки – одновременно плюс, но так же и минус.
Спасибо. Пригодится.
ррр… месяц назад то же самое написал на пхп :)
Неплохая статья, возьму на заметку.
Кто то сталкивался с отправкой заголовков для CSS файлов?
(для кеширования документов браузерами)
Очень много времени трачу на подгонку верстки и дизайна под различные браузеры. Знающие люди, дайте ссылку на какой нибудь полезный архив по хакам и тому подобным вещам, чем сами пользуетесь.
ничем особым не ользуюсь, опытом разве что.
А статья гут! делаем в моске закладочку ))
Статье год, а я только что ее нашел, сайт перекосило в эксплорере. В опере и мазиле все ок, нашел эту статью, но пока не понял что к чему в динамических css. пойду искать дальше :) успехов!
оперу на помойку! Сначала не понравилась как пользователю, через 3 года как сайтоделателю. В общем лажа полная.
ерунда! слишком большая заморочка. проще миритьсяс багами
фигня по-моему. костыли только для ie надо применять. остальные браузеры более-менее корректно всё отображают
Обясните подробней как оно работает !!!!
Что куда закидовать и что где прописовать очень срочно !!!
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.
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.
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!
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.
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.
I like that will. An individual handled our cardiovascular!
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.
Hi dear, me and my mom are also watch humorous movies but after I completed my homework
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.
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.
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.
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.
I really like in which. You carressed my heart!
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
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!
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.
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!
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!
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.
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.
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.
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.
Aren’t getting Scamed purchasing Male Extra
Outstanding slim weight patch,,Most effective slimweight patch,examination of the slim weight patch ,2012 slimweight patch review ,slim weight patchhottestreview,
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!
Best slim weight patch,,Most desirable slimweight patch,review of the slim weight patch ,2012 slimweight patch review ,slim weight patchmost innovativereview,
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.
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.
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.
Gratitude for building this send! I in reality recognize the no cost information.
You are my inspiration , I own few web logs and often run out from to brand.
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!
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.
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.
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