Text enclosed in personalized checkboxes

Thank you for dedicating your time to offer assistance.

I am currently in the process of customizing checkboxes for a website built with bootstrap. Unfortunately, I have limited CSS skills and haven't been able to achieve the desired outcome.

My goal is to create a calendar where each date is represented by a checkbox that users can select. The design I envision includes a light grey bordered circular checkbox with the date (1, 2, 3...31) positioned at the center. On hover, the circle should darken and display a pointer cursor, while clicking on it will change the circle to blue, with the font color adjusting for readability. The dates will be generated dynamically using a PHP loop to populate the checkbox id, name, and value.

Despite my efforts, I haven't found a working solution and have experimented with various techniques to customize checkboxes. One major challenge I face is maintaining the centered alignment of the date within the button, regardless of the varying width of numbers like "1" and "29".

I am uncertain whether redefining the checkbox in CSS is the correct approach. This uncertainty extends to inserting the date text (1, 2, 3...31) using PHP or hiding the checkbox off-screen and styling a DIV or SPAN differently based on its state. However, I struggle to make the Bootstrap DIV/SPAN elements fully responsive to the applied CSS styles.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.css">
<style>
    .control-me::after {
        color: black;
        background-color:white;
    }
    #toggle:checked ~ .control-me::after {
        color:white;
        background-color:blue;
        }
    .visually-hidden {
        position: absolute;
        left: -100vw;
    }
</style>    
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://localhost/choreboard/css/bootstrap.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</head>



<body style="background-color: #E0E0E0">
<div class="row justify-content-center">
        <div class='col-9'>
            <div class="d-flex justify-content-around flex-wrap">
                <div><label for="test"><input type="checkbox" id="test" class="visually-hidden"><div class="control-me border border-dark rounded-circle text-center m-1" style="height: 30px; width: 30px;"><span class="align-middle">2</span></div></label></div>
                <div class="bg-primary rounded-circle text-center m-1" style="height: 30px; width: 30px"><span class="align-middle text-light">17</span></div>
                [...]
            </div>
        </div>
    </div>
</body>

I have removed unsuccessful attempts from the code, and this is the stage where I need assistance. Please note that only the first date is interactive. Additionally, I struggle to effectively manipulate Bootstrap class inputs using CSS.

Could there be a more effective method to achieve this task?

Warm regards, Seth

Answer №1

Give bootsrap custom select a shot

<div class="input-group mb-3">
  <select class="custom-select" id="inputGroupSelect02">
    <option selected>1</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
  </select>
  <div class="input-group-append">
    <label class="input-group-text" for="inputGroupSelect02">Options</label>
  </div>
</div>

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

Tips for positioning a button in relation to its parent element

I'm running into an issue with absolute positioning on my website: I'm trying to place a button relative to its parent element, and here is what I've attempted: .parent { position: relative; } .child { position: absolute; top: 0px ...

:hover functionality can only be activated within the Inspector

The element top_fixed_right:hover on my homepage is functioning perfectly. However, on a different page, the same div only responds to the :hover state when forced using Chrome's developer tools. Normal mouse hovering does not trigger it. I tried op ...

Is it possible to display a React Component code within a <code> tag?

I am in the process of creating a tester page that allows users to interact with a library component and document how it is being used. Here is the library component: render = () => { let component = ( <Slider onSlid ...

Vue Labyrinthine Design theme

Looking for some guidance from experienced developers out there! I'm currently exploring how to incorporate Mazeletter as a background feature for each page in an app project I've been working on. This is all new territory for me, so any assista ...

Challenges of Python Web Scraping: Insufficient Extraction of HTML Code

As someone new to Python, I am currently experiencing difficulties with my web scraping code. The script is able to access the website and bypass cookies successfully. However, it is failing to capture the entire HTML code. Here is a snippet of the HTML c ...

PHP Table Sorting Functionality

After inputting the correct code, I am still facing an issue with the table sorting not showing up. Can someone assist me with this problem? I have included both my CSS styles and PHP coding. Thank you for your help! Here is a visual representation of the ...

Smooth scrolling in JavaScript can lead to unexpected jumps when using scroll-margin-top

I am currently working on implementing smooth scrolling into my website using JavaScript. However, I have run into a problem with CSS property scroll-margin-top causing a sudden jump at the end. The CSS I am using for scroll margins looks like this: class ...

What is the best way to send multiple PHP variables to an ajax function when clicked?

I'm encountering an issue while trying to pass variables to a function in my controller using AJAX. The error message at the bottom of the image is preventing the variables from being passed successfully. My setup involves the use of the CodeIgniter ...

Populating HTML elements with JSON data

I need help loading multiple JSON objects into individual divs in an HTML file. Each object should be displayed in a separate div, with the first object going to the first div, the second object to the second div, and so on. I believe I need to use a for l ...

The alignment of links is not meeting the centering requirement

I'm facing a challenge with aligning my "buttons" on the pages, although they are essentially text links designed to resemble buttons using CSS. These buttons are utilized within an unordered list structure (refer to the HTML snippet below). The rele ...

To extract the plain text from a paragraph element and the src and alt values from its child image tag, you can use the following method

I have this retrieved from the database: <p><img style="margin: 5px; float: left;" alt="rotary-wheelchairs" src="images/stories/DSC_0693_400x400.jpg" />In a 2 week period, the Rotary Club of Playa, in partnership w ...

Dynamic PHP script for managing varying quantities of modules within a designated module slot

In the process of developing a Joomla 3.8 template from scratch using Bootstrap 4.0, I am also learning Bootstrap 4.0 and PHP simultaneously. Please be patient with me as I navigate through this learning journey. Beneath the main component area, there is ...

Is it possible for the logo in the div and the height of the div to vanish after 10 seconds?

Is it possible to conceal a div along with its logo? I currently have a jpeg logo displayed at the top of my website, but I would like it to vanish after 10 seconds and have the text below it shift upward to fill the space. I've managed to hide the ...

Is there a way to enable hover functionality on mobile devices? I wish for the hover effect seen on desktop to be triggered automatically on mobile devices

I attempted to implement @media (hover: hover) without success. In my design, I have three images in a row that reveal a text overlay when hovered over with a mouse. However, the issue arises when I try to switch to a mobile view, as the images remain un ...

How can I make sure my rows are properly aligned using the Grid

Looking at the image below, I am attempting to align "Ticket Number" and "Email" using a Grid: View My Result Image <Grid container direction="row" justifyContent="flex-start" alignItems="stretch" style={{ pad ...

Expand the object by clicking on it, causing the surrounding objects to move outside the viewport instead of appearing below

I'm facing a challenge with 3 squares inside one container, each occupying 33.33% of the viewport and placed next to each other. When I click on one square, it should expand to full viewport width and reveal hidden content, while the other two remain ...

Using CSS to overlay text on an image on a webpage

Can anyone help me with this puzzling scenario? <TD><a href="index-1.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','images/m21.jpg',1)">Home</a><img src="images/m2.jpg" nam ...

Loop through the numbers entered into a table field

<table id="Container1Details" cellspacing="15"> <tbody> <tr> <td align="right"> <input name="acidity" type="number" maxlength="4" id="acidity" min="0.112" max="0.152" step="0.001" style= ...

Endless stream of text flowing in a continuous line within each paragraph

I am trying to create a unique scrolling effect for each line in a paragraph. The goal is to have each line repeat after one scroll is completed. For example: Let's say there is a line like this in the paragraph: 1,2,3,4, The desired outcome is for ...

dynamic dropdown displaying colors for selection

Using a bootstrap form to add a printer involves selecting the material and color. The dynamic dropdowns are functioning correctly, but it is necessary to display the selected color for user clarity. Please guide me on how to pass the color along with its ...