What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Div tag not fitting into top of screen despite having sufficient room

WinPeps

New member
Joined
May 18, 2024
Messages
1
Reaction score
0
HTML Coins
0
I am trying to write some frontend code for an arduino project and I am trying to fit a div with two buttons in it into the top right of the screen. However, it seems that no matter what I try it wants to go one layer down from the top. How can I fix this?

All of my code:
HTML:
<!DOCTYPE html>
<html>
    <head>
        <style>
            .container {
              width: 100%;
              height: 100vh;
            }

            .toppane {
              width: 100%;
              height: 10vh;
            }

            .leftpane {
              width: 33.333%;
              height: 45vh;
              float: left;
            }

            .middlepane {
              width: 33.334%;
              height: 45vh;
              float: left;
            }

            .rightpane {
              width: 33.333%;
              height: 45vh;
              float: right;
            }

            body {
              margin: 0!important;
            }

            .d-flex {
              display: flex;
            }
            button {
              display: block;
              margin: 10px 0;
              padding: 10px;
              width: 100%;
              height: 100%;
            }
            input {
              width: 90%;
              height: 40%;
              type: number;
              font-size:35px;
            }

        </style>
    </head>
    <body>
        <div class="container">
            
            <div class="toppane" style="background-color: #7d9de3; width: 66.667%"><button style="background-color: #7d9de3; border-color: #7d9de3"><h1>UPLOAD!</h1></button></div>
            <div class="toppane" style="width: 33.333%; float:right; height: 10vh">
                <h1>
                    <button id="increase" style="margin: 0px 0; padding 0px">Increase Text Size</button>
                    <button id="decrease" style="margin: 0px 0; padding 0px">Decrease Text Size</button>
                </h1>
            </div>
            <div class="leftpane" style="background-color: #8e63cf"><button style="background-color: #8e63cf; border-color: #8e63cf" onclick="startPopups()"><h1>POP-UP NAVIGATION</h1></button></div>
            <div class="middlepane" style="background-color: #d1fc97"><h1><label for="FreqPlMn">The box below increases or decreases the minimum frequency (tone) of the buzzer. Please enter a value from 0 to 100. The default is 50.</label></h1><input id="FreqPlMn" name="FreqPlMn" min="0" max="100" type="number"></input></div>
            <div class="rightpane" style="background-color: orange"><h1><label for="FreqScale">The box below increases or decreases the scaling of the frequency (tone) of the buzzer. Please enter a value from 0.5 to 1.5 below. The default is 1.</label></h1><input id="FreqScale" name="FreqScale" min="0.5" max="1.5" type="number" step=".1"></input></div>
            <div class="leftpane" style="background-color: #fc9df9"><h1><label for="Max">The box below increases or decreases the maximum buzz distance of the buzzer. Please enter a value from 200 cm to 800 cm. The default is 800cm.</label></h1><input id="Max" name="Max" min="200" max="800" type="number" step="10"></input></div>
            <div class="middlepane" style="background-color: red"><h1><label for="DelayPlMn">The box below increases or decreases the minimum delay of the buzzer. Please enter a value from 100 ms to 1000ms. The default is 100ms.</label></h1><input id="DelayPlMn" name="DelayPlMn" min="100" max="1000" type="number" step="100"></input></div>
            <div class="rightpane" style="background-color: lightgreen"><h1><label for="DelayScale">The box below increases or decreases the scaling of the delay of the buzzer. Please enter a value from 0.5 to 1.5 below. The default is 1.</label></h1><input id="DelayScale" name="DelayScale" min="0.5" max="1.5" type="number" step=".1"></input></div>
        </div>
        <script>
            function startPopups() {
                let FreqPlMn = prompt("FreqPlMn", "50");
                let FreqScale = prompt("FreqScale", "1");
                let Max = prompt("Max", "800");
                let DelayPlMn = prompt("delayPlMn", "100")
                let DelayScale = prompt("delayScale", "1");
            }
        </script>
        <script>
        document.addEventListener('DOMContentLoaded', (event) => {
            // Select the buttons
            const increaseButton = document.getElementById('increase');
            const decreaseButton = document.getElementById('decrease');

            // Add event listeners to the buttons
            increaseButton.addEventListener('click', () => adjustFontSize(1));
            decreaseButton.addEventListener('click', () => adjustFontSize(-1));

            function adjustFontSize(change) {
                // Select all elements you want to adjust (e.g., paragraphs, divs, etc.)
                const elements = document.querySelectorAll('h1, button, label'); // Add more selectors as needed
                elements.forEach(element => {
                    // Get the current font size
                    const currentSize = window.getComputedStyle(element, null).getPropertyValue('font-size');
                    // Convert the font size to a number and adjust it
                    const newSize = parseFloat(currentSize) + change;
                    // Apply the new font size
                    element.style.fontSize = `${newSize}px`;
                });
            }
        });
        </script>

    </body>
</html>

Here is an example of it not working:
1716053302907.png
 
It might help if you split up the toppane into two (one for the upload, and the other for the buttons) like you've done for the others.

Other than that, I think it could work if you float the toppane left.
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back