Customizing the appearance of a radio button within a form

I need assistance with styling a form that contains a radio button. I'm looking to customize the appearance of the radio button by adding a background image and also changing the default view of the check image. Additionally, I want the form to be centered on the screen and highlighted with a line. My code can be found on jsfiddle:

           <style>
                form{
                    font-size: 200%;
                    font-family: "Courier New", Monospace;
                    display: inline-block;
                    align: middle;
                    text-align: center;
                    font-weight: bold; 
                     background-size: 20px; 
                }     

                input[type="radio"] {
                      width: 26px;
                      height: 26px;
                      background: url(check.png) no-repeat;

                }

                </style>

http://jsfiddle.net/chrathan/q1mnq2os/2/1

I am seeking guidance on how to achieve these customizations.

Answer №1

Here's a suggestion:

*{box-sizing: border-box}
form{
    font-size: 200%;
    font-family: "Courier New", Monospace;
    text-align: center;
    font-weight: bold; 
    width: 320px;
    margin: 0 auto;
    background-size: 20px; 
}     

input[type="radio"] {
    width: 26px;
    height: 26px;
    visibility: hidden;
    display: none
}
label{
    position: relative;
    margin-right: 40px
}
label:after{
    content: '';
    position: absolute;
    right: -40px;
    top: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border: 2px solid blue;
    border-radius: 50%;
}
input[type="radio"]:checked + label:after{
    background: red; /*add your background image here*/
}
<form class = "form"  action="action2.php"  method="post">
    
    <a href=' .$user. ' style=\"text-decoration:none;\"> "' .$user. '" </a><br><br>
    <p>
        <input   type="radio" name="classif" id="C1" value="true" checked="checked" hidden />
        <label for="C1">FASHION</label>
    </p>
    
    <p>
        <input type="radio" name="classif" id="C2" value="false" hidden />
        <label for="C2"> NON FASHION </label>
    
        <input type="hidden" name="imageName" value="' . $line . '">
    </p>
    
    <input   type="submit"   value="submit"  />
    </form>;

Answer №2

Aligning a form in the center:

To align the form in the center, you can do the following:

display:inline-block

Replace the above code with:

margin:0 auto

This will center the form on the page.

Check out the updated jsfiddle here.

Here is a helpful resource for styling radio buttons.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to centering a list on a webpage using Bootstrap 3

Looking to create a centered list using the latest version of Bootstrap 3. Any tips? The desired list should be positioned in the middle of the page. ___________________________________________ | | | ...

Steps to creating a popup within an HTML page from another HTML page

I recently started learning JavaScript. I have a link on my homepage that directs to another HTML page, but I would like it to show as a popup on the homepage with responsiveness and some stylish design elements such as a folded corner. Is there a way to a ...

Is there a way to set the starting position of the overflow scroll to the middle?

Is there a way to have the overflow-x scrollbar scroll position start in the middle rather than on the left side? Currently, it always begins at the left side. Here is what it looks like now: https://i.stack.imgur.com/NN5Ty.png If anyone knows of a soluti ...

jQuery UI - Add character right before the final element

My slider is set to range from 10 to 1000 with increments of 20 (10-30-50, etc). I'm looking to add a character before the value on the last step (1000). Currently, it shows values like "560 kr/h" or "400 kr/h", but I want it to display ">1000 kr ...

Adjusting the position of the parent div by manipulating the bottom property

Is there a way to toggle the bottom property of a div when clicking its child anchor tag? <div class="nav" :class="{ 'full-width': isFullWidth }"> <a class="toggle-button" @click="toggleNav"><i class="fa fa-angle-down">< ...

Utilize API or alternative methods for analyzing Instagram data

My master's thesis requires me to dissect multiple Instagram profiles, each containing over 1000 posts. I am in need of a comprehensive list including the following details: Type of Post (Image, Multi Image, Video) Description Likes Comments (total c ...

Can the content inside HTML tags be susceptible to XSS attacks?

While working with Codeigniter, I have noticed that the xss_clean() function is replacing tab characters with a single space character. This behavior ends up causing issues when the content is later displayed within <pre><code></code>< ...

The act of resizing a window causes the text to be forcibly expelled from its containing div

When you hover over an image in a grid, text and a button appear. However, when the window is resized, the content ends up overflowing out of the div. This issue is part of my first project that I am working on during a bootcamp. I have decided to keep th ...

Blazor Razor Component Library (RCL) Lacks CSS IntelliSense

I am encountering an issue with the CSS intellisense in my razor class library (RCL) that houses all the pages of my Blazor application. It appears that the CSS intellisense is not functioning within the RCL unless I modify the RCL .csproj xml tag From Sdk ...

Adjustable background image with no need for a scroll bar

I am looking to create a static webpage that remains fullscreen without any scrolling. My goal is to have a centered form with the background image adjusting to the window size. As a beginner, I apologize if this request seems too simple. .container { ...

"Capture input value changes and display the previous value when submitting a post. See an example of

Hi there! I'm facing 2 issues with my code, you can find a DEMO here When adding a product to the sale form, the input field for `description` changes for all products. Changing the input product in the sale does not reflect the change. I have shar ...

Having trouble retrieving alert message after submitting form using jquery

Trying to submit a form using jQuery, but when clicking on the submit button it displays a blank page. I understand that a blank page typically means the form has been submitted, but I want to show an alert() for testing purposes instead. However, it only ...

The hover drop-down menu in CSS is not appearing in the correct position

Having trouble with my navigation bar - the dropdown menu isn't showing up below the category when I hover over it. It keeps ending up in the left-hand corner and I can't access it! I've searched everywhere for a solution, but can't fin ...

Modify the text when clicked on, but do not change the span

I'm currently attempting to change the text within an anchor (<a href=>) element when another element is clicked. The structure of the HTML is as follows: <h1> <a href=""> replace this text <span class="breadcrumb" ...

The issue with HTML5 anchor download attribute for saving files cannot be resolved

When I use an anchor tag like this.. <a class="btn btn-download" href="https://www.anotherdomain.com/file.jpg" download="customname.jpg">Download</a> The file is downloaded as file.jpg instead of customname.jpg Interestingly, it works fine i ...

Stop SCSS from processing CSS variables in Angular-CLI

I am currently using Angular5 with sass v1.3.2. My goal is to dynamically change a color that is widely used in the scss files of my single page app without having to recompile new files. This color is globally defined in my _variables.css as: $brand: # ...

How can I populate a <select> tag with options dynamically using C# when the page loads?

I am using jQuery ajax to populate cascaded dropdown elements from a database. The issue I'm facing is that I can't seem to add the default "Select Program" option at the top of my first dropdown dynamically. Even though I tried using the prepend ...

Ways to resolve the issue of truncated lines while displaying HTML content in WebView on Android devices

When displaying content in a WebView, I am encountering an issue where the top and bottom lines are being cut off. What steps can I take to resolve this problem? My current approach involves using HTML to present data within the WebView. ...

The CSS provider for Gtk+3 is malfunctioning

I've been attempting to set an image as the background of a GtkBox using a CSS provider, and also customize the style of some label text, but no matter what I try, nothing seems to work. Below is the content of my custom.css file: GtkBox#Home_Princi ...

Conflict between jquery and hoverIntent libraries

I've encountered an issue with a website that was functioning properly until we added a new form to a specific page. The form, created by another person, utilizes javascript/jQuery for processing. Since adding this form, it has caused the majority of ...