【问题标题】:How to change this specific css class inside div, in Date Picker jquery-ui?如何在日期选择器 jquery-ui 中更改 div 内的这个特定 css 类?
【发布时间】:2016-07-25 18:09:52
【问题描述】:

在日历日期选择器中,我有这个 DIV

<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-datepicker-multi-2 ui-datepicker-multi">

我想为这个类更改 css 类:

ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-datepicker-multi-2 ui-datepicker-multi

我是这样用的,但是不行:

.ui-datepicker .ui-widget .ui-widget-content .ui-helper-clearfix .ui-corner-all .ui-datepicker-multi .ui-datepicker-multi-2 {

position: absolute;
top: 38px;
left: 44px;
z-index: 1;
display: block;
width: 55em;
}

如何更改该类的 css?我的css不正确吗? 这个 DIV 有问题,因为会自动将一种样式添加到 div 中。我检查了检查元素,我看到有内联元素,但没有。这就是为什么CSS不会影响它,如何解决?

How to remove auto style into this div?

我需要有人帮助我完成以下 JavaScript 代码,如何 将宽度设置为 width: "55em" 都是因为以下代码 CSS 不会影响到该 DIV

        // determine sizing offscreen
    inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px", width: "55em" } );
    $.datepicker._updateDatepicker( inst );

    // fix width for dynamic number of date pickers
    // and adjust position before showing
    offset = $.datepicker._checkOffset( inst, offset, isFixed );
        inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
        "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
        left: offset.left + "px", top: offset.top + "px", width: "55em" } );    
    if ( !inst.inline ) {
        showAnim = $.datepicker._get( inst, "showAnim" );
        duration = $.datepicker._get( inst, "duration" );
        inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
        $.datepicker._datepickerShowing = true;

        if ( $.effects && $.effects.effect[ showAnim ] ) {
            inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
        } else {
            inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
        }

        if ( $.datepicker._shouldFocusInput( inst ) ) {
            inst.input.trigger( "focus" );
        }

        $.datepicker._curInst = inst;
    }
},

【问题讨论】:

    标签: javascript html css datepicker


    【解决方案1】:

    你不需要在类之间有空格。当您有空间时,它将针对每个班级,就好像它是之前班级的孩子一样。删除空格将针对具有所有这些类的元素。

    .ui-datepicker.ui-widget.ui-widget-content.ui-helper-clearfix.ui-corner-all.ui-datepicker-multi.ui-datepicker-multi-2 {
       position: absolute;
       top: 38px;
       left: 44px;
       z-index: 1;
       display: block;
       width: 70em;
    }
    

    编辑:为了覆盖内联样式,请使用 JQuery 的 .css() 函数来设置您想要的元素的样式。像这样的:

    $('#ui-datepicker-div').css('width':'70em');
    

    【讨论】:

    • 我做到了,但它不起作用,这个DIV有问题,因为会自动将一种样式添加到div中。我检查了检查元素,我看到有内联元素,但没有。这就是为什么CSS不会影响它,如何解决它?
    • @Alexandrrechiardson 如果您的问题是内联样式覆盖了您的样式表,那么这应该在创建元素的 JS 函数中完成。看起来您正在使用某种库,所以我会查看有关如何更改这些样式的文档。
    • 您好,您需要在调用 jquery ui css 后进行样式覆盖。是这样吗?
    • 问题与 jquery-ui.js 有关,这就是为什么要添加 css,我检查了文件,我需要更改我不知道的 JavaScript 代码。
    猜你喜欢
    • 1970-01-01
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多