The table will grow horizontally instead of vertically
P粉087074897
P粉087074897 2023-09-15 17:32:14
0
1
612

I'm trying to make a calculator and am currently working on HTML and CSS. I'm trying to make the calculator larger both vertically and horizontally. I can easily increase the width to fit the container using width: 100% or flex: 1 1 100%; however, whenever I try to increase the height with height: 100%; it goes outside the bounds of the container and the input button becomes huge. I've tried using flex-basis and flex-grow to make it grow vertically as well, but I can't.

<body>
    <div class="container">
            <form>
                <div class="display">
                    <input type="text" name="display">
                </div>
                <div class="column1">
                    <input type="button" value="AC">
                    <input type="button" value="+/-">
                    <input type="button" value="%">
                    <input type="button" value="/">
                </div>
                <div class="column2">
                    <input type="button" value="7">
                    <input type="button" value="8">
                    <input type="button" value="9">
                    <input type="button" value="*">
                </div>
                <div class="column3">
                    <input type="button" value="4">
                    <input type="button" value="5">
                    <input type="button" value="6">
                    <input type="button" value="-">
                </div>
                <div class="column4">
                    <input type="button" value="1">
                    <input type="button" value="2">
                    <input type="button" value="3">
                    <input type="button" value="+">
                </div>
                <div class="column5">
                    <input type="button" value="0">
                    <input type="button" value=".">
                    <input type="button" value="=">
                </div>
            </form>
    </div>
</body>


html {
    height: 100%;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    height: 100%;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    height: 50%;
    width: 30%;
}

form {
    flex: 0 1 100%;
}

.column1, .column2, .column3, .column4, .column5, .display {
    display: flex;
    height: 100%;
}

.column1 input, .column2 input, .column3 input, .column4 input, .column5 input, .display input {
    flex: 1 1 100%;
}

P粉087074897
P粉087074897

reply all(1)
P粉574268989

The following is the specific operation method:

.container{
    /* height: 50%; */
    width: 100%;
}

.column1, .column2, .column3, .column4, .column5, .display{
    height: calc(100vh/6);
    /* Distributing the viewport height within 6 columns */
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template