Рубрика: HTML


CSS хаки для Internet Explorer

Продолжаем изучение хаков для Internet Explorer. Занимаясь html версткой приходится сталкиваться с багами IE. Появляется необходимость задания дополнительных инструкций CSS. Такие инструкции часто называют хаками. Вот примеры инструкций для IE свойства height:

* height: 10px; /* этот CSS хак увидит только IE */

_height: 10px; /* эту инструкцию воспримут только IE 5.5 и IE 6.0 */

_heig\ht: 10px; /* а этот CSS хак увидит только IE 6.0 */ 

Примеры хаков IE для свойства display:


_display: none;

_disp\lay: block; /* только IE 5.5 не отобразит блок */ 

На самом деле CSS хаки это плохо, так как код не проходит валидацию. Если Вам хочется, чтобы код был валидным, используйте условные комментарии.

Originally posted 2010-05-13 15:07:17. Republished by Vancouver Web Design

Футер всегда внизу

Нередко, мне дают задание на верстку дизайна, и в техническом задании указывают, что футер сайта всегда должен быть привязан к низу. Оно и правильно… не очень красиво смотрится, когда на сайте мало контента, и футер съезжает вверх. Не знаю как у кого, но у меня несколько раз возникали с этим проблемы.

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

Все очень просто… итак… приступим.

Созадем главный блок (class=”main”) и внутрь его помещаем еще два блока с контентом (class=”content”) и футером (class=”footer”).

<div class=”main”>
<div class=”content”></div>
<div class=”footer”></div>
</div>

Теперь рассмотрим CSS

html, body {
margin:0; /*убираем отступы у документа, внешние…*/
padding:0; /*…и внутренние*/
height:100%; /*устанавливаем документу высоту в 100%*/
}

.main {
width:100%; /*устанавливаем ширину главного блока…*/
min-height:100%; /*…и минимальную высоту (для Opera и FireFox)*/
position:relative; /*позиционируем блок относительно*/
}

.content {
padding: 0 0 85px 0; /*устанавливаем отступ снизу для контента, чтобы блоки при заполнении не наезжали друг на друга*/
}

.footer {
position:absolute; /*позиционируем блок абсолютно…*/
bottom:0; /*…снизу*/
width: 100%; /*устанавливаем ширину футера*/
height:85px; /*устанавливаем высоту футера*/
}

Вот и все :) … Ага… чуть не забыл… хак для родного IE…
Внутри тега head прописываем строчку
<!–[if lt IE 7]><style media=”screen” type=”text/css”>.main {height:100%;}</style><![endif]–>

Теперь точно все.

Футер всегда внизу

Originally posted 2010-02-01 15:15:45. Republished by Vancouver Web Design

Safari CSS хак

Для того чтобы определенное правило обрабатывалось только в Safari используем следующее хак


@media screen and (-webkit-min-device-pixel-ratio:0)

{
#div {margin-left: 10px;}
}

другой пример

<code>@media screen and (-webkit-min-device-pixel-ratio:0) {
 .b-hat .b-login-box .b-field input {
 width: 110px;
 }
 }</code>
<code>

У кого какие идеи по этой теме оставляем в коментах.

Originally posted 2011-03-14 23:12:00. Republished by Vancouver Web Design

Закрукругление углов используя только CSS

Закругление углов?
Нет ничего проще.

1. Скачиваем htc файл сдесь.
2. Загружаем его в папку images.
3. В css файле создаем класс

.curved { 

-moz-border-radius:10px; / Firefox /
-webkit-border-radius:10px; / Safari and chrome /
-khtml-border-radius:10px; / Linux browsers /
border-radius:10px; / CSS3 /
behavior:url(images/border-radius.htc);

}

4. Присваиваем html элементам класс .curved, чтобы сделать углы у них закругленными.

Замечания

1. Путь к .htc файлу должен быть относительно документа не css файла
2. Хак не работает с элементами формы.
3. Дополнительный материал для самообразования:

  • Border Radius in IE | San’s Bits and Bobs …
  • Anonymous
  • CSS3 goodies and their browser equivalents | Myk.be
  • CSS3 border-radiusを使った角丸を実現 | solo.design
  • GetHtmlCss CSS3 support in Internet Explorer 6, 7, and 8
  • Web Programming: Curved boxes in CSS « Let’s share and win the challenge of life
  • delicious Links: 14. December 2010 | miZine
  • Soluții CSS3 pentru Internet Explorer | Tutoriale
  • lifeisbetter.in » Blog Archive » Best “Rounded Corner” solutions that might just fit into your projects.
  • CSS: Rounded Corners in IE without any special Javascript?
  • CSS3 – What a beginner web designer must know. | Capability , .
  • How to use border-radius.htc with IE to make rounded corners | DeveloperQuestion.com
  • Border-radius.htc – problem z IE | Inside the Web
  • Getting CSS3 properties to render in IE6, IE7, and IE8 using a simple script. | Rumbrook Studio
  • Ombrages et arrondies avec CSS3 pour IE6, IE7 et IE8 « Bugz.fr : Un jour un bug, un bug une solution. Blog geek et high tech spécialisé dans l’informatique, le développement et le web.
  • Gambiarras para o IE simular CSS3 | Renato Gomes’ Blog
  • Turning Point » Blog Archive » Internet Explorer 6, 7, and 8에서 CSS3 속성유지하기
  • Getting border-radius to work in IE | jc-designs.net
  • Marcelo Torres – Web Designer Freelancer e WordPress Theme Developer
  • CSS3 Solutions for Internet Explorer | Code Base
  • IE8 is not very nice – pay attention here!

    I learned something while doing this. IE8.0.6 and IE8.0.76 handle this differently. First, the element with this property on it should be positioned to relative. If you have text on top of it, then that will have to be wrapped in something and also positioned relative. Example:

    <div><p>This is the text that goes on top of the rounded corners div</p></div>

    If you did this:

    <div>This is the text that goes on top of the rounded corners div</div>

    Then IE8.0.76 doesn’t play nice. IE8.06 however will work fine. I have NO idea why, but that is how it is.

    Originally posted 2011-04-09 08:08:57. Republished by Vancouver Web Design

    CSS хаки

    Список css хаков:

    
    .class { background: white } /* Для оперы и прочего */
     html*.class {
     background: yellow !important; /* IE 7 */
     background: gray; /* IE6 */
     }
     html:root .class { background: green; } /* FF */
     html:root*.class { background: red !important; } /* Safari */
    
    @-moz-document url-prefix() {
     .style {background: #F00;}
     } /* FF */
    

    Originally posted 2011-03-14 23:38:06. Republished by Vancouver Web Design