Maintain consistent distance between checkboxes and their corresponding labels

I have a set of 10 checkboxes that look like this:

[]  Arts   []  Dance  []  Karate 
[]  Volleyball   []  Basketball  

Currently, I am using the following CSS styles:

#tagstype_tags .tag_select {
    padding-left: 240px !important;
    width: 500px !important;
}
.tag_select label {
    margin-right: 15px;
    margin-left: 10px;
}

How can I modify the styling to achieve the following layout for the checkboxes?

[]  Arts         []  Dance        []  Karate 
[]  Volleyball   []  Basketball 

Answer №1

To determine the layout, it is crucial to consider your markup structure. For instance, if you have a list with list elements, you could implement the following approach:

<ul>
<li class="checkboxLI"><input type="checkbox" name="volleyball"><label>Volleyball</label></li>
<li ...
</ul>

Subsequently, you can set the list elements to be displayed as 'inline-block' with a static width of your choice. In this case, the label might have 10px padding on the left side.

ul {
    display:block;
    width:100%;
}
.checkboxLI {
    display:inline-block;
    width:150px;
}
.checkboxLI input {
    display:inline;
}
.checkboxLI label {
    display:inline;
    padding-left:10px;
}

It is important to note that long labels may cause wrapping issues that are unavoidable.

I trust this information proves helpful,

Regards, Uwe

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

Is the z-index useless when the button is positioned behind divs and other elements?

I would like the "Kontakt" button to appear in the top right corner of the page, always on top of everything else. I have tried setting the z-index to z-index: 99999999999 !important;, but it doesn't seem to be working... On desktop, the button displ ...

A guide on creating a downward animation of an object using CSS3

I am currently working on practicing CSS 3 animation. I am facing a challenge in figuring out how to make the item fall down the page at full speed without needing the user to track it downward with the mouse, all without using javascript. Ideally, I want ...

How can I maintain an element in the open position in jQuery slideUp/slideDown function if it has a certain

I am working on a menu that includes both parent and child elements. When you hover over a parent item with children, the submenu smoothly slides down, and when you hover off, it slides back up. However, I am facing a challenge. How can I modify this jque ...

The proper way to link a style sheet within an MVC framework

Currently, I am working on transitioning a website that I created in the Atom text editor to an ASP.NET environment. To adhere to best practices, I have decided to implement the MODEL VIEW CONTROLLER design pattern in this project. While attempting to ad ...

Eliminate any space from the navigation bar on my website

I just started learning HTML and I'm struggling with some whitespace issues on my navigation bar. Can anyone help me figure out what's causing it? div.nav { background-color: black; color: white; font-size: 20px; font-weight: bold; ...

Adding a button to the right of a text-field input in Vuetify app

I need advice on the best way to use Vuetify in order to display a button to the right of a text-field (attached). I've checked the main site for information but couldn't find anything related to this specific scenario. https://i.sstatic.net/Pp ...

How to implement jQuery CSS hover effect using jQuery?

I've configured the hover opacity in my CSS, .button-simple:hover { opacity:.70; filter:alpha(opacity=70); filter: "alpha(opacity=70)"; } However, the hover opacity is not displaying after adding this line to my code, $('input[type ...

What's the best way to reduce the dimensions of this container in order to align them next to one another?

https://i.sstatic.net/VHahe.jpg As a novice student in the world of coding with html and css, I have embarked on a project to create a website. However, I've encountered a minor issue... I'm looking to adjust the width of these boxes so they al ...

Leveraging font as a comprehensive repository of icons

I have been experimenting with using entypo as the icon source for my web application. The UI technology I am working with is ZK. However, I encountered an issue when trying to include an icon from that font by using: <span sclass="entypoWhite">&am ...

Displaying the user's username upon logging into a website is a simple yet effective

I have successfully developed a simple web page using PHP and HTML. However, I am facing an issue in displaying the username after login. Additionally, I would like to hide the login and signup sections after successful login. Can anyone provide assistance ...

Having trouble with my Bootstrap 4 navbar button - what am I doing wrong?

After conducting research online, I found myself unable to resolve my issue due to my lack of proficiency in English. I apologize for any confusion caused and would like to revisit the topic. The problem lies with my navbar toggle that is not functioning ...

Struggling to Align Responsive Navigation Bar Items?

Learning how to create a responsive website by following a tutorial here Facing an issue: Unable to position elements to the right of the <ul> within the <nav>. Everything seems to fall below or not align properly. Trying to add a login form n ...

Having trouble aligning the unordered list with the input

Can anyone help me troubleshoot my CSS so that the list appears below the input field? Check out this example The nested menu in this example is positioned too far to the left and slightly too high. It should be aligned with the bottom of the containing ...

Overlaying images responsively on top of each other

I have successfully achieved the result of displaying an image over another image using the following code: <div class="row"> <div class="col-lg-6 col-md-6 col-sm-12"> <div class="image-with-overlay"> <div clas ...

What is the best way to split an image in half without displaying it and avoiding any horizontal scrolling on the page?

https://i.sstatic.net/Kj99o.png https://i.sstatic.net/W1BQ8.png Trying to align the two images shown above, but facing issues with making it responsive. The SVG image exceeds the container boundaries, causing horizontal scrolling. The goal is to have the ...

Issues with Bootstrap split button display malfunctioning

Experiencing an issue with a Bootstrap split button while working on a test Drupal website. Although it seems to be working fine in Codepen and JSFiddle, on this particular website, the dropdown component appears to be getting pushed under the button. Desp ...

Issue with Internet Explorer 7 causing table to display with added height

Currently investigating why there is additional space being added by IE. The only fixed data is the width of the image (171 px). Using Jquery, I checked the height of the div in Firefox, Chrome, and Opera which came out to 164px, but in IE 7 it's 172 ...

What could be causing my getAsFile() method to return null?

Below is the code I have been working on: document.getElementById("Image_Panel").addEventListener('paste', (event) => { console.log("Initiating image paste - Step 1"); const clipboardData = event.clipboardData; // Checking ...

`CSS Content Placeholder Issue When Used Alongside JavaScript`

Let me explain a bit, I have a master page named UserProfile.master which has a content placeholder linked to UserProfileWall.aspx. Now, I am trying to incorporate some additional JavaScript and a second CSS file in the userprofilewall page. However, whene ...

Tips for creating a mobile-friendly contact section on your website

I have encountered an issue with my Contact Us page. Although it works perfectly on desktop, the mobile view is not responsive. Is there anyone who can assist me in resolving this error? Here is the Contact Us page that needs to function properly on mobil ...