Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Andrew Gargano
seal-mask
.a{fill-rule:evenodd;}techdegree
Andrew Gargano
Front End Web Development Techdegree Student 6,603 Points

Form Project - display label and input on the same line.

Hello,

How can make label and input appear on the same line at media break point?

Thank you for your help!

HTML:

<form action="index.html" method="post">

          <h2>Signup for our newsletter</h2>
          <p class="p_intro">Get the latest news on how your code is doing right in your inbox</p>

        <fieldset class="field_contact">
            <legend class="field_header" ><span class="number"></span>Contact Information</legend>

              <label for="name">Full Name</label>
              <input type="text" id="name" name="user_name" placeholder="Required" required>

              <label for="mail">Email Address</label>
              <input type="email" id="mail" name="user_email" placeholder="Required" required>

              <label for="phone">Phone Number</label>
              <input type="tel" id="phone" name="user_phone">

              <label for="address">Street Address</label>
              <input type="text" id="address" name="user_address">

              <label for="city">City</label>
              <input type="text" id="city" name="user_city">

              <label for="state">State</label>
              <select id="state" name="user_state">
                  <optgroup label="Choose State">
                    <option value="AL">Alabama</option>
                    <option value="AK">Alaska</option>
                    <option value="AZ">Arizona</option>
                    <option value="AR">Arkansas</option>
                    <option value="CA">California</option>
                    <option value="CO">Colorado</option>
                    <option value="CT">Connecticut</option>
                    <option value="DE">Delaware</option>
                    <option value="DC">District Of Columbia</option>
                    <option value="FL">Florida</option>
                    <option value="GA">Georgia</option>
                    <option value="HI">Hawaii</option>
                    <option value="ID">Idaho</option>
                    <option value="IL">Illinois</option>
                    <option value="IN">Indiana</option>
                    <option value="IA">Iowa</option>
                    <option value="KS">Kansas</option>
                    <option value="KY">Kentucky</option>
                    <option value="LA">Louisiana</option>
                    <option value="ME">Maine</option>
                    <option value="MD">Maryland</option>
                    <option value="MA">Massachusetts</option>
                    <option value="MI">Michigan</option>
                    <option value="MN">Minnesota</option>
                    <option value="MS">Mississippi</option>
                    <option value="MO">Missouri</option>
                    <option value="MT">Montana</option>
                    <option value="NE">Nebraska</option>
                    <option value="NV">Nevada</option>
                    <option value="NH">New Hampshire</option>
                    <option value="NJ">New Jersey</option>
                    <option value="NM">New Mexico</option>
                    <option value="NY">New York</option>
                    <option value="NC">North Carolina</option>
                    <option value="ND">North Dakota</option>
                    <option value="OH">Ohio</option>
                    <option value="OK">Oklahoma</option>
                    <option value="OR">Oregon</option>
                    <option value="PA">Pennsylvania</option>
                    <option value="RI">Rhode Island</option>
                    <option value="SC">South Carolina</option>
                    <option value="SD">South Dakota</option>
                    <option value="TN">Tennessee</option>
                    <option value="TX">Texas</option>
                    <option value="UT">Utah</option>
                    <option value="VT">Vermont</option>
                    <option value="VA">Virginia</option>
                    <option value="WA">Washington</option>
                    <option value="WV">West Virginia</option>
                    <option value="WI">Wisconsin</option>
                    <option value="WY">Wyoming</option>
             </select>
             <label for="zip">Zip Code</label>
             <input type="text" id="zip" name="user_zip">
        </fieldset>

CSS:

*:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;

}

header { width: 100%; background: #000033; text-align: center; height: 100%; margin-top: 0; padding-top: 0; border-top: 0; }

form { max-width: 300px; text-align: left; margin: 10px auto; padding: 10px 20px;
border-radius: 8px;

}

fieldset { margin-bottom: 30px; border: none;

}

.field_contact { border-bottom: solid;

}

.p_intro { border-bottom: double; padding-bottom: 20px; }

h1 { color: white; margin-top: 0; padding-top: 20px }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="number"], select { background: rgba(255,255,255,0.1); border: none; font-size: 16px; height: auto; margin: 0; outline: 0; padding: 10px; width: 90%; background-color: #e8eeef; color: #8a97a0; box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset; margin-bottom: 30px; }

label[for="topics"] { padding-top: 20px }

textarea { background: rgba(255,255,255,0.1); border: none; font-size: 16px; height: 100px; margin: 0; outline: 0; padding: 10px; width: 90%; background-color: #e8eeef; color: #8a97a0; box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset; margin-bottom: 30px; }

input[type="radio"], input[type="checkbox"] { margin: 0 4px 8px 0; }

button { padding: 19px 39px 18px 39px; color: #FFF; font-weight: 900; background-color: #00b8e6; font-size: 18px; text-align: center; font-style: normal; border-radius: 5px; width: 100%; border: 1px solid #00b8e6; border-width: 1px 1px 3px; box-shadow: 0 -1px 0 rgba(255,255,255,0.1) inset; margin-bottom: 10px; }

legend { font-weight: bold; font-size: 140%; margin: 10px 0 10px 0; }

label { display: block; margin-bottom: 10px; }

label.light { font-weight: 300; display: inline;

}

footer { text-align: center; color: #b4b4cb; padding-top: 20px;

}

::-webkit-input-placeholder { text-align:right; }

input:-moz-placeholder { text-align:right; }

input[type=text]:focus, input[type=email]:focus, input[type=tel]:focus { border: solid; }

.p_intro, h2 { text-align: center; }

@media screen and (min-width: 760px) {

form { max-width: 480px; }

}

2 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

Hey Andrew,

Just make sure that your label and input elements are displayed inline or inline-block. For example:

@media (max-width: 700px) {
    label,
    input {
        display: inline-block;
    }