Place a radio button on top of a div once the available space is depleted

Is there a way to make these radiobuttons hover over the topchoice and bottomchoice divs? I may need to adjust the width of choicefirstleft and choicesecondleft, potentially making it 100%. However, when the width approaches 100%, the radiobutton shifts down as seen in the example on jsfiddle...

I'm unsure how to ensure that these buttons remain above the colored divs. Any suggestions?

HTML:

<div id="results">
    <div id="topchoice">
        <div class="result">
            <?php echo $topresult; ?>
        </div>
        <div id="choicefirstleft">
            <label for="yes">Yes</label>
        </div>
        <input type="radio" id="yes" value="1" name="votingvalue"></input>
    </div>
    <div id="bottomchoice">
        <div class="result">
            <?php echo $bottomresult; ?>
        </div>
        <div id="choicesecondleft">
            <label for="no">No</label>
        </div>
        <input type="radio" id="no" value="2" name="votingvalue"></input>
    </div>
</div>

CSS:

 #topchoice{
        margin-top: 40px;
        overflow:hidden;
        background-color: #000;
        opacity: 0.9;
    }

    #bottomchoice{
        margin-top: 5px;
        overflow:hidden;
        background-color: #000;
        opacity: 0.9;
    }
    #choicefirstleft{
        width:30%;
        background-color:greenyellow;
        float:left;
        z-index: 1;
    }
    #choicesecondleft{
        width:99%;
        float: left;
        background-color: red;
        z-index: 1;
    }

    #results{
         font-size: x-large;
        width: 50%;
        margin:0 auto;   
        color: white;
        overflow:hidden;
    }

    #results input{
        float:right;


        z-index: 4;
    }

http://jsfiddle.net/K3Qgf/

Answer №1

I created the container

position: relative; 

and then changed it to

position: absolute;

for the radio buttons (using a new class)

Check out the code here

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

Ways to eliminate the lower boundary of Input text

Currently, I am working on a project using Angular2 with Materialize. I have customized the style for the text input, but I am facing an issue where I can't remove the bottom line when the user selects the input field. You can view the red line in t ...

Is there a way to create a glow effect in CSS that considers the background color?

Exploring ways to create realistic-looking LEDs using HTML and CSS has been a fun challenge. Achieving a glowing effect for each LED would be simple if the color remained constant. However, I aim for the glow to dynamically adjust based on the LED's c ...

ID is not receiving the CSS styles

I'm having trouble applying my CSS to a specific img ID element on the page. I've been trying to solve this for about 30 minutes with no luck. The strange thing is, I have two other elements with the same HTML and CSS that are working correctly. ...

Strange FontAwesome input placeholder issue

I'm trying to use an icon from FontAwesome in the placeholder of an input field. Here is my code snippet: <input type="password" name="password" placeholder="&#xf023; &nbsp; Password"> However, when I view it on the screen, it appear ...

Angular application featuring scrolling buttons

[Apologies for any language errors] I need to create a scrollable view with scroll buttons, similar to the image below: Specifications: If the list overflows, display right/left buttons. Hide the scroll buttons if there is no overflow. Disable the le ...

Generate numerous lines of div elements

I am looking to set up a 2x2 layout with 4 div elements. Check out my experiment in this fiddle where I utilized inline-block for display. My goal is to position "div 3" and "div 4" directly beneath 1 and 2, respectively. Is there a way to achieve this wit ...

Setting image height for consistent display across all browsers

I have searched both this forum and Google before posting this question, but unfortunately, the methods provided do not seem to work for me. Perhaps I am doing something incorrectly. The page I am working on looks like this: enter image description here ...

Difficulty in placing the logo within the navigation menu

Currently working on developing a website and encountering challenges with positioning the logo within the navigation bar. A test version of the site can be found at The logo is not centered properly in its designated space, especially in smaller browser ...

2 column setup in the last row of a CSS grid

Can anyone help me troubleshoot an issue with aligning two buttons to the right in a form using CSS grid? I've attached a screenshot for reference. https://i.stack.imgur.com/DFGrx.png **css ** .wrapper { width:75%; padding-top: 15px; padd ...

Is there an HTML tag that can contain a block of JavaScript code without being processed by the browser?

I am dealing with the code below: <!-- Facebook Pixel Code --> <script> !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; n.push=n;n.loaded= ...

Including React components in my HTML documents

I have developed a node.js server using express and am rendering an html page with jsx code embedded. The server is running smoothly, but I am encountering difficulties when trying to import other jsx components into my html file to utilize them in my main ...

Utilizing CSS to set a map as the background or projecting an equirectangular map in the backdrop

How can I set an equirectangular projection like the one in this example http://bl.ocks.org/mbostock/3757119 as a background for only the chart above the X-axis? Alternatively, is it possible to use an image of a map as a CSS background instead? .grid . ...

Add CSS styling to a single form

When working on a larger project, the goal is to reduce the size of various elements within a form named quickpost-form <div id="qp-form"> Specific elements in the form require a smaller font size such as text, input, input-group, and tex ...

The content of the SELECT tag cannot be generated using Ajax and HTML

I am working with the following snippet of HTML code: <select id="c0" name="countries" onchange="show_other()"> <option value="1">something</option> <div id="c1"> </div> </select> Within this code, I have the i ...

Arranging items in a vertical column using CSS based on the content

I am facing an issue with aligning the values in a column under each other without percentages using my own html code, css, and bootstrap classes: <div class="d-flex"> <p class="table-string">91.86</p> <span ...

Navigate to a unique component

I am attempting to navigate to the location of a custom component, but the reference to it is not returning a valid HTML node. The function "goToContactUs" should execute this action. What would be the most effective approach to accomplish this? class H ...

Managing custom Bootstrap 4 styles and assets within Yii2 framework

Recently, I integrated the yii2-bootstrap4 extension into my yii2-advanced project and customized it using a Sass file named custom.css. After adding custom.css to frontend/web/css, I made modifications to frontend/assets/AppAsset.php as shown below: cla ...

How to create a thumbnail hover effect with CSS3 and javascript, overcoming the z-axis issue

Currently, I am working on creating a set of thumbnails that enlarge when hovered over. The initial setup achieves the zoom effect using CSS3 transform:scale and ease-in-out. However, the issue is that the enlarged images overlap each other due to sharing ...

Guide to highlighting a particular letter in a string variable using JavaScript and AngularJS

Looking to highlight specific letters within a string variable. I have the string stored as an AngularJS variable in a table like this: <td>{{variable}}<td> In my JavaScript file, I am passing a variable for Angular that contains the string & ...

Incorporating a new component into the table tab design with HTML

One more question to wrap up the day. Here is my current setup along with the corresponding CSS: <p>&nbsp; </p> <p>&nbsp; </p> <div class="row tab-cover"> <div class="col-sm-4"><a href="/home" target=" ...