Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Вёрстка веб-сайтов > Медиа запросы


Автор: s1lver 3.9.2013, 18:33
Доброго времени суток!

Возник вопрос с медиа запросами. Все ли значения применяюся к ним?

Вот этот кусок кода применяет только уменьшение размера шрифта, все остальное игнорирует.
Код

@media screen and (max-width:1060px){
    header h1{
        padding: 15px 0 0 190px;
        width: 250px;
        top: 0;
        text-align: left;
        font-size: 13px;
    }
    header p{
        padding: 0;
        margin: -100px 0 0;
        top: 0;
        text-align: right;
        font-size: 12px;
    }
    header nav {
        display: block;
        padding: 0 0 0 168px;
        margin: 39px 0 0 20px;
        z-index: 1;
    }
}

Подскажите, может я что-то делаю не так...

Автор: JAYBE 2.10.2013, 18:10
Всё так. Только сначала лучше указать общие стили, а потом уже @media. Лучше скину свой пример:
Код

* {
    box-sizing: border-box;
}
body {
    max-width: 960px;
    min-width: 320px;
    width: 90%;
    margin: 1em auto;
    background-color: #DCDBD9;
    color: #2C2C2C;
    font: normal 100% Cambria;
}
.files {
    margin: 0;
    padding: 0;
    list-style-type: none;
}
.files a {
    display: inline-block;
    width: 100%;
    padding-left: 20px;
    line-height: 1.25em;
}
.files a:hover {
    background-color: white;
    color: black;
    min-width: 50%;
}
.directory a {
    background: url("folder_icon.png") transparent left center no-repeat;
}
.file a{
    background: url("file_icon.png") transparent left center no-repeat;
}
#menu {
    border-radius: 1em;
    background-image: -webkit-linear-gradient(top, #474747, #010101);
    background-image: -moz-linear-gradient(top, #474747, #010101);
}
#menu>li {
    margin: 0.5em 0.5em;
    display: inline-block;
}
#menu a {
    color: white;
    font: normal 75% Verdana, Geneva, sans-serif;
}
#menu li:after {
    content: "|";
    display: inline-block;
    margin-left: 1em;
    color: red;
}
#menu li:last-child:after {
    display: none;
}
.clear:after {
    clear: both;
    content: '';
    display: block;
}
@media screen and (max-width: 540px) {
    body {
        font-size: 150%;
        margin: 0;
        width: 100%;
    }
    .menu {
        width: 100%;
    }
    .files a {
        padding: 0;
        line-height: 3.5em;
    }
    .directory a,
    .file a {
        background: none;
    }
    .directory a:before {
        content: 'D:';
    }
    .file a:before {
        content: 'F:';
    }
}
@media screen and (max-width: 960px) {
    .files a {
            line-height: 2em;
        }
}

Автор: s1lver 9.10.2013, 09:06
Что-то все таки не так. Браузер упорно игнорирует смещения, только размер воспринимает  smile 

Автор: AVA12 9.10.2013, 15:33
Я на 145% уверен, что стили для экрана перебиваются более специфичными общими стилями. Для проверки (только для проверки!) добавь к проблемным стилям модификатор !important (например, width: 250px !important;)

Автор: s1lver 17.10.2013, 13:37
Похоже разобрался!  smile 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)