jQuery 数据选择器字体大小问题

发布于 2024-12-25 22:49:27 字数 199 浏览 4 评论 0原文

我刚刚实现了 jQuery & ASP .NET MVC 3 (Razor) 项目的 datapicker 内容 不知何故,datapicker 的字体大得令人难以置信。

有任何线索如何修复它吗?

谢谢你!

在此处输入图像描述

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!

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一个人的旅程 2025-01-01 22:49:27

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

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.

孤城病女 2025-01-01 22:49:27

您需要对其进行“主题化”

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

使用 jQuery UI CSS 框架类的示例标记:

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

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>

眼泪也成诗 2025-01-01 22:49:27

最后我找到了解决方案

  1. Find jquery.ui.datepicker.css

  2. Add font-size:10px;为.ui-datepicker的每一行

  3. 更改为宽度: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;}

在此处输入图像描述

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

enter image description here

一梦浮鱼 2025-01-01 22:49:27
.ui-widget {font-size: 62.5%;}

似乎可以做到这一点。它应该被添加到主体中,但这样就不需要改变其他任何东西。
https://groups.google.com/forum/?fromgroups =#!topic/jquery-ui/pri7DPcO074

.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

不念旧人 2025-01-01 22:49:27

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

这是重新声明它的 CSS:

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

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*/
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文