Change select2 DropDownList Item font size in CSS

akhter
 
on Sep 22, 2022 06:29 AM
Sample_520897.zip
198 Views

Dropdown font size is not getting change on medium

<asp:DropDownList ID="ddlsup" runat="server" class="form-control" cssclass=" js-example-placeholder-single">
</asp:DropDownList>

 

.form-control{
    width: 200px !important;
    height:25px;
    font-size:medium;
}

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script type="text/javascript">
    $(function () {
       $(".js-example-placeholder-single").select2({
            placeholder: "Select",
            allowClear: true
        });
    });
</script>
Download FREE API for Word, Excel and PDF in ASP.Net: Download
KasimA
 
on Sep 23, 2022 12:08 AM

Hi akhter,

Please refer below sample.

HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" />
    <style type="text/css">
        body {
            font-family: Arial;
            font-size: 10pt;
        }

        .js-example-placeholder-single {
            width: 250px !important;
        }

        .select2-results__option {
            font-size: 25px !important;
        }
    </style>

    <script type="text/javascript">
        $(function () {
            $(".js-example-placeholder-single").select2({
                placeholder: "Select",
                allowClear: true
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="container-fluid" style="padding-top: 10px !important;">
            <asp:DropDownList ID="ddlsup" runat="server"
                class="form-control js-example-placeholder-single">
                <asp:ListItem Text="-Please Select-" />
                <asp:ListItem Text="One" Value="1" />
                <asp:ListItem Text="Two" Value="2" />
                <asp:ListItem Text="Three" Value="3" />
            </asp:DropDownList>
        </div>
    </form>
</body>
</html>

Screenshot