What is the best way to change a vertical drop-down menu to a horizontal layout?

  • I need help aligning my dropdown menu horizontally instead of vertically. I tried using the flexbox example from w3 schools, but it didn't work when I included the classes inside my select tag.
  • Even after debugging, I realized that the issue is with the flexgrow property assigned to the root class.
  • Can someone guide me on how to fix this so that I can troubleshoot similar issues in the future?
  • Below is a link to my relevant code snippet and sandbox:
  • All the code can be found in AutoCompleteComponent.js

https://codesandbox.io/s/4x9lw9qrmx

queryBuilderContainer: {
    display: "flex",
    flexWrap: "wrap",
    backgroundColor: "DodgerBlue ",
    border: "1px solid red "
    // width: 100,
    
    // display: flex;
    // flex-wrap: wrap;
    // background-color: DodgerBlue;
},
queryBuilderContainerItem: {
    border: "1px solid black ",
    backgroundColor: "red ",
    width: 100,
    margin: 10,
    textAlign: "center",
    //lineHeight: 75,
    fontSize: 30
},
root: {
    flexGrow: 1,
    height: 250
},
input: {
    display: "flex",
    padding: 0
},
valueContainer: {
    display: "flex",
    flexWrap: "wrap",
    flex: 1,
    alignItems: "center",
    overflow: "hidden"
},

nossr0901
<NoSsr className={classes.queryBuilderContainer}>
    <Select
        className={classes.queryBuilderContainerItem}
        classes={classes}
        styles={selectStyles}
        options={this.state.suggestions}
        components={components}
        value={this.state.single}
        onChange={this.handleChange("network")}
        placeholder="Search a to do"
    />
    <Select
         className={classes.queryBuilderContainerItem}
         classes={classes}
         styles={selectStyles}
         options={this.state.nameSuggestions}
         components={components}
         value={this.state.names}
         onChange={this.handleChange("location")}
         placeholder="Search name"
    />
    <div className={classes.divider} />
    <Select
        className={classes.queryBuilderContainerItem}
        classes={classes}
        styles={selectStyles}
        options={this.state.operatorSuggestions}
        components={components}
        value={this.state.operator}
        onChange={this.handleChange("operator")}
        placeholder="Search name"
     />
     <div className={classes.divider} />
     <button onClick={e => this.props.removeSeleted(this.props.index)}>
         Remove
     </button>
</NoSsr>

Answer №1

The issue you're experiencing lies within the div parent element of your NoSsr component.
This particular div parent should have the className: queryBuilderContainer.
By doing so, you won't need to add a class directly to your NoSsr.

Take a look at the code snippet below:

<div className={classes.queryBuilderContainer}>
      <NoSsr>
        <Select className={classes.queryBuilderContainerItem}...>
        <Select className={classes.queryBuilderContainerItem}...>
        ...
      </NoSsr>
 </div>

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

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

Consolidate test outcomes from various nodes in the stack into a single graph

Nowadays, web applications consist of a variety of different technology stacks. Developers utilize languages like Ruby, Python, PHP, JavaScript, and C for the backend, as well as frameworks such as AngularJS and EmberJS for MVC/client-side code. To ensure ...

Tips for adjusting the class of elements in neighboring rows of an HTML table with the help of jQuery's nextAll() selector

While attempting to switch classes using the jQuery selector .nextAll(':lt(3)'), I encountered an issue. The class change does not take effect on new rows of HTML tables. It seems like the class change for the next 3 cells is only being applied ...

Encountered an issue when attempting to run the React js app using npm start

npm ERROR! CODE ENOENT npm ERROR! SYSCALL OPEN npm ERROR! PATH C:\Users\Ahsan Raza\Desktop\myapp\package.json npm ERROR! ERRNO -4058 npm ERROR! ENOENT: could not find file or directory, open 'C:\Users\Ahsan Raza&bsol ...

Troubleshooting your Meteor App on Nitrous.io with server-side debugging

I currently have a basic Meteor application up and running on a Nitrous box. I am interested in utilizing node-inspector for debugging the server-side part of my app, but I'm facing difficulty accessing the console as detailed here. The Meteor app is ...

Tips on adjusting font color without activating the :visited state

Currently, I have set up the following HTML and CSS: <div id = "navi"> <ul> <li><a id = "topLinks" class = "currentPage" href = "index.html"> Home </a></li> <li><a id ...

Updating to the latest version of Next.js will result in a modification of the API path

I recently updated my app to the latest version of nextjs (13.1.6) and encountered a problem where all my requests are now failing. It seems that the URL I specified in the request creator, based on the ENV value, is being overwritten. .env file CONST NEXT ...

Adding negative values to the Tailwind CSS utility plugin is a simple process that can greatly enhance

Adding Negative Values to Tailwind CSS Utility Plugin Quick Summary: I've developed a custom Tailwind utility plugin that includes numeric values. I'm looking for a way to introduce negative numbers by adding a - at the start of the class, simi ...

Retrieve data from a JSON array using either JavaScript or PHP

Check out my code snippet: const newData = [{"new_id":"1","new_no":"1","total":"N.A"},{"new_id":"2","new_no":"3","total":"4"},{"new_id":"2","new_no":"4","total":"5"}]; Now, I need to extract specific details from this JSON data based on the 'new_no& ...

Discover the inner workings of the code below: set a variable called "start" to the current time using the new Date().getTime() method. Create a loop that continuously checks if

I'm having trouble understanding how this code snippet works. Can someone please provide a demonstration? Thanks in advance.... It seems that the code is subtracting 'start' from the current date with new Date, resulting in 0 which is less t ...

Transferring the final space from a node containing a mixture of content to a separate

Having a multitude of HTML files generated by MS Word, my objective is to modify the contents in order to extract data and perform other tasks. In an HTML paragraph with mixed content, I have noticed that spaces after italicized or bold words also become ...

Is it possible for a Bootstrap table to extend beyond the boundaries of a Bootstrap

Within my bootstrap container, there resides a boostrap table structured as such: <div class="container"> <table class="table"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> ...

Use the arrow key to move through the different layers

I'm working on enhancing a custom auto-complete feature using JQuery. My goal is to allow the user to navigate down into the auto-complete dropdown and then back up to the input box that triggered it initially. The code snippet below demonstrates how ...

How to properly handle file uploads and get the correct image path from Node Js (Express) to React Js?

Currently, I am working on my local system developing a file upload feature using node js. My project file structure looks like this: Project ..client .... source code of React App ..Server ....uploads ......avatar ........image.png ....index.js In this ...

What is the best way to generate an array of imported images within a React Component?

I am looking to optimize the loading process for nearly a hundred images in my React component by importing them all via a single statement from another JavaScript file. However, before I can achieve this, I need to find a way to store all these images in ...

Troubleshooting difficulties integrating NodeJS with R using an R script

I have been attempting to execute an R-script from a js-file but I am consistently receiving a null value as the return. Here is my folder structure: -R_test --example.js --helloWorld.R The contents of example.js are as follows: var R = require(" ...

Sending information to a single component among several

I'm developing a custom DownloadButton component in VueJS that features an animation when clicked and stops animating once the download is complete. The DownloadButton will be utilized within a table where it's replicated multiple times. I intend ...

Alignment of badge-pill and h2 in a horizontal position

I'm currently working on mastering Bootstrap. My goal is to have a prominent heading followed by three small badge-pills that are horizontally centered on the page. However, I've run into a couple of issues: 1- The badge-pills are appearing stac ...

Transforming Nested JSON Data into an Interactive HTML Table

I am attempting to transform this nested JSON data into an HTML table: { "language":"en", "retrieved_url":"https://www.canlii.org/en/ca/scc/doc/1986/1986canlii46/1986canlii46.html?autocompleteStr=r%20v%20oakes&aut ...

Avoiding the separation of hyphenated words when they overflow on a new line

My code is designed to limit text to two lines and show an ellipsis if there is more content. However, I am facing an issue with hyphenated words like "breath-taking" not being treated as one word. Instead, they are often cut off at the end of the second l ...

I am interested in incorporating a captcha system using ajax

Recently, I implemented email and captcha validation in a form. Now, I am looking to make some modifications. Specifically, I want the form to not reload the page if the captcha is incorrect or left empty. This means that all fields that have already bee ...