jQuery datepicker字体大小问题

时间:2012-01-11 00:06:49

标签: jquery css jquery-ui jquery-ui-datepicker

我刚刚实现了jQuery& ASP .NET MVC 3(Razor)项目的数据贴纸 不知何故,数据贴纸的字体非常庞大。

有任何线索如何解决?

谢谢!

enter image description here

5 个答案:

答案 0 :(得分:2)

所有jQuery UI元素都可以在jQuery UI css文件中手动编辑,或者您可以在下载之前在jQuery UI站点上构建自己的自定义主题。如果您使用Chrome,Safari或Firefox与Firebug,请右键单击日期选择器,选择“检查元素”,然后在需要更改的jQuery UI css文件中查找相应的代码行。如果您不确定jQuery UI css文件的位置,请查看Web检查器中的“资源”以查找文件路径。

答案 1 :(得分:1)

你需要“主题化”

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

使用jQuery UI CSS Framework类进行示例标记:

 <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>

答案 2 :(得分:1)

最后我找到了解决方案

  1. 查找jquery.ui.datepicker.css

  2. 添加字体大小:10px;对于.ui-datepicker

  3. 的每一行
  4. 更改为宽度:11em;

  5. 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;}
    

    enter image description here

答案 3 :(得分:1)

.ui-widget {font-size: 62.5%;}
似乎要做的伎俩。它应该被添加到身体,但这样就不需要改变其他任何东西了。 https://groups.google.com/forum/?fromgroups=#!topic/jquery-ui/pri7DPcO074

答案 4 :(得分:0)

某些随机CSS必须覆盖该元素的默认字体大小或完全丢失。只需重新声明它或明确地将其定义为!important以抵消任何其他CSS值。

这是重新声明它的CSS:

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