Jump to content
  • 0

Не работает vertical-align


Torawhite
 Share

Question

Здравствуйте! Столкнулся с такой проблемой: vertical-align отказывается работать - при установке значения "middle" выравнивает по верхнему краю, не могу понять почему... Возможно, сталкивался кто-то?

HTML:

<div id="menu">
        <a title="Главная страница" href="http://www.torawhite.ru/" target="_self" id="home"></a>
        <a href="#" target="_self" id="magazine">ЖУРНАЛ</a>
        <a href="#" target="_self" id="market">МАРКЕТ</a>
        <a href="#" target="_self" id="more">ЕЩЕ</a>
    </div>

 

CSS:

#menu {
    position: absolute;
    height: 30px;
    width: 268px;
    bottom: 5px;
    left: 0px;
    }

#menu a {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    background-size: contain;
    border-right: 1px solid #FFFFFF;
    cursor: pointer;
    font: 14px ProximaNova-Reg, Verdana;
    text-decoration: none;
    color: #FFFFFF;
    }

#menu a:hover, #menu .active_menu {
    background-color: #BF1238;
    background-size: contain;
    }


#home {
    position: absolute;
    background: url(http://www.torawhite.ru/images/main.svg) no-repeat;
    left: 0px;
    width: 30px;
    height: 30px;
    }

#magazine {
    position: absolute;
    left: 31px;
    width: 90px;
    height: 30px
    }

 #market {
    position: absolute;
    left: 122px;
    width: 84px;
    height: 30px;
    }

#more {
    position: absolute;
    left: 207px;
    width: 60px;
    height: 30px;
    }

Edited by Torawhite
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  On 12/7/2014 at 3:39 PM, npofopr said:

из-за position: absolute; для ссылок не работает.

Вообще не понятно зачем оно там.

Как вариант, пользуйтесь line-htight: высота ссылки;

line-htight: поднимает только выше за границу ячейки

  On 12/7/2014 at 3:39 PM, npofopr said:

из-за position: absolute; для ссылок не работает.

Вообще не понятно зачем оно там.

Как вариант, пользуйтесь line-htight: высота ссылки;

Без position разве можно как-то позиционировать эти ссылки?

Link to comment
Share on other sites

  • 0
  On 12/7/2014 at 4:19 PM, Torawhite said:
Без position разве можно как-то позиционировать эти ссылки?
Что? Вы вообще представляете, что такое таблица? Я вообще не понимаю, зачем вы абсолюты туда навтыкали. 
Link to comment
Share on other sites

  • 0
  On 12/7/2014 at 4:22 PM, npofopr said:

 

  On 12/7/2014 at 4:19 PM, Torawhite said:
Без position разве можно как-то позиционировать эти ссылки?
Что? Вы вообще представляете, что такое таблица? Я вообще не понимаю, зачем вы абсолюты туда навтыкали. 

 

Представляю, но если убрать position:absolute, то ячейки прилипают к левому краю блока. Это же ссылки, которые представлены в виде табличной ячейки, а не цельная таблица.

  On 12/7/2014 at 4:22 PM, npofopr said:

 

  On 12/7/2014 at 4:19 PM, Torawhite said:
Без position разве можно как-то позиционировать эти ссылки?
Что? Вы вообще представляете, что такое таблица? Я вообще не понимаю, зачем вы абсолюты туда навтыкали. 

 

Спасибо, что натолкнули на верный путь! Выставил у блока #menu display:table и убрал у ссылок position:absolute и left - всё стало по центру!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Обсуждения

    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com Портфолио https://www.behance.net/d4d4186e Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ    
    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com   Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ   Портфолио https://www.behance.net/d4d4186e
    • Доброго всем времени суток. Прошу помощи. Научите принципу изменения футера. Движок Xenforo. Версия 2.2.10. Стиль дефолтный. Что именно нужно в итоге на фото примере. Мой шаблон app.footer less имеет следующее значение.  .p-footer { .xf-publicFooter(); a { .xf-publicFooterLink(); } } .p-footer-inner { .m-pageWidth(); .m-pageInset(); padding-top: @xf-paddingMedium; padding-bottom: @xf-paddingLarge; } .p-footer-row { .m-clearFix(); margin-bottom: -@xf-paddingLarge; } .p-footer-row-main { float: left; margin-bottom: @xf-paddingLarge; } .p-footer-row-opposite { float: right; margin-bottom: @xf-paddingLarge; } .p-footer-linkList { .m-listPlain(); .m-clearFix(); > li { float: left; margin-right: .5em; &:last-child { margin-right: 0; } a { padding: 2px 4px; border-radius: @xf-borderRadiusSmall; &:hover { text-decoration: none; background-color: fade(@xf-publicFooterLink--color, 10%); } } } } .p-footer-rssLink { > span { position: relative; top: -1px; display: inline-block; width: 1.44em; height: 1.44em; line-height: 1.44em; text-align: center; font-size: .8em; background-color: #4682B4; border-radius: 2px; } .fa-rss { color: white; } } .p-footer-copyright { margin-top: @xf-elementSpacer; text-align: center; font-size: @xf-fontSizeSmallest; } .p-footer-debug { margin-top: @xf-paddingLarge; text-align: right; font-size: @xf-fontSizeSmallest; .pairs > dt { color: inherit; } } @media (max-width: @xf-responsiveMedium) { .p-footer-row-main, .p-footer-row-opposite { float: none; } .p-footer-copyright { text-align: left; padding: 0 4px; // aligns with other links } }  
    • Нужны сайты с примерами верстки, типа https://css-tricks.com/. Типовые приемы и нестандартные на все случаи жизни. Накидайте ссылок.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy