I am using two css class for dropdown control first css applies to all dropdown and second applies to only those dropdown that are having some specific value in custom tag (data-view="readonly-edit"). In first css I am using width:auto; to expand it fully by default, but if any dropdown is having the custom tag (data-view="readonly-edit") then don't want to apply the width:auto, to that control, that control should use width that is given in their width property itself.
My question if how do I override the "width:auto" with width given on control property itself.
Following the sample code
Css
.DropdownList {
border-radius: 5px;
-webkit-border-radius: 5;
font-family: Calibri,"Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 4px 1px 4px 1px;
border: none;
color: #000000 !important;
line-height: 1;
font-size: 13.5px;
background-color: transparent;
pointer-events: none;
-ms-user-select: none;
tab-index: -1;
cursor: default;
opacity: 1 !important;
-webkit-appearance: none;
-moz-appearance: none;
border: none;
width:auto !important;
}
.DropdownList[data-view=readonly-edit] {
-webkit-appearance: menulist !important;
-moz-appearance: menulist !important;
padding: 5px 2px 5px 2px;
border: 1px solid #7D7D7D;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
color: #1E2935;
line-height: 1.4285;
pointer-events: auto;
-ms-user-select: auto;
cursor: auto;
background-color: white !important;
opacity: 1 !important;
width:0px; /*here it should auto inherit the width
from control width property itself and override the
width:auto given in above css*/
}
Aspx
Auto width applying for this DropDownList
<asp:DropDownList ID="ddlAutoWithDropDown" CssClass="DropdownList" Width="110Px" runat="server">
Width given on control itself should apply for this DropDownList
<asp:DropDownList ID="ddlFixedWithDropDown" data-view="readonly-edit" CssClass="DropdownList" Width="220Px" runat="server">