Ways to incorporate line spacing using CSS

Is there a way to adjust the spacing between the drop down boxes in the sidebar so that they align neatly with the questions in my section?

select {
  font-family: 'Courier New', monospace;
  color: black;
  font-weight: bold;
  font-size: 30px;
  text-align: left;
  line-height: 50px;
}

section {
  width: 31%;
  display: inline-block;
  vertical-align: top;
  height: 270px;
}

aside {
  width: 31%;
  display: inline-block;
  padding: 1% 1% 1% 1%;
  vertical-align: top;
  height: 270px;
}

button {
  font-family: 'Courier New', monospace;
  color: black;
  font-weight: bold;
  font-size: 50px;
  text-align: center;
}
<header>
  <h1>Children's Quiz</h1>
  <img src="childrenfun.webp" alt="child" height=300 width=600>
</header>

<section>

  <p>What colour is made from yellow and red?</p>

  <p>How many fingers do humans have?</p>

  <p>What is 20 + 4?</p>

</section>

<aside>
  <select id="q1">
    <option>White
      <option>Yellow
        <option value="correct">Orange
          <option>Green
  </select>
  <br>
  <select id="q2">
    <option value="correct">10
      <option>20
        <option>5
          <option>8
  </select>
  <br>
  <select id="q3">
    <option>21
      <option>6
        <option>204
          <option value="correct">24
  </select>
</aside>

<article>
  <button id="checkButton">Check Answers</button>
</article>

This showcases what my website looks like at the moment:

https://i.sstatic.net/XO1fF.jpg

Answer №1

It would be ideal to have questions and answers grouped together in rows.

To ensure that the questions and drop-down boxes stay aligned, a practical solution is to place them within the same container in your HTML code:

<div class="box"></div>
. This way, you can have both items (questions and drop-down boxes) neatly organized inside these containers.

Using CSS flex will enable you to keep your questions and drop-down boxes in the same row with

display: flex; flex-direction: row;
, and align them vertically using align-items: center;.

  .box {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .box p {
    width: 50%;
  }

  .box div {
    width: 50%;
  }
<div class="box">
    <p>What colour is made from yellow and red?</p>
    <div>
        <select id="q1">
            <option>White</option>
            <option>Yellow</option>
            <option value="correct">Orange</option>
            <option>Green</option>
        </select>
    </div>
</div>

<div class="box">
    <p>How many fingers do humans have?</p>
    <div>
        <select id="q2">
            <option value="correct">10</option>
            <option>20</option>
            <option>5</option>
            <option>8</option>
        </select>
    </div>
</div>

<div class="box">
    <p>What is 20 + 4?</p>
    <div>
        <select id="q3">
            <option>21</option>
            <option>6</option>
            <option>204</option>
            <option value="correct">24</option>
        </select>
    </div>
</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

Say goodbye to tables and hello to CSS div layouts!

Is there a way to align three or four elements without relying on tables? I want them to follow this format: The reason I am asking is because my current method involves using tables, but they are not allowing me to set a specific height for the "test" bo ...

The background of the wrapper div refuses to expand beyond the original size of the browser window

I'm currently in the process of developing a website, focusing on establishing the fundamental structure of my design to facilitate the addition of content and allow for the dynamic expansion of the div based on the length of the content. Nevertheless ...

Modify the location of the input using jQuery

Hey there, I've got this snippet of HTML code: <div class='moves'> <div class='element'><input type='text' value='55' /></div> <input class='top' type='text&apo ...

The JavaScript code that functions properly in Codepen is not functioning on my HTML page

Can you help me understand why this code is working fine in CodePen, but not on my HTML page? I'm unable to identify the error that may have occurred. Any assistance would be greatly appreciated! I suspect there's an issue with connecting some jQ ...

Numerous div elements are situated closely together, featuring small pockets of blank spaces in between each

I am facing a challenge with multiple boxes (div) of varying sizes. Below is a screenshot illustrating the issue: Here's my code: HTML <div id="categories_container"> <div class="main_category"> <div class="categories_tit ...

On the second attempt, Firefox is able to drag the div element smoothly by itself

I have created a slider resembling volume controls for players using jQuery. However, I am facing an issue ONLY IN FIREFOX. When I drag the slider for the second time, the browser itself drags the div as if dragging images. The problem disappears if I clic ...

When the update button is clicked, the textfield is hidden; it reappears upon refreshing the page

Our marketplace multi-vendor site on Magento allows sellers to list their products for sale. The frontend displays the price using the following code: Phtml <input onFocus="showPriceCancel('<?php echo $products->getId(); ?>');" clas ...

Steps to apply styles to an iframe element directly from its inner HTML code

Looking for help with this line of code: <iframe src="http://www.google.com" name="google" style="Z-INDEX: 0; MARGIN-TOP: -1px; WIDTH: 100%; HEIGHT: 1070px"> <html> <head></head> <body> < ...

I am having trouble showing the background image in the div

I created a 960 layout using 3 divs to easily organize child divs with images and text. However, I'm having trouble getting the background image of the first div to display. Can you help me figure out what I'm doing wrong? This is the concept f ...

What are the best strategies for optimizing my CSS drop down menu to be both responsive and mobile-friendly?

I am struggling to make my current CSS and HTML menu fully responsive and mobile-friendly. I have researched solutions from other sources but have been unable to implement them successfully. I am seeking help in modifying my menu so that it adjusts to smal ...

Angular implementation of a dynamic vertical full page slider similar to the one seen on www.tumblr

I'm determined to add a full-page slider to the homepage of my Angular 1.x app After testing multiple libraries, I haven't had much luck. The instructions seem incomplete and there are some bugs present. These are the libraries I've experi ...

The right-aligned navigation bar elegantly shifts downward when it exceeds the screen width

I've been struggling to create a Right Aligned Navigation Bar with a search bar and a login icon that stay in one row on the page. No matter how I try, it keeps jumping down instead of aligning properly. Here is an image of what I'm trying to ach ...

Increasing the upward motion of the matrix raining HTML canvas animation

Recently, I've been experimenting with the Matrix raining canvas animation here and I was intrigued by the idea of making it rain upwards instead of downwards. However, my attempts to achieve this using the rotate() method resulted in skewing and stre ...

The proper approach is using CSS for linking pseudo-classes

Look what I stumbled upon: Important: Remember, a:hover MUST be placed after a:link and a:visited in the CSS code to work properly!! Remember: Place a:active after a:hover for it to have an effect in the CSS code!! Note: Pseudo-class names are not case- ...

Animation in CSS/transform drifting out of view

I have a challenge with animating text to each corner of the screen, where the text is rotated in every corner. However, I am facing an issue where the text goes off-screen in the top right and bottom left corners. It seems like the rotation might be causi ...

Tips for making a sidebar sticky when scrolling

In order to keep the right-side bar fixed, I have implemented this javaScript function: <script type="text/javascript> $(document).ready(function () { var top = $('#rightsidebar-wrapper').offset().top - parseFloat($('#rightsideb ...

I noticed a random gap between the elements with no discernible explanation

<div id="colorscheme"> </div> <div id="content"> <div id="display_saved"> TEXT TEXT TEXT </div> Here is the HTML structure related to a particular document issue. CSS: #colorscheme{ width:25%; display:inline-blo ...

Tips for avoiding content appearing beneath overlapping elements

I am facing an issue with a hero image that has an overlapping box. I want to add content below the box but it ends up appearing behind the box. How can I ensure that the content shows below the box while maintaining responsiveness? .shell { display: ...

Different styles of Unicode arrowheads found on different versions of Android devices

Here is the HTML/CSS code I'm using to create a "Play" button with an arrowhead symbol. The code utilizes ▶ and &9658; to achieve this functionality. <div class='audio-container'> <p style="text-indent:0em;"> <aud ...

Having trouble with CSS webkit radial not working on iPad's Safari Mobile browser?

I'm feeling confused right now. I have this gradient code background-image: -webkit-radial-gradient(50% 65%, ellipse cover, #f2f2f4, #201935 55%); It's working on Safari when I change the User Agent to Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3 ...