Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I make my dropwdown menu responsive?

I am working on a project where I have a dropdown combo box for filtering menu. It looks great in desktop, however in responsive, the dropdown menu pops put of the gray search box.
I am not sure how to make it responsive. Any help/advice appreciated. Thanks.

Link to code – https://live.datatables.net/waruwabo/1/edit

Here is my code –

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.searchbox {
    border-radius: .5rem;
    border: 1px solid #ced4da;
    background-color: #f0f0f0;
    padding: 20px;
    margin-bottom: 20px;
}
<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>

    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
<div class="searchbox">
<p>Name: <select id="dropdown1">
<option value="">Select</option>
<option>Ashton Cox</option>
<option>Brielle Williamson</option>
<option>Cedric Kelly</option>
</select>
</p>

<p>Postion: <select id="dropdown2">
<option value="">Select</option>
<option>Technical Author hghhgjh</option>
<option>Integration Specialist</option>
<option>Javascript Developer</option>
</select>
</p>

<p>Office: <select id="dropdown3">
<option value="">Select</option>
<option>San Francisco county state</option>
<option>New York state and city</option>
  <option>Edinburgh Learning Center test</option>
</select>
</p>
  <button type="button" id="test">Clear Filters</button>
</div>
  

>Solution :

You can just add a width of x% and it will never be bigger than the parent div. This does not apply for the options beneath it

.searchbox {
    border-radius: .5rem;
    border: 1px solid #ced4da;
    background-color: #f0f0f0;
    padding: 20px;
    margin-bottom: 20px;
}

select {
  width: 40%;
}
<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>

    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
<div class="searchbox">
<p>Name: <select id="dropdown1">
<option value="">Select</option>
<option>Ashton Cox</option>
<option>Brielle Williamson</option>
<option>Cedric Kelly</option>
</select>
</p>

<p>Postion: <select id="dropdown2">
<option value="">Select</option>
<option>Technical Author hghhgjh</option>
<option>Integration Specialist</option>
<option>Javascript Developer</option>
</select>
</p>

<p>Office: <select id="dropdown3">
<option value="">Select</option>
<option>San Francisco county state</option>
<option>New York state and city</option>
  <option>Edinburgh Learning Center test</option>
</select>
</p>
  <button type="button" id="test">Clear Filters</button>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading