How to set the color and font style of placeholder text

I want to set the color to the placeholder, change the font style to bold, and increase the size.

How can I achieve this? Should I give style to the placeholder, or is there any other way can I achieve this? I want to set the color and change font style to work in all browsers for select size in the below result.

<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}

}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>

You can use the following code for cross-browser support :

For Google Chrome :

.element::-webkit-input-placeholder {
    color: blue;
    font-weight: bold;
}

For Mozilla Firefox :

.element::-moz-placeholder {
    color: blue;
    font-weight: bold;
}

For Internet Explorer :

.element:-ms-input-placeholder {
    color: blue;
    font-weight: bold;
} 

For Opera :

.element:-o-input-placeholder {
    color: blue;
    font-weight: bold;
} 

you can find this and more css tricks here

https://css-tricks.com/snippets/css/style-placeholder-text/

::-webkit-input-placeholder {
   color: red;
   font-weight: 800;
}

:-moz-placeholder { /* Firefox 18- */
   color: red;  
   font-weight: 800;
}

::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
   font-weight: 800;
}

:-ms-input-placeholder {  
   color: red;  
   font-weight: 800;
}
<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}
::-webkit-input-placeholder {
   color: red;
}
}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        <h4 style="margin-bottom: .5em;">Select City</h4>
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>

你可以使用占位符伪元素和font-weight使它更大胆

<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}
    ::-webkit-input-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    :-moz-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    ::-moz-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    :-ms-input-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        <h4 style="margin-bottom: .5em;">Select City</h4>
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>
链接地址: http://www.djcxy.com/p/70502.html

上一篇: 输入焦点上占位符的颜色

下一篇: 如何设置占位符文本的颜色和字体样式