Share on facebook
Share on reddit
Share on twitter
Share on pinterest
Share on tumblr
Share on whatsapp
Drop Downs

How to create a CSS dropdown

Share on facebook
Share on twitter
Share on linkedin
Share on tumblr
Share on whatsapp
Share on pinterest

Dropdowns are elements that we use to describe a primary action. Here’s how to create it

HTML

<div class="dropdown">
	<span>Hover Me</span>
	<div class="content">
		<h1>Content</h1>
	</div>
</div>

<div class="dropdown">
	<span>Hover Me Again</span>
	<div class="content">
		<h1>Content 2</h1>
	</div>
</div>

CSS

.dropdown {
  font-family: product sans;
  background: #0058ff;
  width: max-content;
  padding: 11px 21px;
  border-radius: 100px;
  color: white;
}
.dropdown .content {
  pointer-events: none;
  position: absolute;
  width: max-content;
  height: max-content;
  background: #0070ff;
  margin-top: 14px;
  margin-left: -14px;
  opacity: 0;
  transition: all 0.3s;
  padding: 6px;
  font-size: 12px;
  border-radius: 2px;
  box-shadow: 0px 7px 10px #777;
}
.dropdown:hover .content {
  display: block;
  opacity: 1;
  pointer-events: all;
}

And finally download it here

Subscribe on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *

Request a tutorial if you didn't find what you need.