CSS height transition with ul not working - css-transitions

I have the following css:
#cssmenu .has-sub .has-sub:hover > ul {
height: 76px;
}
#cssmenu .has-sub .has-sub ul {
height: 0px;
overflow: hidden;
position: inherit;
left: -1px;
top: -1px;
background-color: #999;
transition: height 2s;
-moz-transition: height 2s; /* Firefox 4 */
-webkit-transition: height 2s; /* Safari and Chrome */
-o-transition: height 2s; /* Opera */
}
with this html:
<div id="cssmenu">
<ul>
<li class="active has-sub"><span>Products</span>
<ul>
<li class="has-sub"><span>Product 1</span>
<ul>
<li><span>Sub Product</span></li>
<li class="last"><span>Sub Product</span></li>
</ul>
</li>
<li class="has-sub"><span>Product 2</span>
<ul>
<li><span>Sub Product</span></li>
<li class="last"><span>Sub Product</span></li>
</ul>
</li>
<li class="has-sub"><span>Product 3</span>
<ul>
<li><span>Sub Product</span></li>
<li class="last"><span>Sub Product</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
and I'd when I moving my mouse over Product 1:
the transition just not working. Where I went wrong?
The whole page is available here

Don't hide the child ul you are trying to transition. Set it to display:block (it's height is 0px anyway so you can't see it).
#cssmenu .has-sub ul ul {
display: block;
}
A tidier approach would be to be more specific with your original ul selector and only hide the parent UL, rather than hide all UL's and switch the child back to display: block. You'd need to add another class to hook onto with this approach though:
#cssmenu .top-sub-menu > ul {
display: none;
}

Related

Why isn't my "menu" displaying properly?

I used a layout similar to a menu how it has the main menu and a submenu that appears when you hover over it. In this case, I'm trying to have a "Share" menu with the icons the submenu on the same line. I picked details from http://cssdeck.com/labs/another-simple-css3-dropdown-menu Why isn't my menu hiding/showing properly?
HTML
a {
padding: 4px;
}
i.fa {
color: #8b8b8b;
}
ul {
list-style-type: none;
}
ul li:hover ul {
display: block;
}
ul li ul {
display: none;
padding: 0;
visibility: hidden;
}
ul li ul:hover {
display: block;
}
ul li ul li {
display: inline-block;
}
<ul>
<li style="color: #676767;"> <a style="color: #676767;" href="#"><i class="fa fa-share-alt"></i> Share</a>
<ul class="socialShare">
<li><i class="fa fa-facebook"></i>
</li>
<li><i class="fa fa-twitter"></i>
</li>
<li><i class="fa fa-pinterest"></i>
</li>
</ul>
</li>
</ul>
I ran your code on a separated file, and i detected that your mistake was in the html. I supposed that you want to create on hover effect on the Share, and then show the social networks.. Here's the code of the HTML properly coded.
<ul>
<li>
<a style="color: #676767;" href="#"><i class="fa fa-share-alt"></i> Share</a>
<ul class="socialShare">
<li>
<i class="fa fa-facebook"></i>Facebook
</li>
<li>
<i class="fa fa-twitter"></i>Twitter
</li>
<li>
<i class="fa fa-pinterest"></i>Pinterest
</li>
</ul>
</li>
</ul>
The reason the menu isn't appearing is because the menu <ul> which you are trying to show has visibility: hidden, and that property is not being changed on hover. Since that element already has display: none set (which does get set to block on hover), you can remove the visibility property.
I see that the code in your link has visibility: hidden set but also sets it to visible on hover. This would also correct the problem, but I don't see any reason to have visibility at all on this.
Also, in your particular example, you need some content in the menu <li>s to actually see that it's being shown. See the updated snippet below.
a {
padding: 4px;
}
i.fa {
color: #8b8b8b;
}
ul {
list-style-type: none;
}
ul li:hover ul {
display: block;
}
ul li ul {
display: none;
padding: 0;
/*visibility: hidden;*/ /* Not needed, since there is already display:none*/
}
ul li ul:hover {
display: block;
}
ul li ul li {
display: inline-block;
}
<ul>
<li style="color: #676767;"> <a style="color: #676767;" href="#"><i class="fa fa-share-alt"></i> Share</a>
<ul class="socialShare">
<!-- Need some content in the <li>s -->
<li><a href="https://www.facebook.com/sharer/sharer.php?u=http://test.gpjbaker.com/brands/gp-j-baker/denbury-collection/"><i class="fa fa-facebook">
link a
</i></a></li>
<li><a href="https://twitter.com/home?status=http://test.gpjbaker.com/brands/gp-j-baker/denbury-collection/"><i class="fa fa-twitter">
link b
</i></a></li>
<li><a href="https://pinterest.com/pin/create/button/?url=http://test.gpjbaker.com/brands/gp-j-baker/denbury-collection/&media=&description="><i class="fa fa-pinterest">
link c
</i></a></li>
</ul>
</li>
</ul>

Foundation5 top bar icons and text

I am trying to achieve an iOS kind of look on a Zurb' Foundation 5 top menubar. I would like to have a icon font icon on top and the matching menu description below. Something that would look like this:
This is what I got now:
Having an icon first and following text is trivial with icon fonts:
<div class="contain-to-grid">
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1>Site name</h1>
</li>
</ul>
<section class="top-bar-section">
<ul>
<li class="show-for-medium-up" id="people-menu" data-tooltip data-options="disable_for_touch:true" title="People"><i class="fi-results-demographics"></i> <span class="menu-heading"> option 1 </span></li>
<li id="assets-menu" data-tooltip data-options="disable_for_touch:true" title="Assets"><i class="fi-euro"></i> <span class="menu-heading"> option 2 </li>
<li id="documents-menu" data-tooltip data-options="disable_for_touch:true" title="Documents"><i class="fi-page-edit"></i> option 3 </li>
<li id="services-menu" data-tooltip data-options="disable_for_touch:true" title="Services"><i class="fi-info"></i> Option4 </li>
<li class="divider"></li>
<li id="login-menu" data-tooltip data-options="disable_for_touch:true" title="Sign in"><i class="fi-key"></i> </li>
<li id="logout-menu" data-tooltip data-options="disable_for_touch:true" title="Sign out">Example login <i class="icon-bell color6"></i> </li>
</ul>
</section>
Adding a < br > before the span does not help as it breaks the top bar even if span has zero margin/padding in CSS.
How can I get the icon and text stack up nicely above each other?
You'll need to override a few default Foundation styles, but it's definitely possible.
Give these styles a try:
.top-bar ul>li a:not(.button) {
line-height: 1em;
padding-top: 8px;
}
.top-bar ul>li a i {
display: block;
height: 16px;
margin: auto 0;
line-height: 1em;
text-align: center;
}
You'll likely need to adjust both the padding-top, line-height, and icon height values to match your particular design.

Auto heighten divs in Foundation over using media queries?

My questions is a common problem i seem to encounter but my brain never registers the right answer for some reason, probably because i'm slow.
The question I have is regarding my navigation menu.
When i'm at full width in Foundation i use the large-12 class and the small-12 class for smaller viewports, however i have that nav div inside of another parent div so when i get to small viewport the navigation drops below the height of the parent div.
I've set the parent div to a min-height: 204px and a max-height: auto assuming that it will adjust in height to wrapping child elements but i doesn't work.
So what is the best way to ensure that child divs that grow in height due to smaller viewports will push the parent div in height as well?
Here is my html:
<div>
<div class="interior-header">
<div>
<nav class="utility">
<ul>
<li>Register</li>
<li>Login</li>
</ul>
</nav>
</div>
<div>
<nav class="main">
<div class="logo small-12 large-offset-1 large-5 columns left"></div>
<ul class="small-12 large-6 columns right">
<li>Home</li>
<li>Catalog</li>
<li>Learn More</li>
<li>Be a Broker</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</div>
and here is the css for this particular component:
// HEADER INTERIOR
.interior-header {
background: url('../img/hero.jpg');
background-size: cover;
background-repeat: no-repeat;
min-height: 174px;
max-height: auto;
}
// NAVIGATION FIRST TIER
nav.main {
margin-top: 2%;
min-height: 100px;
height: auto;
}
Any help would be awesome, thank you.
.main {overflow: hidden;}
This causes a block-level element to contain its descendants.

How can I add image/div in ul submenu already using a background image?

http://www.dunhamssports.com/wp-content/themes/ds2/css/images/pic.png
I am trying to add a red bar at the bottom of each submenu in a list I am building. Since the current sub menu ul is outputting the dark gradient background I cannot use another background image. Having trouble figuring out where in my code I might be able to trick it to appear at the bottom of each list in the submenu.
<div id="nav">
<ul id="coolMenu">
<li>Home</li>
<li>Products
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locater</li>
</ul>
</li>
<li>Store Locator
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locator</li>
</ul>
</li>
<li>Weekly Circular</li>
</ul>
</div>
body {background-color:#999;}
#nav {background: url(http://www.dunhamssports.com/wp-content/themes/ds2/css/images/nav.jpg) repeat-x scroll 0 0 transparent; border-bottom: 1px solid #010103; height: 46px;}
ul {list-style-type:none; padding:0px; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:16px; line-height:36px; text-transform:uppercase;}
#coolMenu {float: left;list-style: none;margin:0px; font-size: 14px;}
#coolMenu > li {float: left;margin:10px 0px 0px 10px; border-right:1px solid #fff;padding-right:7px;}
#coolMenu li a {display: block; line-height: 2em; padding: 0 .5em; text-decoration: none;}
#coolMenu ul {position: absolute;display: none;z-index: 999;list-style-type:none;}
#coolMenu ul li a {width: 100%;}
#coolMenu li:hover ul {display: block;}
/* Main menu
------------------------------------------*/
#coolMenu > li > a {color:#fff;font-weight: normal;}
#coolMenu > li:hover > a {color: #fff; border-bottom:9px solid #920001;}
#coolMenu > li > .active {color: #fff;}
/* Submenu
------------------------------------------*/
#coolMenu ul {border: 1px solid #fff; background-image:url(http://www.dunhamssports.com/wp-content/themes/ds2/css/images/dropnav-bg.png); background-repeat:repeat;text-transform:none; color:#fff; list-style-type:disc; padding-left:25px;}
#coolMenu ul li a {color: #fff; text-indent:-10px;}
#coolMenu ul li:hover a {color: #999;}
You can put in a div into the last li so you can then adjust it there like this,
<ul id="coolMenu">
<li>Home</li>
<li>Products
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locater
<div></div>
</li>
</ul>
</li>
<li>Store Locator
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locator
<div></div></li>
</ul>
</li>
<li>Weekly Circular</li>
</ul>
And then put in this style,
#coolMenu ul li div {
border-bottom:9px solid #920001;
width: auto;
margin-left: -20px;
}

CSS3 box-shadow on <li> element not working

I have a grid of 12 boxes created from an unordered list as below. Border radius works fine, but IU can't get the shadow to appear. Does the box-shadow property only work on divs, but not display block elements?
<ul id="treatments">
<li id="eyelash"></li>
<li id="massage"></li>
<li id="tanning"></li>
<li id="facials"></li>
<li id="waxing"></li>
<li id="tinting"></li>
<li id="threading"></li>
<li id="nails"></li>
<li id="makeup"></li>
<li id="hair"></li>
<li id="courses"></li>
<li id="bespoke"></li>
</ul>
#content #treatments li {
height: 125px;
width: 125px;
display: block;
float: left;
margin-right: 13px;
margin-bottom: 13px;
-moz-box-shadow: 1px 1px 2px #777;
-webkit-box-shadow: 1px 1px 2px #777;
box-shadow: 1px 1px 2px #777;
-moz-border-radius: 8px;
border-radius: 8px;
behavior: url(/scipts/PIE.php);
}
Be sure that the margin of <li> is not set to zero.
The box-shadow is rendered in the margin. No margin -> no shadow.
You shouldn't have any issues with using box-shadow on li elements since box-shadow can be applied to all elements. Here's the section on box-shadow on the W3C site.
I had same problem... box-shadow didn't work... The reason was in rbga instead of rgba in my css code! :D