css - My elements in a menu seem to have no width? -
see codepen demo
edit of course, hard coding width element no solution. should size of actual title.
html
<br/> <nav class="navigation"> <div class="navfake"></div> <div class="singleelement"> <div class="container"> <div class="title">test title 2</div> <div class="titlepicture">some picture</div> </div> </div> <div class="singleelement"> <div class="container"> <div class="title">test title newsfeed super long 1</div> <div class="titlepicture">some picture</div> </div> </div> </nav>
css
/** newsfeed , footer */ nav { width: 100%; height: 20px; position: relative; } .navfake { width: 100%; height: 100%; background: green; z-index: 10; position: relative; } .singleelement { display: inline-block; height: 60px; text-align: center; } .container { position: absolute; top: 0px; -webkit-transition: .8s ease; -moz-transition: .8s ease; -ms-transition: .8s ease; -o-transition: .8s ease; transition: .8s ease; height: 200px; } .titlepicture { position: absolute; width: 100%; background-color: red; z-index: 10; height: 100px; overflow: hidden; } .container:hover { top: -80px; } .container:hover .titlepicture { height: 100px; z-index: 10; } .title { z-index: 555; position: relative; height: 20px; width: 100%; } .footer { position: relative; z-index: 1000; background-color: white; }
the trick replace position absolute position relative
html
<nav class="navigation"> <div class="navfake"></div> <div class="singleelement"> <div class="container"> <div class="title">test title 2</div> <div class="titlepicture">some picture</div> </div> </div> <div class="singleelement"> <div class="container"> <div class="title">test title newsfeed super long 1</div> <div class="titlepicture">some picture</div> </div> </div> </nav> <div class="footer">some text blablablablablablabla <br/>some text blablablablablablabla <br/>some text <br/>some text <br/>some text <br/>some text <br/>some text <br/>xxx </div>
css
/** newsfeed , footer */ nav { width: 100%; height: 20px; } .navfake { width: 100%; height: 100%; background: green; z-index: 10; position: relative; } .singleelement { display: inline-block; height: 60px; text-align: center; position: relative; } .container { top: -20px; position: relative; /**changed*/ -webkit-transition: .8s ease; -moz-transition: .8s ease; -ms-transition: .8s ease; -o-transition: .8s ease; transition: .8s ease; height: 200px; } .titlepicture { position: absolute; background-color: red; z-index: 10; height: 100px; overflow: hidden; } .container:hover { top: -80px; } .container:hover .titlepicture { height: 100px; z-index: 10; } .title { z-index: 555; position: relative; height: 20px; width: 100%; } .footer { position: relative; z-index: 1000; background-color: white; }
Comments
Post a Comment