Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

× Contact Enhanced is a contact component manager created to replace Joomla! core contacts component and add lots of advantages and new features (see Features ) and it offers many plugins and modules for several different purposes,
Product page | Documentation Page

Need help making fancy checkbox styling

5 years 11 months ago #24202 by rustle
Hi Guys
I have been using your software for years and it gets better with every install 8)

I have a customer who is requesting a very fancy styling on their checkboxes, in their email form (see attached screen cap).

I have built this type of thing in the past, but it involves adding some html to the output of the input type="checkbox" so that we can hide the default web browser output, and then style away, as is discussed here:
www.w3schools.com/howto/howto_css_custom_checkbox.asp

I do not see how to override the html output of form fields with Joomla overrides and I tried to be sneaky with the CE php field and make my own input field but I could get nothing to work...

Would you be able to advise on how I could get control of the html output of the checkbox field, or some other way I could achieve the illustration attached?

Thanks in advance

Attachments:

Please Log in or Create an account to join the conversation.

5 years 10 months ago #24203 by support
Dear rustle,

I'm glad you like our extensions. ;-)

Recently another user hired us to implement the W3Schools custom checkboxes as a custom work for him. So I can now share the results with you.

Create a CSS Form Field and add these CSS rules:
/* Customize the label (the container) */
label[class*="ce-radiobox"],
label[class*="ce-checkbox"] {
  display: block;
  position: relative;
  padding-left: 35px;
  margin-bottom: 12px !important;
  cursor: pointer;
/*  font-size: 22px; */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
 
/* Hide the browser's default radio button */
label[class*="ce-radiobox"] input,
label[class*="ce-checkbox"] input {
  position: absolute;
  opacity: 0;
}
 
/* Create a custom chebox and radio button */
.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 25px;
  width: 25px;
  background-color: #eee;
}
/* Create the radio round border */
label[class*="ce-radiobox"] .checkmark{
  border-radius: 50%;
}
 
/* On mouse-over, add a grey background color */
label[class*="ce-radiobox"]:hover input ~ .checkmark,
label[class*="ce-checkbox"]:hover input ~ .checkmark
{
  background-color: #ccc;
}
 
/* When the radio button is checked, add a blue background */
label[class*="ce-radiobox"] input:checked ~ .checkmark,
label[class*="ce-checkbox"] input:checked ~ .checkmark{
  background-color: #89a408;
}
 
/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}
 
/* Show the indicator (dot/circle) when checked */
label[class*="ce-radiobox"] input:checked ~ .checkmark:after,
label[class*="ce-checkbox"] input:checked ~ .checkmark:after{
  display: block;
}
 
/* Style the indicator (dot/circle) */
label[class*="ce-radiobox"] .checkmark:after {
  top: 9px;
  left: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}
 
label[class*="ce-checkbox"] .checkmark:after {
  left: 9px;
  top: 5px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 3px 3px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}
You'll just have to change the background-color attributes to match your template colors

Create or edit an existing JS Form Field with the following content:
jQuery(document).ready(function($){
	$( ".cf-type-radiobutton input, .cf-type-checkbox input" ).after("<span class='checkmark'></span>" );
});


This code allows you to achieve the W3Schools example you've provided, not the screenshot. If you want to hire us to customize Contact Enhanced to match the screenshot, please contact us using the Support -> Contact form.

Best wishes,
The following user(s) said Thank You: blue_Shift

Please Log in or Create an account to join the conversation.

5 years 10 months ago #24204 by rustle
You are AWESOME

I will report back when complete and share any css i create

Please Log in or Create an account to join the conversation.

5 years 10 months ago #24207 by rustle
This JS snippet doesn't work as intended for the illustrations above.... very close

this js adds a <span></span> before the value of the label which is great for adding a checkbox before the <label> value... but what I need to achieve is to change the styling of the <label> elements when the option is selected.
Or wrap the label value in a <span></span>.

using your js field how would I be able to wrap the label value or target the css class?

Please Log in or Create an account to join the conversation.

5 years 10 months ago #24216 by support
Dear Rustle,

The CSS and JS I provided is to implement the same approach in the W3Schools link you've provided:

rustle wrote: I have built this type of thing in the past, but it involves adding some html to the output of the input type="checkbox" so that we can hide the default web browser output, and then style away, as is discussed here:
www.w3schools.com/howto/howto_css_custom_checkbox.asp


We have not implemented any CSS and JS changes to allow you to change the CSS styling of the label as you requested. If you'd like a customization quote, please use the Support -> Contact form.

Thanks for understanding and best wishes,

Please Log in or Create an account to join the conversation.

5 years 10 months ago #24219 by rustle
Done
please reply asap as I am a bit behind on this task

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback