Tips on properly showcasing user input in this code

I am struggling to make the "Custom" option appear inline with some text and input boxes, like this:

Custom: I would like [ ] x [ ].

However, the display of the text boxes is not working due to a hidden attribute.

I attempted to add the following CSS:

#product .sizes input:not([type:"text"]) 
{
  display: none;
}

But it resulted in a large text box appearing - I'm unsure how to resolve this issue. It's probably a simple fix that I can't seem to figure out.

Any assistance would be greatly appreciated!

#product .sizes label{
  position: relative;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1.5rem;
  text-align: center;
  height: 80px;
  line-height: 80px; 
  display: block;
  cursor: pointer;
  border: 3px solid #2fcc71;
  border-radius: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

#product .sizes label span{
display: inline-block !important;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1rem;
  text-align: left;
  height: 10px !important;
  line-height: 10px !important;   
}

#product .sizes input:checked + label{
  border: 3px solid #333;
  background-color: #2fcc71;
  color: #fff;
}

#product .sizes input:checked + label:after {
  content: "\2713";
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 100%;
  border: 2px solid #333;
  background-color: #2fcc71;
  color: #fff;
  z-index: 999;
  position: absolute;
  top: -10px;
  right: -10px;
}

#product .sizes input {
display: none;
}   
<form id="product">
    <section class="sizes">
  <div id="fixedSize"></div>
  <div id="ChooseSize">
  <input type='radio' name='radio_size' id='size1' value='1'><label class='size1-label cell' for='size1'>Standard</label>
  <input type='radio' name='radio_size' id='size2' value='2'><label class='size2-label cell' for='size2'>Different</label>
  <input type='radio' name='radio_size' id='size3' value='3'><label class='size3-label cell' for='size3'>Custom: I would like <input type="size_h"> x <input name="size_w" type="text"></label>
  </div>
</section>  
</form>    

Answer №1

To style inputs inside a label using CSS, you can simply target them with the following code:

#product .sizes label > input {
   display: inline;
}

With this selector, you have the flexibility to customize the inputs as needed. For example, controlling their width using the width property...

#product .sizes label{
  position: relative;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1.5rem;
  text-align: center;
  height: 80px;
  line-height: 80px; 
  display: block;
  cursor: pointer;
  border: 3px solid #2fcc71;
  border-radius: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

#product .sizes label span{
display: inline-block !important;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1rem;
  text-align: left;
  height: 10px !important;
  line-height: 10px !important;   
}

#product .sizes input:checked + label{
  border: 3px solid #333;
  background-color: #2fcc71;
  color: #fff;
}

#product .sizes input:checked + label:after {
  content: "\2713";
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 100%;
  border: 2px solid #333;
  background-color: #2fcc71;
  color: #fff;
  z-index: 999;
  position: absolute;
  top: -10px;
  right: -10px;
}

#product .sizes input {
display: none;
}
#product .sizes label > input {
   display: inline;
   width: 30px;
}
<form id="product">
    <section class="sizes">
  <div id="fixedSize"></div>
  <div id="ChooseSize">
  <input type='radio' name='radio_size' id='size1' value='1'><label class='size1-label cell' for='size1'>Standard</label>
  <input type='radio' name='radio_size' id='size2' value='2'><label class='size2-label cell' for='size2'>Different</label>
  <input type='radio' name='radio_size' id='size3' value='3'><label class='size3-label cell' for='size3'>Custom: I would like <input type="size_h"> x <input name="size_w" type="text"></label>
  </div>
</section>  
</form>

Answer №2

To customize the radio inputs using CSS, you can add a specific class to them:

<input type='radio' class='radio' ... >
#product .sizes input.radio {
    display: none;
}

Another option is to assign IDs to the inputs you want to display and then override the CSS:

<input type='radio' name='radio_size' id='size3' value='3'><label class='size3-label cell' for='size3'>Custom: I would like <input id="input-h" type="size_h"> x <input id="input-w" name="size_w" type="text"></label>
#input-w, #input-h {
    display: inline;
}

#product .sizes label{
  position: relative;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1.5rem;
  text-align: center;
  height: 80px;
  line-height: 80px; 
  display: block;
  cursor: pointer;
  border: 3px solid #2fcc71;
  border-radius: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

#product .sizes label span{
display: inline-block !important;
  color: #2fcc71;
  background-color: #fff;
  font-size: 1rem;
  text-align: left;
  height: 10px !important;
  line-height: 10px !important;   
}

#product .sizes input:checked + label{
  border: 3px solid #333;
  background-color: #2fcc71;
  color: #fff;
}

#product .sizes input:checked + label:after {
  content: "\2713";
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 100%;
  border: 2px solid #333;
  background-color: #2fcc71;
  color: #fff;
  z-index: 999;
  position: absolute;
  top: -10px;
  right: -10px;
}

#product .sizes input.radio {
    display: none;
}   
<form id="product">
    <section class="sizes">
  <div id="fixedSize"></div>
  <div id="ChooseSize">
  <input type='radio' class='radio' name='radio_size' id='size1' value='1'><label class='size1-label cell' for='size1'>Standard</label>
  <input type='radio' class='radio' name='radio_size' id='size2' value='2'><label class='size2-label cell' for='size2'>Different</label>
  <input type='radio' class='radio' name='radio_size' id='size3' value='3'><label class='size3-label cell' for='size3'>Custom: I would like <input name="size_h" type="text"> x <input name="size_w" type="text"></label>
  </div>
</section>  
</form>    

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 JQuery drop-down correctly

Although I am not well-versed in JQuery and struggle with CSS, I often find myself working with both. Currently, I have encountered a problem: The jquery script I am using involves clicking on an image to reveal a login box that drops down using slideTogg ...

Creating an ASP.NET MVC application, the index table seems to extend beyond the confines of the page

Embarking on the journey of creating my first web app after years of mastering C# Windows Forms development in .NET has been a thrilling adventure. Following the guidance of the NerdDinner tutorial, I've tweaked certain components to align with my pro ...

How can I use CSS to target a class defined in an XML file?

Looking at this Xml snippet, I'm interested in finding out how one can target the class "down" using css to apply consistent styling to similar code sections. The necessary css references have been correctly included at the beginning of my xml file. ...

"Creating dynamic web apps with the powerful duo of Meteor and Zurb

Just starting out with programming and currently working on a new web application using Meteor and AngularJS. I would like to incorporate the elements/css from 'Zurb Foundation For Apps' into my project... I am familiar with including Bootstrap ...

How can we display an absolutely positioned div when hovering over a card with the help of Tailwind CSS?

I am currently working on a Next.js application with Tailwind CSS. I would like to implement a feature where additional information is displayed when hovering over a product card, similar to the functionality seen on wildberries.ru. I have tried using &apo ...

Exploring the distinctions between width/height measurements and the image attribute in styling

What is the benefit of using a style image attribute instead of individually coding width and height for each image? ...

Achieve perfect centering for content and left align text with CSS Grid

It seems like there should be a simple solution to this issue, but I'm having trouble finding it. I'd like to replicate the layout shown in the image linked below: https://i.sstatic.net/5GsWL.png The challenge is to center the item and quantity ...

html scroll to the flickering page

Why is it that when a user clicks on a link in the list, the browser flickers? This issue becomes especially noticeable if a user clicks on the same 'link' twice. Is there a solution to prevent this from occurring? The problem also seems to aris ...

I am experiencing issues with my background image not fully expanding or displaying correctly in the html section. Any assistance with troubleshooting the background image would be greatly appreciated

I am currently exploring Bootstrap and I am new to front-end development. I do not have a separate CSS file, only an HTML file included in my Python Django project. In this file, I am attempting to add a background image to my section. However, the image ...

Show where the image should be placed according to the coordinates of the mouse click

My project begins with a blank canvas, prompting the user to click anywhere on the page to reveal an image. My goal is to show an image at the exact location where the user clicks. Although I can successfully trigger an image to appear in the corner of the ...

Outlook's text feature does not adhere to standard line-height specifications

While working on an HTML email, I encountered an issue with Outlook 2010. Here is the code snippet: <td background="images/11-text-1--alpha-d3c29e.jpg" bgcolor="#d3c29e" width="514" height="460" valign="top"> <!--[if gte mso 9]> ...

What is the best way to set the title of the <span>/<div> tag in order for it to display the <br/> tag in the content and show a tooltip on separate lines?

I have this AngularJS code sample that reads the HTML tag within the data and displays the content on the screen with the following message: Hi Mike! Good Morning!!! I need to modify it so that the title or tooltip also shows the content in two separa ...

Issue with a responsive CSS circle element that holds an image

I'm struggling to figure out how to create 9 responsive CSS circles in a row, with each circle containing an img tag rather than a background image. The goal is to center the img and resize it based on the size of its parent circle div. These 9 circle ...

OrbitControls in THREE.JS fail to function properly when a DOM Element is layered on top of the scene

I am attempting to position labels as elements with position:absolute; over a THREEJS scene. The issue arises when the mouse hovers over one of the labels (the red box in the example below), causing the events that trigger OrbitControls to be "halted" by t ...

What is the best way to conceal menus on Big Cartel?

Is there a way to hide menu items on a custom theme without having to create a new one? I'm looking for a solution like adding something to the stylesheet. Any suggestions would be appreciated! <div id="store" class="clearfix"> <div id=" ...

CSS Tip: Enhance your divs by adding a vertical pipe to each one

I am looking to insert a pipe character between links, with the exception of after the last one. The HTML is being rendered in such a way that it has the same class applied. <!DOCTYPE html> <html> <head> <style> p:last-of-type { ...

Moving through divisions that share a common class name using jquery

I am experimenting with a plugin that allows me to attach popups to images. My goal is to enable navigation between all popups using previous and next buttons upon clicking on a popup. Below is the element when it's displayed: <div class="imp-too ...

How can I target specific elements to toggle the active class using Javascript?

At the moment, I have a function that highlights my navbar menu items based on which one I clicked. However, the issue arises when there is a button inside my navbar receiving the highlight class upon clicking. I'm unsure of how to modify the JavaSc ...

The sticky positioning feature seems to be malfunctioning exclusively on mobile devices

I have encountered an unusual issue while working on my cafe-shop menu. Despite finding a solution in a standalone HTML file, the menu doesn't function properly when inserted into one of the pages of my WordPress theme - specifically, it only works on ...

Tips for toggling the appearance of like and add to cart icons

I am attempting to create a simple functionality for liking and adding items to a cart by clicking on the icons, which should immediately change the icon's color when clicked. However, I am facing an issue where the parent div's link is also bein ...