Changing the style properties via Tritium - css

Newbie question, I'm working on a simple scenario: Changing the background color and the text of a giving element on my page using Tritium. My page looks like this:
<div class="hero" id="hero">
<div id="heroContentShort">
<div class="heroContentShort">
<h1 style="text-transform:capitalize;">My Text<span style="text-decoration:underline;font-weight:bold;">- on Moovweb</span></h1>
</div>
</div>
On my .TS file I have the following:
insert("div", class:"cus_title"){
insert("div", class:"cus_row1"){
move_here("//div[#id='hero']/div/div/h1")
attribute("background", "red")
text("My New Text")
}
}
The above is successfully changing the text, although is not preserving any format nor is changing the background color to red.
What I'm doing wrong?
Thanks

First and foremost, I highly recommend you not do the coloring in tritium. The DOM and the style should be separate. I would recommend you put this at the bottom of your main.scss file if you do not want to create your own page. Then you would do:
.cus_row1 {
background-color: red;
}
That would get the background color to work perfectly, and correctly.
However, if (for some reason) you HAD to do this in tritium, I would instead do this:
insert("div", class:"cus_title"){
insert("div", class:"cus_row1"){
move_here("//div[#id='hero']/div/div/h1")
attribute("style", "background-color: red")
text("My New Text")
}
}
The first reason, is that the background attribute is deprecated. Second, the user agent stylesheet can overwrite it. I hope this works for you!

Related

how can I change highlight text color for only a react component?

I am using react and want to change text highlight color.
First I went for a working solution:
Highlight.css
::selection {
background:#fbc308;
color: black
}
somecomponent.tsx
import './highlight.css'
However, it changes text highlight color for every elements, which is not I want.
And,
<div style={{"::selection" : {
background:"#fbc308",
color: "black"}}}><p>Something</p></div>
didn't work (error)
So, I went for:
.somecomponent p::selection {
...style
}
But however it only changes p elements. I want to change all text highlight color in a component.
Thanks.
Thanks for Eduard's answer, I resolved it by
.somecomponent *::selection

Change ion-refresher & ion-infinite-scroll color

It's a "simple" request but I'm not able to achieve this result...
In my app I have these two components:
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingIcon="ios-arrow-down-outline"
pullingText="Scorri per aggiornare"
refreshingSpinner="circles"
refreshingText="Aggiornamento...">>
</ion-refresher-content>
</ion-refresher>
and
<ion-infinite-scroll [enabled]="morePagesAvailable" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content
loadingSpinner="bubbles"
loadingText="Caricando più post ...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
And they works fine with a white background. Now I need to change the background color to black but now the text of the two components it's not visible anymore because it's black by default.
How can I change che color of the two components?
I tried with a CSS class but the color it's not applied.
How is it possible to customize these components?
Thank you
As docs suggest (at least for version 1 of ionic):
The ionSpinner icon to display after user lets go of the refresher.
The SVG ionSpinner is now the default, replacing rotating font icons.
Set to none to disable both the spinner and the icon.
Closes thing in SVG to color is fill property. so you may use it instead of color.
Hope this helps
HTML Code
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content class="loadingspinner"
loadingSpinner="crescent"
loadingText="Loading...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
Respective CSS
.loadingspinner{
--color : #adadad;
}
.spinner-crescent{
color: #adadad;
}
If this helps someone. You have to add a class to the infinite scroll content or just use the tag selector.
<ion-infinite-scroll [enabled]="morePagesAvailable" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content
class="infinite-scroll-color"
loadingSpinner="bubbles"
loadingText="Caricando più post ...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
And then change the stroke property of the tag line, to change the spinner svg color.
.infinite-scroll-color {
line {
stroke: #YOURCOLOR;
}
//If you want to change the text color too, just add this css
.infinite-loading-text {
color: #YOURCOLOR;
}
}
Cheers!

CSS Styling Angular 2+ (pain in the butt)

Ok, i am new to Angular 4. I am having issues with styling the application properly. I went ahead and added a background image to the body, this worked as expected, then added a component that would display content and it looked as expected.
I added a second component different route but for this one I do not want the body to have the background image at this point i am not sure what is the best practice.
I read a few articles and some say that you can have a different style for the body at the component level by adding a body style override in the styleUrls. I did this but everytime i went from say /myroute/page2 to myroute/page1 the background sticked to what i set for myroute/page2 while it should show the body image for /myroute/page1. I am also using ViewEncapsulation set to None (maybe this is the issue)?.
Also this is my setup and may be wrong too
index.html has something like this:
</head>
<body>
<app-root></app-root>
</body>
</html>
then my app.component.html has this:
<app-navigation></app-navigation>
<router-outlet></router-outlet>
<app-footer></app-footer>
and then i have my welcome.component.html that has a section
<section id="hero">
<div>
</div>
</section>
Now the component above shows the background set correctly, but if I navigate using something like
this.router.navigate(['/page2']);
the background stays the same as in my welcome component. If i refresh on /page2 the right background now shows up.
UPDATE:
Ok i gave up on showing the background on the second component, i wanted without background image, but want to keep the one in the first component. So i removed the ViewEncapsulation from all of them but now if I move the body {} to the first component it does not show it for some reason (I made sure it has the right path). Is there a better fix than removing it by using the DOM?. What is the best practice?.
You need to set style class on ngOnInit and remove it on ngOnDestroy.
constructor(private renderer: Renderer2) {
}
ngOnInit() {
this.renderer.addClass(document.body, 'your_class');
}
ngOnDestroy() {
this.renderer.removeClass(document.body, 'your_class');
}
This worked for me, pls try. In your component1,
ngOnInit() {
document.body.style.background="url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSu5rIAFQkkswZLuwAUCXZqc_8bBROGkGgmZP5bmGk57sRKXWJMEg)";
}
ngOnDestroy() {
document.body.style.background="";
}
In your component2,
ngOnInit() {
document.body.style.background="url(http://gkreading.com/wp-content/uploads/2017/03/awesome-kid-in-the-grass.jpg)";
}
ngOnDestroy() {
document.body.style.background="";
}
Hope this helps.

Css with id and class

Hello and greetings to you all.
I have a strange reaction with css in one website that i'm making.
There is this code
<a class="instagram-photo image" id="p1130472628000663001_176824616" href="PROFILE" target="_blank" data-name="NAME" data-caption-std="Colors #thefeditor" data-caption="Colors #thefeditor <a target="_blank" href="INSTA LINK;>View Photo</a> " data-created="1448982860" data-author="AUTHORNAME" data-likes="87" data-comments="0" data-profile="PROFILE LINK" rel="group"><img src="IMAGE LINK"><span class="journal-meta">Example Name<span>username</span></span><span class="icon">Image</span></a>
The above image is set with the following background color.
media="all"
.classic-view .instagram-photo.image {
background-color: #3dc0f1;
}
I'm trying to change the blue color (#3dc0f1) color to this
background-color:rgba(255,215,0,0.6) !important;
With no luck because i want to change the color ONLY to this id
id="p1130472628000663001_176824616"
because if i go to the custom css and put this css code
.instagram-photo
{
background-color:rgba(255,215,0,0.6) !important;
}
It changes all the images, but i want to change the images with the ID that i gave you above.
I have tried
#p1130472628000663001_176824616.instagram-photo {
background-color:rgba(255,215,0,0.6) !important;
}
But it didnt work. Any idea of how can i make it work? Thanks!
P.S. the answer below is also correct but i also managed to do it with
a[id*="_176824616"][class*="image"]
{
background-color:rgba(255,215,0,0.6) !important;
}
Thanks a lot!
Why not just doing:
.instagram-photo#p1130472628000663001_176824616
{
background-color:rgba(255,215,0,0.6) !important;
}
That way, you are declaring a rule to CSS that says that you want to set the background color to an element of class instagram-photo and with id having your id - notice that the class and id are concatenated to one phrase on the rule. This is done in order to specify the rule containing both class and id on a specific element and not the nested ones.
Also, consider that for simplicity, you could simply do:
#p1130472628000663001_176824616
{
background-color:rgba(255,215,0,0.6) !important;
}
By "saying" to CSS you want to apply the rule only to the element(s) with the specific ID, without taking into consideration its class - this is specific on your case, so it should work fine.
In addition, consider avoiding using !important, as this can lead to unexpected behavior on your rules and violates the sequence the rules are applied.

How to change the background color of the tooltip only in grid in Kendo UI MVC?

In my page,I use tooltip which class name is .tooltipcell to the grid cell,and also use tooltip which class name is .tooltipbtn to the button.Now I want to change the background color of the tooltip in grid,but I do not want to affect the background color of the button tooltip.How to do that?I use to codes below,it affects the two tooltip.
method1:both effect
.k-widget.k-tooltip{
background-color:red; //set the desired color
}
method2:both effect
div .k-widget.k-tooltip{
background-color:red; //set the desired color
}
JS
show: function (e) {
e.sender.popup.element.addClass('red-tooltip');
},
and CSS
.red-tooltip {
background-color: #f00 !important;
}
You can do this:
.tooltipcell{background-color:green;}
.tooltipbtn{background-color:green;}
Just incase your div .k-widget.k-tooltip might overwrite the style you may have to target it deeper like this:
div .k-widget.tooltipcell{background-color:green;}
div .k-widget.tooltipbtn{background-color:green;}
The is an amendment to MarioD Answer.
I didn't test it but given that it works, a better practice would be to concatenate these classes. It saves size in the css and improves loading time. Do this:
div .k-widget.tooltipcell, div .k-widget.tooltipbtn {
background-color:green;
}
I had the same problem where I was using kendo tooltip. I wanted to change the CSS of the tooltips only in one place leaving the rest of the tooltips intact.
Using css the normal way to do this would be to use target .widget and .k-tooltip CSS classes.
Although this would change all the tooltips within a page.
So, since I wanted to change only one tooltip (same problem as this post) I had to do a JS approach.
So, I had to use the show function of kendo's tooltip.
Example:
$('.target')..kendoTooltip({
position: 'bottom',
showAfter: 1000,
content: 'test',
function(e) {
e.sender.popup.element.addClass('customClass');
}
}).data('kendoTooltip');
I will try to post here a jsfiddle in few moments.
André

Resources