How to change text in the input bar - forms

I have this code for my form, it inherits the text color of the theme am using, I want give a different color to the text in the input text bar, I have the form below. Thanks

input{
color: [some color];
}
Try doing it in css. Might want to add a class to the css/input to uniquely identify it and avoid global styles.
This can either go in a css stylesheet or a style tag on the page.
A stylesheet in generally recommended, but a style tag would go above the markup like this
<style>
input{
color: [some color];
}
</style>

Related

Declarative Initialization list width kendo autocomplete

Is there any way to decoratively define the List width in the HTML.
I know I can do it
var autoComplete = $("#autoComplete").data("kendoAutoComplete");
// set width of the drop-down list
autoComplete.list.width(400);
but I want to do it in HTML only.
I have already tried:
data-list-width="400"
When you create an autocomplete in Kendo UI, it creates a second HTML element (a wrapper) for the drop down options. This element is given as id the id of the original one plus -list.
You can define a CSS style for this newly created wrapper as:
#autocomplete-list {
width: 300px !important;
}
You need to use !important otherwise the value calculated by Kendo UI has prevalence over yours.
Example in this JS Fiddle: http://jsfiddle.net/OnaBai/n55w8/
I got the answer from telerik today:
Currently, the width of the popup element can be set only programatically.
Salam!
The .width(400) is not a configuration setting, it is jQuery width method, so you can't set width for your autocomplete decoratively.
If you use MVVM framework in your project, maybe Custom binding help you to add a custom binding like <input id="autoComplete" data-bind="listwidth: 400" /> for your autocomplete.
See this demo if you want to use custom binding.

GWT2.4 how to get margin width in GWT, which was set in css

I set a margin for a panel in css. Now I need to get the margin width in GWT. How could I do this?
For example, I set a css style for the panel
<ui:binder>
.panel{
margin: 5px;
}
<g:HTMLPanel Ui:field=myPanel styleName="{style.panel}" />
</ui:binder>
In GWT 2.4, how can I retrieve the margin value (5px) in GWT class.
I have tired these, DOM.getIntStyleAttribute(myPanel.getElement(), "margin"),
DOM.getIntStyleAttribute(myPanel.getElement(), "marginWidth"), and myPanel.getElement().getStyle().getMargin(). all of these return 0.
How can I get the margin width then?
Thanks for replying.
Regards
You're looking for the computed style, but are requesting the element style.
If you were to set the style attribute on an element directly, then you could query the element's margin like you tried.
<!-- style can only be set on html elements, not widgets -->
<div ui:field="divElement" style='margin:5px'></div>
divElement.getStyle().getMargin();
From what I could find, GWT does not provide a method for looking up the computed style. You will instead need to rely on an external library. A quick google search for gwt computed style will provide you with a few options.
Alternatively, you could define the margin width as a GWT CSS constant and use a CssResource to access it.
MyPanel.ui.xml
<ui:style field="style" type="com.myproject.client.MyPanel.MyStyle">
#def marginWidth 5px;
.panel{ margin: marginWidth; }
</ui:style>
MyPanel.java
#UiField MyStyle style;
interface MyStyle extends CssResource {
String marginWidth();
}

How can I use the same #def in multiple CssResource css files?

I'd like to say, in a single, centralized location,
#def mainColor = #f00;
and then, in all of my other css files, refer to mainColor without having to redefine it. Then when I change mainColor in once place, my entire app changes color.
The best way I can think of so far is to include two #Source files for every CssResource declaration and always include the global def file. Are there any other ways?
As far as I know, this is your only option:
style.css
#def mainColor #f00;
*.ui.xml
<ui:style src="../../../styles/style.css">
.widget{ color: mainColor; }
</ui:style>
The downside to this is the relative path. Each ui.xml will require a different src path.
Alternatively, if you dont mind using a Constants.java file (instead of css),
you could use #eval
<ui:style>
#eval mainColor com.myproject.client.Styles.INSTANCE.mainColor();
.widget{ color: mainColor; }
</ui:style>

GWT StackLayoutPanel: how to change header background color

I want to change stacklayoutpanel header back ground color using css and I tried everything.
.gwt-StackLayoutPanel .gwt-StackLayoutPanelHeader .gwt-StackLayoutPanelContent .gwt-StackLayoutPanelItem {
color: red;
border:red;
border-color: red;
background:red;
background-color:red;
}
But only changed the text color and I don't want that. Please can you explain how can I do that?
StackLayoutPanel wraps hour header widget/text to an internal class named Header, which is not publicly accessible. One approach is to override default clean.css .gwt-StackLayoutPanel .gwt-StackLayoutPanelHeader styles by copying it to your own css file, then appending !important to styles you want to change.
However, better and cleaner solution is to do the following:
// add/insert your item first
myStackLayoutPanel.add(widget, header, size);
// retrieve the Header internal widget (AFTER ADDING!)
Widget internHeader = header.getParent();
// replace default style
internHeader.setStyleName("my_custom_style");
If you don't like using class css styles, you may alternatively do something like:
... same as above
// reset the default style
internHeader.setStyleName("");
// then add your styles programmatically
Style style = internHeader.getElement().getStyle();
style.setBackgroundColor();
etc.
It is important to retrieve the internal header widget after call to add/insert!
Your CSS style is incorrect. It's trying to target classes with the following hierarchy:
.gwt-StackLayoutPanel
.gwt-StackLayoutPanelHeader
.gwt-StackLayoutPanelContent
.gwt-StackLayoutPanelItem
Which is completely incorrect. If you want ALL elements with those classes to have the same background color, you would write your CSS rule like this:
.gwt-StackLayoutPanel,
.gwt-StackLayoutPanelHeader,
.gwt-StackLayoutPanelContent,
.gwt-StackLayoutPanelItem
{
background-color: red;
}
You better create your own css file based on gwt's default and make changes there. You also need to exclude gwt default css from your_module.gwt.xml and put there your newly created

Applying css in TinyMCE

I am implementing ForeColor in TinyMCE Rich Text Editor.
it uses style to apply forecolor to selected text as like this
<span style="color: rgb(255, 0, 0);" mce_style="color: #ff0000;">Hello</span>.
i want to apply css class instead of "style" here.. how to apply css class here? These Css Classes contain ColorCodes.
Example:
<span class="colorRed">Hello</span>
My CSS Class
.colorRed
{
color: #ff0000;
}
thank you
Because you want your css to be applied to tinymces editor content you will need to add your class to the class your editor content gets styled with.
If you are not using a user-defined content_css file when initializing tinymce (init-function) a content_css file will be used depending on the theme you have set in the init function (file used is to be found in a subfolder of folder themes).
I suggest you create an own content.css which you load using content_css setting in the init function. See this link for the tinymce documentation for this. For a first step you could copy one of the content.css from the themes directory and modify it.
Search on content_css attribute an add your CSS file relative path(i.e:myLibFolder/myCss.css) after adding ","
$('textarea.tinymce').tinymce({
//
//
//....
,
content_css: "css/content.css,myLibFolder/myCss.css"
,
//
});