Arrange the HTML elements in a line, one following the next

I need assistance with aligning two dropdown lists in the jsbin provided. How can I position them one after the other, center them on the page, and ensure there is enough space between the two elements without manually adding spaces using  

In addition, my bootstrap jumbotron header does not fill the entire width of the page. I have tried adjusting the width to 1600px as shown below, but it still leaves space on the left side.

<div class="jumbotron" style="width: 1600px;">

UPDATE: After trying the suggested code changes, the jumbotron now spans the full width, but the appearance of the dropdown lists is not matching what is shown in your jsbins. Please refer to the screenshot below for reference.

https://i.sstatic.net/hNPkM.png

Answer №1

Check out this JSBin link for reference: http://jsbin.com/tapuviyoja/1/edit?html,css,output

If you're wondering about aligning elements one after another, clarify if you mean inline or on a new line. For inline alignment, the <br> tag between select elements should be removed and use display: inline-block;.

The Jumbotron may not extend full width due to padding in its container. Eliminate the padding and set both container and jumbotron width to 100%.

To center-align the form, increase its width to match the window's width and then apply text-align:center.

.line{
width:33%;
float:left;
}

.jumbotron {
padding-top: 0%;
padding-bottom: 0%;
width:100%;
}

.container{
width:100%;
padding:0;
}

body {
background: url('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRZQXod-TpW5bx9oSysCVEdpsYS_9ssKwfbS04asZ2L9xzSnOiHdhFWxFS9') no-repeat center center;
/*opacity: 0.2;*/
background-size: cover;
}

form{
text-align:center;
width:100%;
}

form select{
display:inline-block;
}

Answer №2

Modifying the <form> like this is effective:

<form method="get" action="index.php" style="text-align: center;">

Alternatively, you can include the following CSS:

form {text-align: center;}

Answer №3

To start, enclose the form within a wrapping container.

Next, apply the display property to the form as inline-block, allowing it to respond to the text-align: center property of the parent .container. Lastly, set the text-align property on the form to left in order to prevent child elements with inline and inline-block from being centered.

HTML

  <div class="container">
    <form method="get" action="index.php">
      ...
    </form>
  </div>

CSS

.container {
  text-align: center;
}

form {
  display: inline-block;
  text-align: left;
}

DEMO http://jsbin.com/abcdefg123/1/edit?html,css,output

Answer №4

To address your concerns, the following adjustments should resolve the issues you are facing. It seems there were some structural problems with your HTML code, such as having div elements within the head section.

body {
  background: url('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRZQXod-TpW5bx9oSysCVEdpsYS_9ssKwfbS04asZ2L9xzSnOiHdhFWxFS9') no-repeat center center;
  background-size: cover;
  margin: 0;
  padding: 0;
}
.container {
  padding: 0
}
.jumbotron {
  padding: 0;
  margin: 0;
}
form {
  text-align: center
}
select {
  margin-right: 10px
}
<html>

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

</html>

<body>
  <div class="container">
    <div class="jumbotron">
      <h1 align="center" style="font-family:Comic Sans MS">Check Near You</></h1>
      <p align="center" style="font-family:Comic Sans MS">See which articles are near you ...</p>
    </div>
  </div>
  <form method="get" action="index.php">
    <select class="language" name="language">
      <option value="tagalog">Tagalog</option>
      <option value="english">English</option>
    </select>


    <select class="year" name="year">
      <option value="2010">2010</option>
      <option value="2011">2011</option>
      <option value="2012">2012</option>
      <option value="2013">2013</option>
      <option value="2014">2014</option>
      <option value="2015">2015</option>
      <option value="2016">2016</option>
      <option value="2017">2017</option>
      <option value="2018">2018</option>
      <option value="2019">2019</option>
      <option value="2020">2020</option>
    </select>

    <input type="submit" value="submit">
  </form>
</body>

</html>

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

What is the method for retrieving the IDs of checkboxes that have been selected?

I attempted running the following code snippet: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://static.jstree.com/v.1. ...

What is the most effective way to add images to a table using JavaScript?

Is there a way to insert images into the "choicesDiv" without having to make changes to the HTML & CSS? Here is the table code: <table id="choices"> <tr> <td><div class="choicesDiv" value="1"></div></td> ...

What is the best way to place a semi-transparent black overlay on an image?

<html> <head> <style> #contain_main {background-color:black; width:100%; height:auto;} #main {width:100%; height:700px; background-image:url("https://www.sappun.co.kr/shopimages ...

Three brothers and sisters - One must expand responsively while the remaining two maintain minimum content sizes

Attempting to outline the limitations at hand. We have 3 containers named .content, .left, and .bottom, along with a resize handler that governs the available space. I aim for the .container to expand as the space increases, utilizing all available area. ...

designing a button with eye-catching CSS3 styles

Although I struggle with CSS, I managed to create a button that looks pretty good. However, it doesn't have the same shine as the buttons on Yahoo Mail or the buttons found at Check out my demo on Fiddle: http://jsfiddle.net/karimkhan/y6XGg/ I wou ...

Is there a way to manipulate CSS to update automatically when new content is loaded via ajax?

I need help with customizing the CSS for 4 image links on my website. Each link is represented by a small image in its normal state and a larger image when hovered over. The content for each link is loaded using ajax. My question is how can I modify the C ...

JQuery method for altering currentTime's format

I am attempting to showcase the current time and duration of my videos on my website using the format 00:00, but I am having some difficulty... myVideo.on('timeupdate', function() { $('.current').text(myVideo[0].currentTime); $ ...

Is the ng bootstrap modal within Angular failing to show up on the screen

In the midst of working on my project, I encountered an issue with opening a modal using ng bootstrap. Although I found a similar thread discussing this problem, it did not include bootstrap css. I decided to reference this example in hopes of resolving t ...

What is the process for combining AngularJS filters?

I currently have a fragment object like this: [{id: 721, titulo: "Cotizador Gastos Médicos Bx+ 2019", descripcion: "Cotizador Gastos Médicos Bx+ Tarifas 2019", updateDate: "2020-03-25 14:30:22.0", idCategoria: "1", …}, {id: 88, titulo: "Cotizador GMM ...

A guide to customizing nested elements in react using styled-components

Currently, I am utilizing styled components to apply styles to a child element inside a div using nested css. For a demonstration, you can view my example here const customStyles = theme => ({ root: { ...theme.typography.button, background ...

Initiate the printing process by executing the window.print() function. As the document is being

Here's the code snippet : <body> <div class="headerCont noprint"> <div class="headerHold"> <div class="logoCont"><img src="images/logo.jpg" width="104" height="74" alt="Logo"> ...

What's the best way to search through various addresses for the source in an image tag?

In my current Laravel 5.8 project, I am faced with the task of searching through three different image sources for an img tag. First, I attempt to load the image from "". If that fails, I try a second URL like "". Should both attempts be unsuccessful, I th ...

What are the signs that an element was visible on screen prior to navigation?

Recently, I incorporated SlideUp and SlideDown jquery animations into my website. You can check it out by visiting (click the >>>). However, I noticed a small issue where when users navigate to a new page, they have to re-SlideUp the element that ...

Troubleshooting the issue of onclick not functioning in JavaScript

My attempt to utilize onclick to trigger a function when the user clicks the button doesn't seem to be successful. For instance: function click(){ console.log('you click it!') } <input type='button' id='submitbutto ...

Could HTML code be inserted into the <Head> section of a NextJS page?

I need to add meta tags retrieved from the backend for a certain page to the Head section of my page component. In React, I know that I can incorporate HTML using <div dangerouslySetInnerHTML={{__html: response.someHtml}} />. Can this same method b ...

Adjusting webpage zoom based on different screen sizes

Hey there, I ran into an issue with my web page design. It looks great on my desktop monitors, but when I checked it on my laptop, things went haywire. Strangely, adjusting the zoom to 67% seemed to fix the problem. Both screens have a resolution of 1920 ...

What is preventing the conditional class in Svelte from being applied when the page loads?

Contextual Background In my exploration of Sveltekit, I set out to construct a dashboard using Bootstrap tab components. To achieve this, I opted to utilize <buttons> instead of <a> tags to prevent redirection to different routes. My goal was ...

When hovering over nav bar links, shadows are not displayed

When hovering over the navbar links, I am able to change their color but a shadow at the bottom is missing. Is there a way to add a shadow at the bottom like it had before when not hovered? Visit this link for more information ...

Incorporating tawk.to into a Nuxt/Vue application

Has anyone had success implementing tawk.to in a Nuxt application? I took the initiative to create a file called "tawk.js" in my plugin folder and added the following code: var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date() (function () { ...

Unable to achieve horizontal alignment with DIV element set as inline-block

Currently, I have five columns that are aligned using the display:inline-block. Everything seems to be working fine, but there's a peculiar issue that arises when I refresh the page multiple times. Occasionally, while the first column remains at the t ...