aqua.77 Posted November 18, 2016 Report Share Posted November 18, 2016 Сделал выпадающее меню. Всё работает, меня только один вопрос интересует: всё ли корректно, может ли данный код считаться хорошим? <ul class="q1"> <li class="q2"> <a href="#">123</a><ul class="q3"><li><a href="#">111</a></li><li><a href="#">222</a></li><li><a href="#">333</a></li></ul> </li> <li class="q2"><a href="#">123</a><ul class="q3"><li><a href="#">111</a></li><li><a href="#">222</a></li><li><a href="#">333</a></li></ul></li> </ul> * { box-sizing: border-box; margin:0; padding:0; } .q1{ margin-left:40px; margin-top:50px; border:1px black solid; text-align:center; } .q2{ display:inline-block; position:relative; vertical-align:top; z-index:1000; overflow:hidden; height:42px; transition:all 1s; width:17%; } .q2 a{ display:inline-block; text-decoration:none; padding:12px 0px; width:100%; text-align:center; background:black; } .q3{ position:absolute; top:-90px; right:0; width:100%; transition:all 1s; z-index:-1; } .q3 li{ display:block; } .q3 a{ display:inline-block; padding:12px 0px; width:100%; text-align:center; background:red; margin-bottom:3px; } .q2:hover .q3{ top:45px; } .q2:hover{ height:177px; } .q3 li:last-child a{ margin-bottom:0; } Quote Link to comment Share on other sites More sharing options...
wwt Posted November 18, 2016 Report Share Posted November 18, 2016 Лучше оформляйте код в песочнице, к примеру тут https://jsfiddle.net/ Quote Link to comment Share on other sites More sharing options...
aqua.77 Posted November 18, 2016 Author Report Share Posted November 18, 2016 On 11/18/2016 at 7:09 AM, wwt said: код в песочнице Expand Та так удобнее https://jsfiddle.net/nduyuhbr/. Я первый раз попробовал сделать резиново-выпадающее меню, и есть ощущение что что-то сделал не корректно Quote Link to comment Share on other sites More sharing options...
wwt Posted November 18, 2016 Report Share Posted November 18, 2016 у вас вложенные UL растягивают главный список по вертикали при выезжании, это значит что контент под меню будет смещаться вниз. Я не знаю может так и было задумано, но мне кажется выпадашки не должны смещать контент. 1 Quote Link to comment Share on other sites More sharing options...
aqua.77 Posted November 18, 2016 Author Report Share Posted November 18, 2016 (edited) On 11/18/2016 at 8:01 AM, wwt said: вложенные UL растягивают главный список по вертикали при выезжании Expand И правда... Я нашел выход обернуть UL и сделать его абсолютно-позицианированным в элементе NAV... q1{ position:absolute; width:100%; top:0;left:0; } nav{ position:relative; margin:50px 0 0 20px; } Но что-то идёт не так. https://jsfiddle.net/zhzhjxo8/ Edited November 18, 2016 by aqua.77 Quote Link to comment Share on other sites More sharing options...
wwt Posted November 18, 2016 Report Share Posted November 18, 2016 Я бы посоветовал делать поверх контента не всё меню, а только выпадающие ul Quote Link to comment Share on other sites More sharing options...
aqua.77 Posted November 18, 2016 Author Report Share Posted November 18, 2016 On 11/18/2016 at 9:33 AM, wwt said: делать поверх контента не всё меню, а только выпадающие ul Expand Можете в песочнице продемонстрировать? просто я запутался Quote Link to comment Share on other sites More sharing options...
wwt Posted November 18, 2016 Report Share Posted November 18, 2016 что-то типо https://jsfiddle.net/2ohktw18/ 1 Quote Link to comment Share on other sites More sharing options...
aqua.77 Posted November 18, 2016 Author Report Share Posted November 18, 2016 On 11/18/2016 at 10:20 AM, wwt said: что-то типо https://jsfiddle.net/2ohktw18/ Expand Спасибо, буду разбираться Quote Link to comment Share on other sites More sharing options...
aqua.77 Posted November 18, 2016 Author Report Share Posted November 18, 2016 On 11/18/2016 at 8:01 AM, wwt said: у вас вложенные UL растягивают главный список Expand Ваш пример был ясен, но я хотел чтобы подменю плавно выползало и не влияло на нижестоящий контент, ещё и резиновое. В общем вот что я напридумал https://jsfiddle.net/2ohktw18/2/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.