jQuery Mobile:显式覆盖所有角的圆角

发布于 2024-12-07 12:04:55 字数 339 浏览 0 评论 0原文

jQuery Mobile 通过添加类 ui-corner-all 自动圆化输入元素的所有角。我注意到,如果我在 Chrome 检查器中手动将此类更改为 ui-corner-left,那么我会正确地在左侧(顶部和底部)仅获得圆角。当然,这可以通过一行 jQuery 轻松完成,例如

$('#myid').removeClass('ui-corner-all').addClass('ui-corner-left');

我的问题是,有没有一种方法可以指示 jQuery Mobile 立即应用此类,而无需在 JQM 完成工作后执行这段额外的代码?

jQuery Mobile automatically rounds all corners of input elements, by adding a class ui-corner-all. I noticed that if I change this class manually to ui-corner-left in Chrome inspector, then I correctly get only rounded corners on the left (top and bottom). This could of course easily be done with one line of jQuery, such as

$('#myid').removeClass('ui-corner-all').addClass('ui-corner-left');

My question is, is there a way I can instruct jQuery Mobile to apply this class straight away, without having to execute this extra bit of code after JQM has done it's work?

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

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

发布评论

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

评论(3

空城旧梦 2024-12-14 12:04:55

基本上可以应用以下内容,但您关心的是在没有额外代码执行的情况下运行,让我们看看我们是否有机会得到它,即使我正在寻找同样的问题,但以下是我的解决方案。

$('div').live('pageshow',function(event){
     $('#myid').removeClass('ui-corner-all').addClass('ui-corner-left');
});

Basically following can be apply, but your concern is to run without extra code execution, lets see wheter we get chance to get it, even I'm looking same question, but following is my solution.

$('div').live('pageshow',function(event){
     $('#myid').removeClass('ui-corner-all').addClass('ui-corner-left');
});
过期情话 2024-12-14 12:04:55

您可以通过在 index.html 文件中指定所需的 jquery mobile 类来覆盖默认值。一个很好的例子是,而不是:

<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-listview-inset ui-shadow'>

它会自动插入这个

class ui-corner-all

,然后添加你自己的类:

<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-corner-left ui-listview-inset ui-shadow'>

在firefox中,ui-corner-all类不会自动为我添加,也许你正在使用旧版本的jquery mobile并且需要升级。
如果您想在 javascript 文件中动态执行此操作:

$("#my_page_id").live("pagecreate",function(){
    var ul = $("<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-listview-inset ui-corner-left ui-shadow'>");
    ul.append($('<li class="ui-li ui-li-static  ui-body-a ui-corner-left">').append("Code Slayer!!!"));
    $('mydiv_in_mypage').html(ul);   

});

就像重新重写 div 的内容一样,自动删除旧内容。如果您要在列表中显示大量信息,您可能需要使用

$.mobile.showPageLoadingMsg('a','Page Loading', true);

,然后在页面完全显示后隐藏该消息。

You can override the default value by specifying in your index.html file the jquery mobile class you want. A good example would be, instead of:

<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-listview-inset ui-shadow'>

which would automatically insert this

class ui-corner-all

you would then add your own class:

<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-corner-left ui-listview-inset ui-shadow'>

In firefox, the ui-corner-all class does not get automatically added for me, maybe you are using an older version of jquery mobile and need to upgrade.
If you want to do it dynamically in a javascript file:

$("#my_page_id").live("pagecreate",function(){
    var ul = $("<ul id='myid' data-inset='true' data-theme='a' data-role='listview'  class='ui-listview ui-listview-inset ui-corner-left ui-shadow'>");
    ul.append($('<li class="ui-li ui-li-static  ui-body-a ui-corner-left">').append("Code Slayer!!!"));
    $('mydiv_in_mypage').html(ul);   

});

as in re-write the contents of the div all over again, automatically erasing the old contents. If you will display a lot of information in your list you might want to use the

$.mobile.showPageLoadingMsg('a','Page Loading', true);

and then hide the message when your page has been fully displayed.

何以畏孤独 2024-12-14 12:04:55

嘿,你可以这样做

  <a  href="#panel"  data-corners="false"></a>

hey Simply you can do like this

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