Why does my checkbox keep getting pushed to the next line?

I'm struggling to get the checkboxes and labels on the same line, they always end up on separate lines. I tried using the inline-block property within the "slide" div as suggested in other posts, but it's not working for me. Any advice?

Appreciate your assistance.

* { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; -o-box-sizing:border-box; box-sizing:border-box; }

html { width: 100%; height:100%; overflow:scroll; 
    background: url("gym.jpg") no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

body { 
    width: 100%;
    height:100%;
    font-family: 'Open Sans', sans-serif;
}

.login { 
    position: absolute;
    top: 43%; /* Form is 45% from top */
    left: 50%; /* Form is 50% across screen*/
    margin: -150px 0 0 -150px; /* Position of form on screen */
    width:300px; /* width of form */
    height:300px; /* height of form */
    border: 5px;
}

h4 {
    color: #fff;
    text-shadow: 2px 2px 4px #000000;
    letter-spacing:1px; 
    text-align:center; 
    margin-bottom: 15px;  /* Space below title */
}

.login input {
    width: 100%; /* 100% of form */
    margin-bottom: 10px; /* gap in between each element */
    background-color: rgba(0,0,0,0.5); /* background color (opacity 3) of all INPUT elements in login class*/
    border: none; /* Border of input elements in login class */
    outline: none;
    padding: 10px; /* height of each input element in login class*/
    font-size: 13px; /* font size */
    color: #fff; /* font color */
    border: 1px solid rgba(0,0,0,0.2); /* 1 pixel black border of opacity 2 for each input element in login*/
    border-radius: 4px; /* can curve the login details elements */
}

.slide input {
    width: 10%;
}

.slide {
    display: inline-block;
}

#reps{
    display: none;
}
#exercheckbox:checked ~ #reps{
    display: block;
}
<body>

 <div class="login">

    <h1>Gym Planner</h1>
    <form method="post" action="storeexercisesauto.php">

            <div class="slide">

                <h4>LABEL</h4> <input type="checkbox" name="exercheckbox" id="exercheckbox">
                <input type="text" name="reps" id="reps">

            </div>

        <input type="hidden" name="x" value="<?php echo $x ?>">
        <center><button type="submit" class="btn">Save</button></center>

    </form>

</div>

Answer №1

The heading 4 element typically has a width of 100%. You can achieve this by implementing the following solution:

<span class="tag">TAG</span>
<input type="checkbox" name="exampleCheckbox" id="exampleCheckbox">

.tag {
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px #000000;
    letter-spacing: 1px; 
    text-align: center; 
    margin-bottom: 15px;
}

Answer №2

the <h4> is a block-level element, occupying the entire line. To make it inline, consider adding display: inline or display: inline-block to h4. However, I suggest using <label> instead of <h4>.

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

Navigating through the webpage using CSS gradient backdrop

Check out this page. Under the "Pedidos" section, there is a scrolling area with a gradient background. The issue I'm facing is that I want the background to continue scrolling and repeating as I scroll down the page, but it remains fixed. I tried the ...

Finding attributes with spaces in their values using XPath

Is there a way to select an attribute with spaces in xpath? I am currently trying to select a checkbox attribute named "checked type". I have experimented with //[@checked type], //[@checked-type], //[@checked_type], and //[@checked\stype], but none ...

Ensure all boxes have equal heights

I'm using Boostrap 5 and I have four boxes that are not cards. How can I ensure they are the same height, considering the dynamic content? You can access the Codepen for more information: https://codepen.io/Deluxe23/pen/gOXJWwG Below is an excerpt o ...

"Stylish footer design in CSS featuring a sleek overflow scrollbar

Perhaps the most straightforward way to demonstrate this is by providing a direct link to the website where the addition should be made. I am in desperate need of a basic footer that remains fixed at the bottom of the page, regardless of the amount of con ...

Arrange the labels and input fields within nested elements in a synchronized manner

My data is structured semantically as shown below: <div class="inputs"> <div class="top"> <h4>Top</h4> <label for="top-1">Label 1</label> <input id="top- ...

Detection of Unauthorized Video Downloads

Is it feasible to identify individuals who illegally download videos from websites, such as YouTube, by using video grabber applications? I wonder if these downloads could be traced in some way, enabling the identification of offenders. Is there a method t ...

Unable to determine the data type of the JSON object during the

I'm having trouble reading an Object type of json... Here is the json I'm working with: body: { "111": { "name": "name1", "status": 10000 }, "222": { "name": "name2", "status": 20000 }, "333": ...

An effective method to showcase the HTML content retrieved by getElementsByClassName using JSON.parse()

Can someone help me modify this code so that it displays the value of favFood? It currently works with getElementById but not getElementsByClassName, and I want to use a class: server file - ProcesssingFileOnServer.php: <?php $myObj = new stdClass(); ...

Leveraging Bootstrap with Less, Grunt, and Node for enhanced development capabilities

I recently started using Grunt and I have set it up with grunt/node. I want to add the foundation of Bootstrap for responsiveness, but not the entire css/js. Can someone help me understand how to do this? I've looked at different documentation but sti ...

The website functions perfectly in Firefox, but encounters issues in Chrome

Having an issue with my website where a table is not displaying correctly next to an image in Chrome, even though it works fine in Firefox. Here is the CSS: #right{ float:right; position: absolute; } #left{ float:left; position: absolute; } This is how t ...

The CSS code seems to be ineffective when attempting to center elements with a specific width in react.js

Hey everyone, I'm currently working on developing a web application using react-bootstrap and I've encountered an issue with adjusting the width of my row and centering it. I have already created the necessary CSS and JS files, but I am unable to ...

There are additional elements that can be toggled, but I prefer to only toggle the one that I have selected

Every time I click on a table a, intending to toggle the .info inside the same div, it also toggles the .info in other divs. Can someone provide assistance with this issue? function info() { $('.table a').click(function() { $('.info ...

How can one effectively create a HTML5 poker application using a .NET and Asp.NET MVC backend system?

My goal is to create an HTML5 poker game with a .net and Asp.Net MVC backend. I am particularly interested in how to handle constant refreshes for various sections of the application. For example, let's say there is an active poker table where player ...

How can I modify the style of table rows with CSS?

Is there a way to change the color/background of a selected row just like it does on hover, and also have the option to deselect the row? To see how it looks on hovering, check out: http://jsfiddle.net/q7ApN/ If you want to make a Change: #gradient-styl ...

Why does the border-radius property not work on my image elements?

Greetings! I have defined an ID named #img in my stylesheet with the property border-radius: 15px; In my HTML, I assigned this ID to a div. However, the images within that div are not getting rounded corners as expected. When using the img selector, it aff ...

Showcase a selection of items in a flexbox positioned vertically as a row

Check out my flexbox item and how it appears here This is the html code: <div id="property"> <div style="background-color:coral;"><img :src="item.property_image" width="200px" height=&qu ...

Stop the stream coming from getUserMedia

After successfully channeling the stream from getUserMedia to a <video> element on the HTML page, I am able to view the video in that element. However, I have encountered an issue where if I pause the video using the controls on the video element a ...

"Please note that the function of the enter key to navigate between form fields is

When I use the enter key to move between form fields, it's not working as expected: The cursor doesn't move to another field in the form when I press the enter key. Removing the submit button allows the enter key to work properly. The issue se ...

I am experiencing issues with the functionality of the jQuery function

I am currently diving into the world of jquery. I put together a script, but unfortunately it's not functioning as expected. 1 Here is a snippet of my HTML code <ul id="recur" class="elasticstack"> <li id=<?=$item['id']?> ...

What is the best way to right-align a flex column in Bootstrap 4 while ensuring they maintain equal height?

Learning the new Flex features in Bootstrap has been quite a journey for me. I must confess that I've had little experience with Flex before, especially since it wasn't well-supported in older versions. If you're curious, here's a link ...