Jump to content

Recommended Posts

Posted

Hi,

 

I like to change the font color of a button when I move my mouse over it.

To achieve this I changed the css:

 
.x-btn {
  background: white !important;
}
 
.x-btn-over {
  background: black !important;
}
 
But this doesn't work.
 
 

 

  • 8 years later...
Posted
42 minutes ago, plawan001 said:

Do you have an example?

1. UniServerModule -> CustomCSS:

.customBtnOver .x-btn-inner {
  color: green;
  font-weight: bold;
}

2. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniButton1.JSInterface.JSConfig('overCls', ['customBtnOver']);

end;

 

image.png.18d64c51e1b7f908127ac07c49fbc787.png

Posted

Where you want to change the color ?

On Form creation or on button click ?

here is javascript code in button click: uniSession.AddJS (document.getElementById("YOUBUTTON_jsID").style.color = "red";);

this change background: uniSession.AddJS (document.getElementById("YOUBUTTON_jsID").style.background = "green";);

Posted
4 minutes ago, plawan001 said:

I set green according to the method you provided the sample

 

46 minutes ago, Sherzod said:
.x-btn-inner

You may already using this class, where possible already used !important

Posted
2 hours ago, plawan001 said:

Test.zip 6.88 MB · 1 download

1. 

.button1 {
  background:white !important;
  border: 2px solid #4CAF50;
}

.button1:hover {
  background:#4CAF50 !important;
  border: 2px solid #4CAF50; 
  color: white !important;
  transition-duration: 0.5s;
}

.customHover .x-btn-inner {
  color: white !important;
  transition-duration: 0.5s;
}

2. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniButton1.JSInterface.JSConfig('overCls', ['customHover'])
end;

 

Posted
8 minutes ago, plawan001 said:

I did and it still doesn't work.
The font still doesn't change color when mouse over the button.

1. Modified CSS:

.button1 {
  background:white !important;
  border: 2px solid #4CAF50;
}

.button1:hover {
  background:#4CAF50 !important;
  border: 2px solid #4CAF50; 
  color: white !important;
  transition-duration: 0.5s;
}

.customHover .x-btn-inner {
  color: white !important;
  font: italic small-caps bold 12px/30px Georgia, serif;
  transition-duration: 0.5s;
}

2. Do not forget

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniButton1.JSInterface.JSConfig('overCls', ['customHover'])
end;

3. Result:

BtnHover.gif.5fc458f69d2c442b386b98b2d1d1938b.gif

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...