Reputation: 23
I'm trying to add a class to a select tag so a drop down menu can inherit some css styling but I can't get the style to apply. Am I formatting the class incorrectly?
Here's my code:
packagesmenu {
box-shadow: none!important;
background: transparent!important;
background-color: transparent!important;
padding: 8px 5px!important;
border-top: 1px solid #AAA!important;
border-left: 1px solid #AAA!important;
border-right: 1px solid #AAA!important;
border-bottom: 1px solid #AAA!important;
max-width: 100%!important;
outline: none;
border-radius: 0;
margin-bottom:15px!important;
text-transform:none!important;
}
packagesmenu:focus {
box-shadow: 0 0 5px 0 #ee2b30!important;
border-top: 1px solid #ee2b30!important ;
border-left: 1px solid #ee2b30!important;
border-right: 1px solid #ee2b30!important;
border-bottom: 1px solid #ee2b30!important;
}
<select style="width:100%;display:block;max-width:600px;margin:0 auto;" onchange="window.location.href = this.value" class="packagesmenu" name="packagesmenu" >
<option>Find your location</option>
<option value="https://go.booker.com/location/vixennailsandspamilton/buy/series">
Milton
</option>
<option value="https://go.booker.com/location/vixennailsandspamississauga/buy/series">
Mississauga</option>
<option value="https://go.booker.com/location/vixennailsandspadanforth/buy/series">
Danforth
</option>
<option value="https://go.booker.com/location/vixenburlington/buy/series">
Burlington
</option>
<option value="https://go.booker.com/location/VixenNailsandSpaOakville/buy/series">
Oakville
</option>
</select>
Upvotes: 2
Views: 48
Reputation: 819
I cleaned up your css. Inline css too. Don't use inline styles - this is poor and hard to maintain, someday you find out, right now please, believe me. Don't use !importand
, it is bad practice, just don't.
To declare in css:
body
select
use tag.someclass
use dot and class name#bigid
use hash and id namewithout spaces. But after :
and ;
always put space. It is allowed without spaces now, but good practice, readability and tradition are strict - spaces!
body{
background: #000; /* this to see background of select */
}
select{ /* no inline css */
display: block;
width: 100%;
max-width: 600px;
margin: 0 auto;
color: #aaa;
}
.packagesmenu {
background: 0;
border: 1px solid #aaa;
border-radius: 0;
outline: none;
max-width: 100%;
padding: 8px 5px;
margin-bottom: 15px;
}
.packagesmenu:focus {
box-shadow: 0 0 5px 0 #ee2b30;
border: 1px solid #ee2b30;
}
<select onchange="window.location.href = this.value" class="packagesmenu" name="packagesmenu" >
<option>Find your location</option>
<option value="https://go.booker.com/location/vixennailsandspamilton/buy/series">
Milton
</option>
<option value="https://go.booker.com/location/vixennailsandspamississauga/buy/series">
Mississauga</option>
<option value="https://go.booker.com/location/vixennailsandspadanforth/buy/series">
Danforth
</option>
<option value="https://go.booker.com/location/vixenburlington/buy/series">
Burlington
</option>
<option value="https://go.booker.com/location/VixenNailsandSpaOakville/buy/series">
Oakville
</option>
</select>
Upvotes: 1
Reputation: 505
In the CSS, a class selector
is a name preceded by a full stop (“.”)
and an ID selector
is a name preceded by a hash character (“#”).
So you're class name declaration wrong.
.packagesmenu {
box-shadow: none!important;
background: transparent!important;
background-color: transparent!important;
padding: 8px 5px!important;
border-top: 1px solid #AAA!important;
border-left: 1px solid #AAA!important;
border-right: 1px solid #AAA!important;
border-bottom: 1px solid #AAA!important;
max-width: 100%!important;
outline: none;
border-radius: 0;
margin-bottom:15px!important;
text-transform:none!important;
}
.packagesmenu:focus {
box-shadow: 0 0 5px 0 #ee2b30!important;
border-top: 1px solid #ee2b30!important ;
border-left: 1px solid #ee2b30!important;
border-right: 1px solid #ee2b30!important;
border-bottom: 1px solid #ee2b30!important;
}
Upvotes: 1