Per modellare l'elemento, il CSS dovrebbe essere sufficiente. Ma, beh, non è abbastanza in termini di accessibilità. Presentazione di EasyDropDown.js, un plugin jQuery gratuito per coprire tutti quei difetti.
EasyDropDown.js può facilmente modellare l'elemento di select vecchio stile nella tua pagina web con molte funzionalità. Dopo il elemento è stato applicato con questo plugin, otterrà il pieno controllo della tastiera con la ricerca testuale. Questo strumento fornisce anche uno scorrimento interno per gli elementi in elenchi lunghi per limitare le dimensioni della casella a discesa. Sono disponibili anche moduli e convalide che aiutano la compatibilità.
Installazione
Per installare EasyDropDown, in primo luogo includere la libreria jQuery nella tua pagina web. Assicurati di includere anche il javascript (prendilo qui) in questo modo:
E il suo file CSS all'interno del tag head :
.. ..
Se stai utilizzando un altro tema, assicurati di copiare i file nella cartella web. Non preoccuparti perché non è necessario includerli nell'HTML per chiamarli.
Styling The Select
Quando si utilizza EasyDropDown.js, è possibile creare un menu a discesa personalizzabile con un markup semantico pulito. Gli elementi select possono essere disegnati solo all'interno di HTML. Puoi disabilitare l'elemento, definire un'opzione selezionata o aggiungere facilmente un'etichetta .
Per modellarlo, devi prima includere una classe dropdown nei tag. È possibile aggiungere label dando una classe di label all'interno dell'opzione. Ecco il markup di base:
Questo è tutto, non è necessario alcun javascript personalizzato da aggiungere. Ora il pessimo, vecchio stile si è trasformato in un input a discesa bello e fantasioso.
Se vuoi aggiungere un'opzione preselezionata, dai semplicemente il tuo menu a discesa con l'attributo selected . Raccomandiamo di non utilizzare l'etichetta con questa impostazione in quanto il valore selezionato sovrascriverà l'etichetta .
... ...
Puoi anche disabilitare il menu a discesa usando l'attributo disabled modo:
...
Temi pronti per l'uso
EasyDropDown.js include altri 2 temi pronti all'uso: Metro e Flat . Per utilizzare i temi, puoi utilizzare data-attribute HTML5.
Dentro il tag, chiama data-settings='{"wrapperClass":"theme-name"}' per applicare un altro tema. Sentiti libero di cambiare il theme-name del theme-name con i nomi dei temi disponibili: metro o flat . Ecco l'esempio:
...
Accanto a wrapperClass, ci sono altre impostazioni che è possibile aggiungere, vedere la pagina della documentazione per i dettagli. Se sei bello con il codice javascript, puoi vedere il tutorial lì.
Una raccolta di utili risorse web è qualcosa che uno sviluppatore web non vede davvero nel proprio toolkit. Pertanto, essendo io stesso uno sviluppatore, mi sforzo di presentarti le migliori e le più recenti risorse di sviluppo web ogni mese.La raccolta di questo mese include un'interessante app gratuita per screencasting, un paio di framework basati sul linguaggio Material Design, un paio di librerie per il test delle prestazioni, CLI e una manciata di altre risorse utili .
La libertà di Internet è qualcosa che diamo valore ma che diamo per scontato giorno per giorno. Quindi quando il governo o le multinazionali cercano di limitarlo in un modo o nell'altro, tutti si alzano e prestano attenzione. È per questo che alcuni dei tuoi siti Web preferiti di recente, il 10 settembre 2014, hanno visualizzato il temuto segno di caricamento come GIF o un messaggio popup simile a questo:Non preoccuparti, Internet non ha rallentato. T