Custom Select Element

Developer
Size
3,616 Kb
Views
14,168

How do I make an custom select element?

Theres a lot of custom select solutions out there for modern browsers, but most aren't the easiest to work with, especially in FireFox where the default drop down arrow just won't disappear.. What is a custom select element? How do you make a custom select element? This script and codes were developed by Adam Grayson on 10 November 2022, Thursday.

Custom Select Element Previews

Custom Select Element - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Custom Select Element</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="customSelect"><span></span> <select> <option>Custom Select Menu</option> <option>option 2</option> <option>option 3</option> <option>option 4</option> </select>
</div>
<div class="customSelect"><span></span> <select> <option>Cross Browser Support</option> <option>option 2</option> <option>option 3</option> <option>option 4</option> <option>option 5</option> <option>option 6</option> </select>
</div>
<div class="customSelect"><span></span> <select> <option>Any Styling</option> <option>option 2</option> </select>
</div>
<div class="customSelect"><span></span> <select> <option>Individual Instances</option> </select>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Custom Select Element - Script Codes CSS Codes

@import url(https://fonts.googleapis.com/css?family=Raleway:700);
* { box-sizing: border-box;
}
.customSelect { width: 320px; height: 60px; font: 700 14px/60px "Raleway", sans-serif; color: #042e33; background: #ffffff; border: 1px solid #d5d5d5; text-transform: uppercase; position: relative; overflow: hidden; margin: 20px auto 0;
}
.customSelect:after { top: 28px; right: 30px; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-color: rgba(136, 183, 213, 0); border-top-color: #88b7d5; border-width: 5px; margin-left: -5px;
}
.customSelect span, .customSelect select { width: 100%; height: 100%;
}
.customSelect span { display: block; position: absolute; top: 0; left: 0; text-indent: 30px;
}
.customSelect select { -webkit-appearance: none; -moz-appearance: none; -ms-appearance: none; -o-appearance: none; appearance: none; opacity: 0;
}

Custom Select Element - Script Codes JS Codes

(function() { $(window).load(function() { var initCustomSelects, setSelectText; initCustomSelects = function() { $('.customSelect').each(function() { var $this, value; $this = $(this); value = $this.find('select').val(); setSelectText($this, value); }); }; setSelectText = function(element, text) { element.find('span').text(text); }; $('.customSelect select').change(function() { var parent, value; parent = $(this).parent('.customSelect'); value = $(this).val(); setSelectText(parent, value); }); initCustomSelects(); });
}).call(this);
Custom Select Element - Script Codes
Custom Select Element - Script Codes
Home Page Home
Developer Adam Grayson
Username agrayson
Uploaded November 10, 2022
Rating 3
Size 3,616 Kb
Views 14,168
Do you need developer help for Custom Select Element?

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!

Adam Grayson (agrayson) Script Codes
Create amazing sales emails 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!