jQuery data picker font size issue

大城市里の小女人 提交于 2019-12-02 18:46:23

问题


I just implemented jQuery & datapicker stuff for ASP .NET MVC 3 (Razor) project and somehow the font of datapicker is incredible huge.

Any clue how to fix it?

Thank you!


回答1:


All the jQuery UI elements can be edited by hand within the jQuery UI css file, or you can build your own custom theme at the jQuery UI site before you download it. If you're using Chrome, Safari, or Firefox with Firebug, right click on the datepicker, select "inspect element", and look for the corresponding lines of code within the jQuery UI css file that you need to change. If you're not sure where your jQuery UI css file is, look at Resources in your web inspector to find the file path.




回答2:


You will need to "theming" it

http://jqueryui.com/demos/datepicker/#theming

Sample markup with jQuery UI CSS Framework classes:

 <div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
   <a class="ui-datepicker-prev ui-corner-all" title="Prev"><span class="ui-icon ui-icon-circle-triangle-w">Prev</span></a>
   <a class="ui-datepicker-next ui-corner-all" title="Next"><span class="ui-icon ui-icon-circle-triangle-e">Next</span></a>
   <div class="ui-datepicker-title">
      <span class="ui-datepicker-month">January</span><span class="ui-datepicker-year">2009</span>
   </div>
</div>
<table class="ui-datepicker-calendar">
   <thead>
   <tr>
      <th class="ui-datepicker-week-end"><span title="Sunday">Su</span></th>
      ...
   </tr>
   </thead>
   <tbody><tr>
      <td class="ui-datepicker-week-end ui-datepicker-other-month "> 1 </td>
      ...
   </tr>
   </tbody>
</table>
<div class="ui-datepicker-buttonpane ui-widget-content">
   <button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all">Today</button>
   <button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all">Done</button>
</div>




回答3:


Finally I found the solution

  1. Find jquery.ui.datepicker.css

  2. Add font-size:10px; for each line of .ui-datepicker

  3. Change with to width: 11em;

CSS:

.ui-datepicker { padding: .2em .2em 0; display: none; font-size:10px;  width: 11em;}
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; font-size:10px;}
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; font-size:10px;}
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; font-size:10px;}
.ui-datepicker .ui-datepicker-prev { left:2px; font-size:10px;}
.ui-datepicker .ui-datepicker-next { right:2px; font-size:10px;}
.ui-datepicker .ui-datepicker-prev-hover { left:1px; font-size:10px;}
.ui-datepicker .ui-datepicker-next-hover { right:1px; font-size:10px;}
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px;  font-size:10px;}
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; font-size:10px;}
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; font-size:10px;}
.ui-datepicker select.ui-datepicker-month-year {width: 100%; font-size:10px;}
.ui-datepicker select.ui-datepicker-month, 
.ui-datepicker select.ui-datepicker-year { width: 49%; font-size:10px;}
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; font-size:10px;}
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0;  font-size:10px;}
.ui-datepicker td { border: 0; padding: 1px; font-size:10px;}
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; font-size:10px;}
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; font-size:10px;}
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; font-size:10px;}
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; font-size:10px;}




回答4:


.ui-widget {font-size: 62.5%;}

Seems to do the trick. It should be added to the body, but this way nothing else has to be changed. https://groups.google.com/forum/?fromgroups=#!topic/jquery-ui/pri7DPcO074




回答5:


Some random CSS must be overwriting the default font-size for that element or its missing entirely. Just re-declare it or explicitly define it as !important to offset any other CSS value out there.

Here is the CSS to re-declare it:

.ui-datepicker table {
    border-collapse: collapse;
    font-size: 0.9em; /*add !important if it doesn't pick up the size*/
}


来源:https://stackoverflow.com/questions/8812401/jquery-data-picker-font-size-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!