Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a simple page that consists of a form. There is a string for what the input box should be, and then the input box.

I want two different behaviors. When a cell phone is accessing the page, I want everything to be stacked on top of each other, but when the page is accessed via a computer I want multiple rows consisting of the the title, followed by the input box on the same row.

I've researched media queries by I still don't understand it enough to get through.

<html>
    <head>
        <style>

        </style>
    </head>
    <body>
        <form>

            <center>
            <div class="left">
                First name:
            </div>
            <div class="right">
                <input type="text" name="firstname"/>
            </div>
            <div class="left">
                Last name:
            </div>
            <div class="right">
                <input type="text" name="lastname"/>
            </div>
            <div class="left">
                Email Address:
            </div>
            <div class="right">
                <input type="text" name="email"/>
            </div>
            <div class="left">
                Address:
            </div>
            <div class="right">
                <input type="text" name="address"/>
            </div>
            <div class="left">
                I've practiced yoga for at least one year:
            </div>
            <div class="right">
                <input type="checkbox" name="oneyear"/>
            </div>
            <div class="right">
                <input type="submit" name="submit" value="submit"/>
            </div>

            </center>
        </form>
    </body>
</html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
204 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have multiple choice: using Bootstrap to easily display your grid in different ways on window resize. You can also use media queries, combine with a grid layout like Flexbox or Grid. Or even use Jquery and the windworesize function. Personnaly, i would choose Flexbox and the flex-direction propriety when the window reach the size of a smartphone or tablet. To write a media querie, you just have to type something like @media screen and (max-width: 640px) for instance and write your rules inside the curly brackets.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...