Is there a way to arrange the components of my form so that the questions are positioned on the left side and the choices are displayed on the right

As I am creating a form, my goal is to align the information within it in a way that places the questions on the left side and the options on the right.

I have experimented with utilizing IDs, centering them, and adjusting their positioning from left to right.

#wholeform {
  background-color: white;
  display: inline-block;
  text-align: center;
  vertical-align: top;
  line-height: 2.0;
  border-radius: 7px;

}
#title {
   max-width: 400px;
  margin: 20px;
    text-align: center;
}
#survey-form {
  text-align: center
}
<div id="wholeform">
<p id="description">Let us know how we can improve freeCodeCamp<p>

  <form id="survey-form">
    * Name: <input type="text" name="fullname"><br>
  * Email: <input type="text" name="email"><br>
    * Age: <input type="text" name="age"><br>
    Which option best describes your current role?<select name="status">
  <option value="student">Student</option>
  <option value="full time job">Full Time Job</option>
  <option value="full time learner">Full Time Learner</option>
  <option value="Prefer not to say">Prefer not to say</option>
   <option value="Other">Other</option>
</select><br>
    * How likely is that you would recommend freeCodeCamp to a friend?<br>
    <input type="radio"> Definitely<br>
    <input type="radio"> Maybe</br>
    <input type="radio">Not sure</br>
    What do you like most in FCC:<select name="options">
   <option value="challenges">Challenges</option>
    <option value="projects">Projects</option>
    <option value="community">Community</option>
    <option value="open source">Open Source</option></select></br>
    Things that should be improved in the future(Check all that apply)<input type="checkbox" name="front-end" value="Front-end Projects"> Front-end Projects</br>
  <input type="checkbox" name="Back-end Projects" value="Back-end Projects" checked> Back-end Projects</br>
     <input type="checkbox" name="Data Visualization" value="Data Visualization" checked> Data Visualization</br>
     <input type="checkbox" name="Challenges" value="Challenges" checked> Challenges</br>
     <input type="checkbox" name="Open Source Community" value="Open Source Community" checked> Open Source Community</br>
     <input type="checkbox" name="Gitter help rooms" value="Gitter help rooms" checked> Gitter help rooms</br>
     <input type="checkbox" name="Videos" value="Videos" checked> Videos</br>
     <input type="checkbox" name="City Meetups" value="City Meetups" checked> City Meetups</br>
     <input type="checkbox" name="Wiki" value="Wiki" checked> Wiki</br>
     <input type="checkbox" name="Forum" value="Forum" checked> Forum</br>
     <input type="checkbox" name="Additional Courses" value="Additional Courses" checked> Additional Courses</br>
   Any Comments or Suggestions?<name="comments" id="comments">
Enter your comment here...
</textarea><br>
    <input type="submit">
    </form>
    </div>

Result expected - Questions aligned left, Options aligned right

Answer №1

Here is a snippet to help you create a layout with questions on one side and answers on the other. Take a look and let me know if this meets your needs.

#wholeform {
  background-color: white;
  display: inline-block;
  border-radius: 7px;
  margin: 50px;
}

.form-group {
  margin-bottom: 1rem;
}

.row {
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  margin-right: -15px;
  margin-left: -15px;
}

.col {
  position: relative;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
}

.col-sm-5 {
  flex: 0 0 41.666667%;
  max-width: 41.666667%;
}

.col-sm-7 {
  flex: 0 0 58.333333%;
  max-width: 58.333333%;
}

#title {
  max-width: 400px;
  margin: 20px;
  text-align: center;
}

#survey-form {}

<div id="wholeform">
  <p id="description">Let us know how we can improve freeCodeCamp
    <p>

      <form id="survey-form">
        <div class="form-group row">
          <label for="staticEmail" class="col-sm-5 col-form-label">* Name</label>
          <div class="col-sm-7">
            <input type="text" class="form-control-plaintext" id="staticName" value="">
          </div>
        </div>
        <div class="form-group row">
          <label for="staticEmail" class="col-sm-5 col-form-label">* Email</label>
          <div class="col-sm-7">
            <input type="text" class="form-control-plaintext" id="staticEmail" value="[email protected]">
          </div>
        </div>
        <div class="form-group row">
          <label for="staticAge" class="col-sm-5 col-form-label">* Age</label>
          <div class="col-sm-7">
            <input type="text" class="form-control-plaintext" id="staticAge" value="">
          </div>
        </div>
        <div class="form-group row">
          <label for="staticSelect" class="col-sm-5 col-form-label">* Which option best describes your current role?</label>
          <div class="col-sm-7">
            <select id="staticSelect" class="form-control" name="status">
              <option value="student">Student</option>
              <option value="full time job">Full Time Job</option>
              <option value="full time learner">Full Time Learner</option>
              <option value="Prefer not to say">Prefer not to say</option>
              <option value="Other">Other</option>
            </select>
          </div>
        </div>
        <div class="form-group row">
          <label for="staticSelect2" class="col-sm-5 col-form-label">* How likely is that you would recommend freeCodeCamp to a friend?</label>
          <div class="col-sm-7">
            <select id="staticSelect2" class="form-control" name="status">
              <option value="student">Student</option>
              <option value="full time job">Full Time Job</option>
              <option value="full time learner">Full Time Learner</option>
              <option value="Prefer not to say">Prefer not to say</option>
              <option value="Other">Other</option>
            </select>
          </div>
        </div>
        <div class="form-group row">
          <legend class="col-form-label col-sm-5 pt-0">Radios</legend>
          <div class="col-sm-5">
            <div class="form-check">
              <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
              <label class="form-check-label" for="gridRadios1">
            First radio
          </label>
            </div>
            <div class="form-check">
              <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
              <label class="form-check-label" for="gridRadios2">
            Second radio
          </label>
            </div>
            <div class="form-check disabled">
              <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
              <label class="form-check-label" for="gridRadios3">
            Third disabled radio
          </label>
            </div>
          </div>
        </div>
      </form>
</div>

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

Activate a button only when a value is inputted into a text box associated with a chosen radio button

I'm facing a challenge with my radio buttons and sub-options. When a user selects an option, the corresponding sub-options should be displayed. Additionally, I want to enable the next button only when text is entered in all sub-option text boxes for t ...

"Exploring the Power of Internal Hyperlinks in HTML

As I embark on my first website building journey, I am faced with a dilemma regarding internal links. While everything runs smoothly locally, none of the internal links seem to work once the site is live. Take for instance this internal link: <a href =& ...

Explaining how to iterate through objects (one by one) in the This.questionnaire.Profile at every click using JavaScript (answer not found in forums)

Creating a series of questions, each part being stored in This.question = {p1: {...}, p2: {...}, p3: {...}, p4: {...}, p5: {...} etc. (and many more). I want to be able to switch from one article to the next every time I click a button... click => next ar ...

The Spring Boot application is having trouble retrieving static files

I started a fresh springboot project and organized the directory structure as follows: view image description here The yml configuration is outlined below: server: port: 8783 servlet: context-path: /spring-demo spring: scan : com.example appli ...

Having trouble with the functionality of Bootstrap's nav-tabs 'show' feature?

I'm having some issues with adding a search box to my glossary. The glossary is created using nested unordered lists (ul) within another ul that has classes of "nav-tabs" and "bootstrap". In the JavaScript code, I am using the following snippet: $j(& ...

Sophisticated filter - Conceal Ancestry

Check out this snippet of my HTML: <td> <a class="button" href="#"> <input id="download">...</input> </a> <a class="button" href="#"> <input id="downloadcsv">...</input> </a> </td> I am ...

Techniques for parsing a String in Objective-C

I am looking to parse a string to replace certain elements within it. If the string contains an <ol> tag, I want to specifically focus on replacing the <li> elements with numbers. I understand that I can utilize the rangeOfString method to c ...

Animate the leftward disappearance of a div to make it vanish

My goal is to create a user interface where users can navigate through different divs. Here is the HTML code: <article id="realize" class="realizeBox"> <div class="shown"> <div class="heading"> <h2>Realisati ...

Python web scraping with BeautifulSoup to gather information

After searching on zillow, I aim to extract all items from the unordered list and target a specific class: "StyledPropertyCardDataWrapper-c11n-8-84-3__sc-1omp4c3-0 bKpguY property-card-data" This class contains information such as price, address ...

What to do when IE6/IE7 margins disappear after moving a relatively positioned floated div using jQuery's .hover()?

Sharing my code with you: http://jsbin.com/uhera3/edit Encountered an issue where the relatively positioned floated divs move to the left in IE7 when using jQuery's .hover() function. Any insights on how to resolve this problem? ...

Discovering the art of line breaks

Imagine I have a random block of text displayed in a single line, like this: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Due to various reasons such as width settings or text-zoom, the text may display as two or more lines on the viewer&apos ...

Adjusting the size of the background image without altering the background color

I am looking to create a background with a gradient color and an overlay background image. The image is simply a transparent icon, but I need to adjust its size without altering the overall background dimensions. Any assistance on this matter would be gre ...

How can I create responsive buttons with icons using material-ui?

I'm working with a material-ui Button that has a startIcon, and I need to hide the button text on smaller screens while still showing the icon. One common solution would be to use the useMediaQuery hook to identify the browser size and render a diffe ...

Securing PHP Code with HTML Encoding

I'm having trouble parsing an HTML page due to encoding issues. Despite trying popular solutions like using utf8_encode() and utf8_decode(), my results remain unchanged. Below is a snippet of my code along with the output. Code $str_html = $this-> ...

Update the chosen option of the <select> element that was generated through PHP if there is a parameter value present in the URL

I'm currently working on a code snippet like this: <select name="id" id="id"> <OPTION VALUE="null">Select<OPTION> <? foreach ($genres as $row){ ?> <OPTION VALUE="<? echo $row->id; ?>"><? echo ...

Learn how to easily incorporate a drop-down list into the material-UI Search component within the navbar to enhance the search results

I integrated a Material UI search bar into my React app's navbar following the instructions from the official documentation on MUI. However, the article does not provide any guidance on how to add a dropdown list when selecting the search input field. ...

Tips for refreshing a specific div element at set intervals using JQuery AJAX?

I need to make updates to a specific div element without refreshing the entire HTML page. The code below currently works, but it reloads the entire HTML page. Additionally, I am working with different layouts where I have separate files for the header, l ...

AJAX Username verification failing to validate

Working with PHP and MySQL, I created a basic form which includes a textfield for the username and a submit button. The page is named checkusername.php. Additionally, I implemented an AJAX function for handling this process. Subsequently, there is another ...

Is there a way to determine if a browser is operating in compatibility mode?

Is there a way to determine if the browser is in compatibility mode or not? I need to apply different CSS depending on the mode. ...

What could be the reason my black overlay doesn't show up when the button is clicked?

Attempting to craft a pop-up window on my own, I encountered an issue. Upon pressing the button, instead of the anticipated pop-up appearing and darkening the background below it, the entire page freezes with no sign of the pop-up box. If I eliminate the ...