简体   繁体   English

如何更改物化日期时间选择器的默认主体颜色?

[英]How to change default body color of materialize datetimepicker?

You can find the entire code here http://codepen.io/anon/pen/BjqxOq你可以在这里找到完整的代码http://codepen.io/anon/pen/BjqxOq

I am displaying a login form using Materialize CSS which you can see in the above Codepen.我正在使用 Materialize CSS 显示登录表单,您可以在上面的 Codepen 中看到。 It has two buttons Login and Register .它有两个按钮LoginRegister When Register is clicked a modal is displayed containing necessary registration fields and one of it is materialize datetimepicker .单击注册时,会显示一个包含必要注册字段的模式,其中之一是 materialize datetimepicker

Is there a possibility to change the default body color of datetimepicker?是否有可能更改 datetimepicker 的默认主体颜色?

HTML HTML

<div class="row">
    <div class="input-field col s6">Date of Birth
        <input type="date" class="datepicker ">
    </div>
</div>

JS JS

$(document).ready(function(){
    $('.datepicker').pickadate({
        selectMonths: true, // Creates a dropdown to control month
        selectYears: 15 // Creates a dropdown of 15 years to control year
    });
});

I have noticed that some answers are not working I have searched a bit and this is the result.我注意到一些答案不起作用我已经搜索了一点,这就是结果。 Change your CSS file according to this.根据此更改您的 CSS 文件。 I have added all the text below feel free to copy.我已经添加了下面的所有文字,请随意复制。

Hope it helps...希望能帮助到你...

.picker__date-display { background-color: #6d4e7a; }
.picker__day.picker__day--today { color: red; }
.picker__day--selected, .picker__day--selected:hover, .picker--focused .picker__day--selected { background-color: #6d4e7a;}
.picker__close { color: #6d4e7a !important;}
.picker__today { color: #6d4e7a !important;}
.clockpicker-tick:hover { background: #6d4e7a !important; }
.clockpicker-canvas line { stroke: #6d4e7a !important; }
.clockpicker-canvas-bearing { fill: #6d4e7a !important; }
.clockpicker-canvas-bg { fill: #6d4e7a !important; }

在此处输入图片说明

The materializecss datepicker has a div with a class called "picker__box" . materializecss datepicker 有一个 div,其中包含一个名为"picker__box"的类。 If you set the background-color for this class, your datepicker will assume this color, as you can see in below codepen.如果您为此类设置背景颜色,您的日期选择器将采用此颜色,如下面的代码笔所示。

http://codepen.io/anon/pen/OMBoMz http://codepen.io/anon/pen/OMBoMz

.picker__box{
    background-color: #CCC;
}

EDIT编辑

To change the upper half body color too, you have to set background-color for two more classes:要更改上半身颜色,您必须为另外两个类设置背景颜色:

.picker__date-display, .picker__weekday-display{
    background-color: #CCC;
}

I hope this helps!我希望这有帮助!

EDIT: This doesn't change the body, but everything but the body, and let the body white编辑:这不会改变身体,而是改变身体以外的一切,让身体变白

Cant comment.不能评论。

Allan Pereira solution didn't work for me, everything went to my color (even the white-background). Allan Pereira 解决方案对我不起作用,一切都变成了我的颜色(甚至是白色背景)。

I used this我用过这个

    .picker__date-display, .picker__weekday-display{
        background-color: rgba(66, 133, 244, 0.79);
    }

    div.picker__day.picker__day--infocus.picker__day--selected.picker__day--highlighted {
        background-color: rgba(66, 133, 244, 0.79);
    }

    button.picker__today, button.picker__close {
        color: rgba(66, 133, 244, 0.79);
    }

(color is a nice blue) (颜色是漂亮的蓝色)

edit: codepen: http://codepen.io/anon/pen/Kgxbdj#anon-signup编辑:codepen: http ://codepen.io/anon/pen/Kgxbdj#anon-signup

This code worked for me for changing the pickers color.此代码适用于我更改选择器颜色。

.timepicker-canvas line {
    stroke: red;
}

.timepicker-canvas-bg, 
.timepicker-canvas-bearing {
    fill: red;
}

Some answers are not working but this method worked for me, just copy and paste as is in your css file.有些答案不起作用,但这种方法对我有用,只需按原样复制并粘贴到您的 css 文件中即可。

.datepicker-date-display {
 background-color: rgb(118, 186, 241);
}

.datepicker-cancel, .datepicker-clear, .datepicker-today, .datepicker-done {
 color:rgb(69, 143, 204);
}

.datepicker-table td.is-today {
 color: rgb(69, 143, 204);
}

.datepicker-table td.is-selected {
 background-color: rgb(118, 186, 241);
 color: #fff;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM