Dropdown is not showing HTML , CSS - html

I have the attr data-toggle= dropdown on the {{form.query}} which is the search input
but it just wont show, any solutions?
bootstrap/jquery links in head section :
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
JavaScript in body :
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
HTML code:
<form class="dropdown" method="get">
<input type="text" name="query" class="form-control" placeholder="Type Here" data-toggle="dropdown" required id="id_query">
<ul class="dropdown-menu col-12 pl-2" role="menu" aria-labelledby="menu" id="list" style="display:inline-block;">
<li role="presentation"> Django</li>
<div class="dropdown-divider"></div>
<li role="presentation"> Potato</li>
<div class="dropdown-divider"></div>
<li role="presentation"> Sleep</li>
</ul>
<input type="submit" value="Search" class="btn btn-lg btn-primary col-12 my-2">
</form>

Can you please check the below code link? Hope it will work for you. You have to add
id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false" in input
and
aria-labelledby="dropdownMenuButton" in dropdown-menu
as per bootstrap documentation
Please refer to this link:
https://jsfiddle.net/yudizsolutions/8fnw0o46/11/
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<form class="dropdown" method="get">
<input type="text" name="query" class="form-control" placeholder="Type Here" data-toggle="dropdown" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false" required id="id_query">
<ul class="dropdown-menu col-12 pl-2" role="menu" aria-labelledby="dropdownMenuButton" id="list">
<li role="presentation"> Django</li>
<div class="dropdown-divider"></div>
<li role="presentation"> Potato</li>
<div class="dropdown-divider"></div>
<li role="presentation"> Sleep</li>
</ul>
<input type="submit" value="Search" class="btn btn-lg btn-primary col-12 my-2">
</form>

You must use ether a link or a button to toggle the dropdown, not a text input.
Wrap the dropdown’s toggle (your button or link) and the dropdown menu
within .dropdown, or another element that declares position:
relative;. Dropdowns can be triggered from <a> or <button> elements to
better fit your potential needs.
https://getbootstrap.com/docs/4.6/components/dropdowns/#examples

Related

Ensuring div are placed below each other after the top div grows in size

I have two divs that represent a list of elements the user can click on on a search bar, followed by a "Done" button.
<div class="dropdown col" id="dropdown-search-id">
<input type="text" class="form-control dropdown-toggle" id="inputSearch" placeholder="Search for a term ">
<div class="col dropdown-menu" aria-labelledby="inputSearch">
<div id="search_list_container">
<ul id="inputSearchEntries">
<li id="searching_li" style="visibility:hidden">
<img src="{{static_dir}}/loader.gif" alt="Loading" style="width:15%"/>
</li>
</ul>
</div>
<div id="doneSearchButton" class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary">Done</button>
</div>
</div>
</div>
Whenever the user starts typing, there are a number of <li> elements that appear with an autocomplete function (that is, they are appended between the <ul> tag, but the position of the "Done" button is messed up, as it does not stay at the bottom, that is, below the list elements.
How can I keep the button always at the bottom of the list, regardless of how many elements there are?
See example below. I used your code, added a few <li> items, the data-bs-toggle and a class on the <ul> list so no bullets appear, and the buttons is where it should be.
So if your problem isn't solved with my example, post the full example of the dropdown, with the search results and including any custom CSS.
Other options:
Use the helper class float-end instead of using flex.
Place the btn inside the list: <ul><li>..</li><li><btn></li></ul>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="dropdown col" id="dropdown-search-id">
<input type="text" class="form-control dropdown-toggle" id="inputSesarch" data-bs-toggle="dropdown" aria-expanded="false" placeholder="Search for a term ">
<div class="col dropdown-menu form-control" aria-labelledby="inputSearch">
<div id="search_list_container">
<ul class="list-group" id="inputSearchEntries">
<li><a class="dropdown-item" href="#">First result</a></li>
<li><a class="dropdown-item" href="#">Another result</a></li>
<li><a class="dropdown-item" href="#">Some other result</a></li>
</ul>
</div>
<div id="doneSearchButton" class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary">Done</button>
</div>
</div>
</div>

Position search bar from right to left

I'm searching to get by search bar that's in a navbar in a dropup menu to go from right to left.
At the moment, my dropup menu is at the far right of my screen just as I want and when I click on my search button, the bar goes off the screen on the right.
I want it to be displayed on the left.
I'm using Bootstrap 5.1
.btn-group {
margin: 50px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<span class="material-icons">
search
<a class="navbar-brand" href="#"></a>
</span>
</button>
<ul class="dropdown-menu">
<div class="form-outline" id="search">
<input type="search" id="form1" class="form-control" placeholder="Trouvez une recette!" aria-label="Search" />
</div>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
Use dropdown-menu-end on the dropdown element. See alignment options.
Note that I've corrected your list markup. The only valid child of ul is li.
.btn-group {
margin: 150px; /* demo only *
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<span class="material-icons">
search
<a class="navbar-brand" href="#"></a>
</span>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<div class="form-outline px-2" id="search">
<input type="search" id="form1" class="form-control" placeholder="Trouvez une recette!" aria-label="Search" />
</div>
</li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

boostrap dropdown menu align

I am new to bootstrap and created a website with that but my dropdown menu didn't work right it open "out of the window" so anyone can help me with that? I've tried a lot with classes but it didn't work...
https://i.imgur.com/DbjKm3U.png
my code:
<div class='dropdown'>
<button class='btn' type='button' id='dropdownMenuButton' data-toggle='dropdown'>
<img class='rounded-circle float-right' height='45px' src='$profileimgurl' />
</button>
<ul class='dropdown-menu pull-left' role='menu'>
<li class='dropdown-header'>$username</li>
<li class='dropdown-header'><a href='profile.php'class=''>Profile</a></li>
<li class='dropdown-header'><a class=''>Friends</a></li>
<li class='dropdown-header'><a class=''>Activity</a></li>
<li class='divider'></li>
<li class='dropdown-header'>Account</li>
<li>
<form action='includes/logout.inc.php' method='post'>
<button class='btn btn-link' type='submit' name='logout-submit'>Logout</button>
</form>
</li>
</ul>
</div>
The default behavior of Bootstrap's Dropdown Component is to align to the bottom left margin of whatever object triggered it. To override this behavior you apply dropdown-menu-right to the dropdown-menu. To use your own code as an example:
<ul class='dropdown-menu dropdown-menu-right' role='menu'>
<li class='dropdown-header'>$username</li>
<li class='dropdown-header'><a href='profile.php'class=''>Profile</a></li>
<li class='dropdown-header'><a class=''>Friends</a></li>
<li class='dropdown-header'><a class=''>Activity</a></li>
<li class='divider'></li>
<li class='dropdown-header'>Account</li>
<li>
<form action='includes/logout.inc.php' method='post'>
<button class='btn btn-link' type='submit' name='logout-submit'>Logout</button>
</form>
</li>
</ul>
It is unclear whether you are using Bootstrap 3.x or Bootstrap 4.x, but in the latter you can also apply responsive behavior to this class (ie. .dropdown-menu-lg-right to better modify your UI on different devices or screens.
This Technique only work on Bootstrap 4
This is not problem bro, its default behavior of dropdowns but for solving this situation you need to use dropdown-menu-right class, for more info go to this link.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Right-aligned menu
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>

checkbox and data-toggle conflicts that doesn't allow checkbox check

i can't check the checkbox because i added data-toggle="tab". bt i dont want to remove that data-toggle="tab". is there any idea to make it work .
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
<div class="dropdown-menu" role="menu" data-toggle="tab" aria-labelledby="dLabel">
<div class="tab">
<input type="checkbox">
</div>
Item
</div>
</div>
thank you in adavance

Inline search box form with input group dropdown - problems with text input width

I'm trying to do seach box like this:
What's the best way of doing it with bootstrap?.
I was playing with inline form and input group dropdown list, but I have problems with text input width, as it's not fills out whole page width.
http://www.bootply.com/LRUm7PdeMN
How about checking the snippet..
Rest of styling you can do yourself..
.container {
padding-top: 50px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="search-box">
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" aria-label="..." placeholder="Search ...">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">All categories <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Wszystkie kategorie
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
</ul>
<button type="submit" class="btn btn-default">
<i class="fa fa-search"></i>
</button>
</div>
<!-- /btn-group -->
</div>
<!-- /input-group -->
</div>
</form>
</div>
</div>
</div>
</div>