Reputation: 43
Found lots of advice on website how to. I am try to make it work but is different kind of dropdown menu. I try to get a slow falling css drop down menu. here is html -
Most help comes in the form of list boxed nav bard but I prefer this method, it position nicely.
.dropbtn {
background-color: #4CAF50;
transition: 0.3s;
color: white;
padding: 16px;
padding-right: 32px;
font-size: 16px;
border: none;
cursor: crosshair;
border-radius: 2px;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
background-color: #f1f1f1;
color: #000000;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: inline;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
color: #000000;
}
.dropdown1 {
position: fixed;
top: 150px;
left: 50px;
}
.dropdown2 {
position: fixed;
top: 150px;
left: 220px;
}
.dropdown3 {
position: fixed;
top: 150px;
left: 615px;
}
.dropdown4 {
position: fixed;
top: 150px;
left: 1003px;
}
.pageheading {
font-family: verdana;
font-size: 85%;
position: absolute;
left: 50px;
top: 210px;
background-color: #4CAF50;
border-radius: 6px;
}
.pageparagraph {
font-family: verdana;
text-align: justify;
position: absolute;
left: 50px;
top: 290px;
right: 685px;
background-color: #4CAF50;
border-radius: 6px;
}
.logo {
font-family: verdana;
font-size: 150%;
color: white;
position: fixed;
top: 10px;
left: 50px;
background-color: #4CAF50;
border-radius: 6px;
}
body {
background-image: url("ForestBackground.jpg");
background-repeat: no-repeat;
}
.arrow1 {
position: fixed;
top: 166px;
left: 185;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow2 {
position: fixed;
top: 166px;
left: 580;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow3 {
position: fixed;
top: 166px;
left: 970;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow4 {
position: fixed;
top: 166px;
left: 1130;
transform: rotate(0deg);
transition: 0.3s;
}
.dropdown:hover .arrow1 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow2 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow3 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow4 {
transform: rotate(90deg);
transition: 0.3s;
}
<div class="dropdown">
<div class="dropdown1">
<button class="dropbtn">Climate Change
<div class="arrow1">➲</div>
</button>
<div class="dropdown-content">
<a href="https://thepotatoshop.com/shop/mash/highland-burgundy-red-1kg/">Greenhouse Gases</a>
<a href="https://thepotatoshop.com/shop/mash/arran-victory-1kg/">Carbon Dioxide</a>
<a href="https://thepotatoshop.com/shop/mash/desiree-1kg/">Methane</a>
<a href="https://thepotatoshop.com/shop/salad/belle-de-fontenay-1kg/">Water Vapour</a>
<a href="https://thepotatoshop.com/shop/salad/belle-de-fontenay-1kg/">NF3</a>
</div>
</div>
</div>
i would like a falling, slide down menu as opposed to a fade in any suggestions friends?
edit - just editing this to say thanks for all the help! and mainly to help get my account able to ask questions again, I don't know why i have been banned. please help. love to you all.
Upvotes: 1
Views: 16095
Reputation: 1733
https://jsfiddle.net/btLjk40x/2/ ~ check this fiddle
.dropdown-content {
overflow: hidden:
height: 0;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
transition: all 1s ease-in;
}
.dropdown:hover .dropdown-content {
height: 200px; // sample height
}
Upvotes: 4
Reputation: 38252
If you want to emulate a "slide-down" effect you can add an extra wrapper to your submenu elements and use translate
like this:
Warning: You are using a lot of fixed positions that will lead you into issues later for responsive layouts and some are unnecessary like the ones for the arrows
.dropbtn {
background-color: #4CAF50;
transition: 0.3s;
color: white;
padding: 16px;
padding-right: 32px;
font-size: 16px;
border: none;
cursor: crosshair;
border-radius: 2px;
}
.dropdown-content {
position: absolute;
width:100%;
overflow:hidden;
}
.dropdown-content > div {
background-color: #f9f9f9;
transform:translateY(-100%);
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
transition:transform 1s;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
color: #000000;
}
.dropdown:hover .dropdown-content > div {
transform:translateY(0);
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
color: #000000;
transition: 0.3s;
}
.dropdown1 {
position: fixed;
top: 150px;
left: 50px;
}
.dropdown2 {
position: fixed;
top: 150px;
left: 220px;
}
.dropdown3 {
position: fixed;
top: 150px;
left: 615px;
}
.dropdown4 {
position: fixed;
top: 150px;
left: 1003px;
}
.pageheading {
font-family: verdana;
font-size: 85%;
position: absolute;
left: 50px;
top: 210px;
background-color: #4CAF50;
border-radius: 6px;
}
.pageparagraph {
font-family: verdana;
text-align: justify;
position: absolute;
left: 50px;
top: 290px;
right: 685px;
background-color: #4CAF50;
border-radius: 6px;
}
.logo {
font-family: verdana;
font-size: 150%;
color: white;
position: fixed;
top: 10px;
left: 50px;
background-color: #4CAF50;
border-radius: 6px;
}
body {
background-image: url("ForestBackground.jpg");
background-repeat: no-repeat;
}
.arrow1 {
position: fixed;
top: 166px;
left: 185;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow2 {
position: fixed;
top: 166px;
left: 580;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow3 {
position: fixed;
top: 166px;
left: 970;
transform: rotate(0deg);
transition: 0.3s;
}
.arrow4 {
position: fixed;
top: 166px;
left: 1130;
transform: rotate(0deg);
transition: 0.3s;
}
.dropdown:hover .arrow1 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow2 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow3 {
transform: rotate(90deg);
transition: 0.3s;
}
.dropdown:hover .arrow4 {
transform: rotate(90deg);
transition: 0.3s;
}
<div class="dropdown">
<div class="dropdown1">
<button class="dropbtn">Climate Change
<div class="arrow1">➲</div>
</button>
<div class="dropdown-content">
<div>
<a href="https://thepotatoshop.com/shop/mash/highland-burgundy-red-1kg/">Greenhouse Gases</a>
<a href="https://thepotatoshop.com/shop/mash/arran-victory-1kg/">Carbon Dioxide</a>
<a href="https://thepotatoshop.com/shop/mash/desiree-1kg/">Methane</a>
<a href="https://thepotatoshop.com/shop/salad/belle-de-fontenay-1kg/">Water Vapour</a>
<a href="https://thepotatoshop.com/shop/salad/belle-de-fontenay-1kg/">NF3</a>
</div>
</div>
</div>
</div>
Upvotes: 1