Select

Developer
Size
4,112 Kb
Views
56,672

How do I make an select?

Part of my Responsive Menu Concepts article on CSS-Tricks.. What is a select? How do you make a select? This script and codes were developed by Tim Pietrusky on 20 June 2022, Monday.

Select Previews

Select - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Select</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ @import url(http://fonts.googleapis.com/css?family=Exo:400,500,700,700italic);
* { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { margin: 1.25em .75em; background: url(http://subtlepatterns.com/patterns/black-Linen.png); font: 1.4em 'Exo', sans-serif;
}
nav[role="select"] { width: 100%; position: relative; color: #000;
}
nav[role="select"] > select { display: none;
}
nav[role="select"] ul { width: 100%; list-style: none;
}
nav[role="select"] ul > li { float: left; padding: .55em .45em; width: 19%; font-size: 1.2em; background-color: rgba(174, 86, 168, 0.5); text-align: center; transition-duration: .15s; transition-timing-function: ease-in-out; transition-property: box-shadow, background, color, text-align, padding; cursor: pointer;
}
nav[role="select"] ul > li:hover { background-color: rgba(174, 86, 168, 0.3); color: #fff; text-align: left; padding-left: .75em; box-shadow: 0 0 0 0.25em rgba(0, 0, 0, 0.3), 0 0 0 0.5em rgba(0, 0, 0, 0.3), 0 0 0 0.75em rgba(0, 0, 0, 0.3), inset 0 0 0 0.25em rgba(0, 0, 0, 0.3);
}
nav[role="select"] ul > li > a { color: inherit; text-decoration: none; transition: inherit;
}
/* small screens */
@media screen and (max-width: 44em) { body { margin: 1em 0; } nav[role="select"] ul { display: none; } nav[role="select"]:after { position: absolute; z-index: -1; content: "Menu"; right: 0; bottom: -1.75em; background: rgba(174, 86, 168, 0.4); padding: .15em .55em; } nav[role="select"] select { display: block; user-select: none; cursor: pointer; width: 100%; padding: .55em .45em; border: none; background-color: rgba(174, 86, 168, 0.25); font: 1.2em 'Exo', sans-serif; }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <nav role="select"> <ul> <li><a href="#">Stream</a></li> <li><a href="#">Lab</a></li> <li><a href="#">Projects</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> <select onchange="if (this.value) window.location.href = this.value;"> <option value="#">Stream</option> <option value="#">Lab</option> <option value="#">Projects</option> <option value="#">About</option> <option value="#">Contact</option> </select>
</nav> <script src="js/index.js"></script>
</body>
</html>

Select - Script Codes CSS Codes

@import url(http://fonts.googleapis.com/css?family=Exo:400,500,700,700italic);
* { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { margin: 1.25em .75em; background: url(http://subtlepatterns.com/patterns/black-Linen.png); font: 1.4em 'Exo', sans-serif;
}
nav[role="select"] { width: 100%; position: relative; color: #000;
}
nav[role="select"] > select { display: none;
}
nav[role="select"] ul { width: 100%; list-style: none;
}
nav[role="select"] ul > li { float: left; padding: .55em .45em; width: 19%; font-size: 1.2em; background-color: rgba(174, 86, 168, 0.5); text-align: center; transition-duration: .15s; transition-timing-function: ease-in-out; transition-property: box-shadow, background, color, text-align, padding; cursor: pointer;
}
nav[role="select"] ul > li:hover { background-color: rgba(174, 86, 168, 0.3); color: #fff; text-align: left; padding-left: .75em; box-shadow: 0 0 0 0.25em rgba(0, 0, 0, 0.3), 0 0 0 0.5em rgba(0, 0, 0, 0.3), 0 0 0 0.75em rgba(0, 0, 0, 0.3), inset 0 0 0 0.25em rgba(0, 0, 0, 0.3);
}
nav[role="select"] ul > li > a { color: inherit; text-decoration: none; transition: inherit;
}
/* small screens */
@media screen and (max-width: 44em) { body { margin: 1em 0; } nav[role="select"] ul { display: none; } nav[role="select"]:after { position: absolute; z-index: -1; content: "Menu"; right: 0; bottom: -1.75em; background: rgba(174, 86, 168, 0.4); padding: .15em .55em; } nav[role="select"] select { display: block; user-select: none; cursor: pointer; width: 100%; padding: .55em .45em; border: none; background-color: rgba(174, 86, 168, 0.25); font: 1.2em 'Exo', sans-serif; }
}

Select - Script Codes JS Codes

 /** Select # What? # Part of my "Responsive Menu Concepts" article on CSS-Tricks http://css-tricks.com/responsive-menu-concepts # 2012 by Tim Pietrusky # timpietrusky.com
**/
Select - Script Codes
Select - Script Codes
Home Page Home
Developer Tim Pietrusky
Username TimPietrusky
Uploaded June 20, 2022
Rating 4
Size 4,112 Kb
Views 56,672
Do you need developer help for Select?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Tim Pietrusky (TimPietrusky) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!