<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none">
<span class="criteria">any</span>
<span class="caret" style="margin-top:6px;"></span>
</a>
The above piece of code is giving me the following output
any ▼
How to place the caret below the anchor close to the anchor text.
Approx look :
any
▼
EDIT : I have text following the anchor and caret, but I want it to be on same line.
before anchor text any text following the anchor
▼
The any is basically a drop down in the middle of sentence. So I want the caret to be close to anchor text, but below it and not necessarily as a next line
EDIT 2 : code before and after
<div class="control-group">
<div class="controls dropdown">
Create backup if
<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none">
<div class="criteria">any</div>
<div class="caret" style="margin-top:6px;display: inline-block"></div>
</a>
<ul class="dropdown-menu" id="selector"
style="text-decoration: none;left: 18%;min-width: 65px;">
<li><a title="any">any</a></li>
<li><a title="all">all</a></li>
</ul>
of the following are true:
</div>
</div>
This is my take on it... Notice that, as you add text before -or after- the caret follows the anchor
.caret {
display: inline;
position: relative;
top: 1em;
left: -1.2em;
padding-right: 0;
margin-right: 0;
width: 0;
}
a > .caret {
display: inline-block;
width: 0;
}
<div class="control-group">
<div class="controls dropdown">
Create backup if more code here
<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none">
<span class="criteria">any</span><span class="caret">^</span></a> of the following are true:
</div>
</div>
Updated to remove extra spaces
You can modify your caret like this:
<span class="caret" style="position:absolute; margin-top:15px;margin-left:-20px;"></span>
That's the final look and the snippet:
Nothing to see there<br>
If <a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none">
<span class="criteria">any</span>
<span class="caret" style="position:absolute; margin-top:15px;margin-left:-20px;">^</span>
</a> unicorns are watching you, be happy!
Related
I have an operations field in a table. Clicking on this field opens the dropdown. The dropdown that opens remains in the table and automatic scrolling appears. How do I get the dropdown dropdown table out of the way.
HTML
<td>
<div class="dropdown">
<button type="button" class="btn btn-sm dropdown-toggle hide-arrow py-0" data-bs-toggle="dropdown">
<i data-feather="more-vertical"></i>
</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" href="#">
<i data-feather="edit-2" class="me-50"></i>
<span>Stok Hareketleri</span>
</a>
<a data-idd="#item.StokID" class="dropdown-item btnSil" href="#">
<i data-feather="x" class="me-50"></i>
<span>Sil</span>
</a>
</div>
</div>
</td>
CSS
position: absolute;
inset: 0px auto auto 0px;
margin: 0px;
transform: translate(-124px, 26px);
display:block;
Increasing the z-index would get the job done for you
.selector {
z-index: 1000
}
New to Bootstrap 4 and making a dummy/mockup page with a header to get use to the navbar system.
I created this jsFiddle (full code) here, but the gist of my page is:
index.html
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="javascript:void(0)">
<img src="https://raw.githubusercontent.com/bitbythecron/bootstrap-troubleshooting/main/dummy-logo.png" class="img-fluid mainlogo" alt="Responsive image">
</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navb">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="aboutMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
About
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="fizzMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Fizz
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="buzzMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Buzz
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="foobarMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Foobar
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="resourcesMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Resources
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="helpMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Help
</a>
</li>
<li class="nav-item">
<a class="nav-link red-button" href="javascript:void(0)">WATCH DEMO</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)">Sign In</a>
</li>
<li class="nav-item">
<a class="nav-link bordered" href="javascript:void(0)">Sign Up</a>
</li>
</ul>
</div>
</nav>
main.css
html, body {
height: 100%;
font-family: 'Lato';
}
.bordered {
border-radius: 5px;
border: 1px solid white;
}
.navbar {
background-color: #00142e;
}
.red-button {
border-radius: 5px;
border: 1px solid #A81E30;
background-color: #A81E30;
color: beige;
}
.mainlogo {
width: 35%;
}
When this runs I get:
The main problem here is the thickness of the padding around the navbar. How do I make it so that there is no padding, and that the height of the navbar is either the same as that of the logo and menu links, or at most just a pixel or two greater than? I did try adding padding: 0px; to the navbar style but that did not affect anything.
Also I would like to center all the navbar content (logo + menu items)...any ideas there? I did try adding d-flex justify-content-center to navbar-collapse but that also did nothing. Thanks in advance!
Update
I updated my jsFiddle with the suggested changes from below and now I'm seeing:
So I'm still not seeing the navbar (again: logo + links) content centered and I'm seeing undesired padding, meaning the blue bar is a little too tall for what I'm looking for (I want something shorter and hugging the logo + links a little tighter).
To fix the centering, add align-item: center to your unordered list. That should be the child element of your navbar-collapse element, and it will center all your links vertically.
As for the padding, I think that it would be better to remove class="img-fluid mainlogo" alt="Responsive image" and instead just give your image a height property that you like. When I did just that, it also looked like it fixed your centering problem as well.
Let me know if that worked for you!
edited to add code snippet
/*old selector for mainlogo*/
.mainlogo {
width: 35%;
}
/*new selector for mainlogo*/
.mainlogo {
height: 50px;
}
/*added selector. targets ul elements that are descendents of element with id "navb"*/
#navb ul {
align-items: center;
}
Navbar after changes
I forked your work in JSFiddle, see what I did.
In fact, I wrapped your <nav> whithin an <header>, then I have added the bootstrap class container to get the content centered depending on the screen size with media-queries.
Also, I have changed your content class container-fluid to container in order to have the same sizing results between the navbar and the rest of your page.
I removed the img-fluid on your image, in order to avoid stretching the image if the page is resized.
Also, as your question in an other post where I answered, I have changed the navbar background to fit your brand-logo background color ;)
And in bonus I added the class navbar-dark, now you can see your burger menu when nav items are collapse. Because since bootstrap 4 :
.navbar-default is now .navbar-light, though .navbar-dark remains the same. One of these is required on each navbar. However, these classes no longer set background-colors; instead they essentially only affect color.
Bonus 2 : I removed your red-button class, and changed it to btn btn-danger which is quite the same, but with hover rules. And for your sign-up button, I added btn btn-success. I did that to let you learn on those classes too, because it is not necessary to reinvent the wheel :)
Then, you can use in your questions / answers in StackOverflow, the built-in JSFiddle Javascript/HTML/CSS snippet CTRL-M as below :
html, body {
height: 100%;
font-family: 'Lato';
}
.bordered {
border-radius: 5px;
border: 1px solid white;
}
header#nav-container{
background-color: #001a31;
}
#navb ul {
align-items: center;
}
.mainlogo {
height: 50px;
}
<!DOCTYPE html>
<html>
<head>
<title>Special Nonprofit</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght#0,300;1,300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<header id="nav-container">
<nav class="navbar navbar-dark navbar-expand-lg container">
<a class="navbar-brand" href="javascript:void(0)">
<img src="https://raw.githubusercontent.com/bitbythecron/bootstrap-troubleshooting/main/dummy-logo.png" class="mainlogo" alt="Responsive image">
</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navb">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="aboutMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
About
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="fizzMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Fizz
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="buzzMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Buzz
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="foobarMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Foobar
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="resourcesMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Resources
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" id="helpMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Help
</a>
</li>
<li class="nav-item">
<a class="nav-link btn btn-danger" href="javascript:void(0)">WATCH DEMO</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)">Sign In</a>
</li>
<li class="nav-item">
<a class="nav-link btn btn-success" href="javascript:void(0)">Sign Up</a>
</li>
</ul>
</div>
</nav>
</header>
<div class="container">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
Try This!
.sidebar {
height: 100%;
width: 0;
position: fixed;
/*Stays in place */
background-color: #303630;
/*Grey*/
overflow-x: hidden;
color:white;
z-index: 12;
/*for Disabling horizontal scroll */
}
/* Position and style for the sidebar links */
.sidebar a {
padding: 10px 10px 10px;
font-size: 25px;
color: #ffffff;
display: block;
transition: 0.3s;
}
/* the links change color when mouse hovers upon them*/
.sidebar a:hover {
color: #ffffff;
}
/* Position and style the for cross button */
.sidebar .closebtn {
position: absolute;
top: 0;
right: 25px;
}
/* Style for the sidebar button */
.openbtn {
font-size: 25px;
background-color: #000000;
color: #ffffff;
padding: 10px 10px 10px;
border: none;
position: fixed;
z-index: 12;
}
/* the sidebar button changes
color when mouse hovers upon it */
.openbtn:hover {
color: #FFFFFF;
}
/* pushes the page content to the right
when you open the side navigation */
#main {
transition: margin-left .5s;
/* If you want a transition effect */
padding: 10px;
}
<div id="sidebar" class="sidebar">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">
×
</a>
Placeholder 1
Placeholder 2
Placeholder 3
Placeholder 4
Placeholder 5
Placeholder 6
</div>
<div id="main">
<button class="openbtn" onclick="openNav()">
Hello
</button>
</div>
<script>
/* Sets the width of the sidebar
to 250 and the left margin of the
page content to 250 */
function openNav() {
document.getElementById(
"sidebar").style.width = "250px";
document.getElementById(
"main").style.marginLeft = "250px";
}
/* Set the width of the sidebar
to 0 and the left margin of the
page content to 0 */
function closeNav() {
document.getElementById(
"sidebar").style.width = "0";
document.getElementById(
"main").style.marginLeft = "0";
}
</script>
I have moved all the navbar content to the center with mx-auto class. removed the padding for top and bottom with py-0 class. this equal to padding-top: 0; padding-bottom: 0; then with media queries. I'm switching between main and secondary logo.
Here's the code:
https://codepen.io/lachiweb/pen/dyXBGvd
I created a dropdown menu with search option in angular JS. when i click on it, a dropdown menu with search option comes. But as i scroll down, search also becomes a part of scroll. I want it to be fixed and placed at position where i clicked.
Here is the code for the dropdown menu.
<div class="dropdown dropdown-scroll" style="margin-top:15px;" >
<button style="width:220px;" class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
{selected.ApplicationName}}
</button>
<ul class="dropdown-menu" role="menu">
<li role="presentation">
<div class="input-group input-group-sm search-control" fixed>
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
<input type="text" class="form-control" placeholder="Query" ng-model="query"></input>
</div>
</li>
<li role="presentation" ng-repeat='app in applicationArray | filter:query'>
<a ng-click="changeSelected(app)"> {{app.ApplicationName}} </a>
</li>
</ul>
</div>
The output is like this :
Now as i scroll, this search goes up and i cant see it anymore. Also, when i click on *select an application, i want the dropdown to be placed at that location where *select an application is there.
Try this fiddle
http://jsfiddle.net/kyrcha/ULSy3/6/
try this one
use navbar-fixed-top class with your search li
<li role="presentation" class="navbar-fixed-top">
<div class="input-group input-group-sm search-control" fixed>
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
<input type="text" class="form-control" placeholder="Query" ng-model="query"></input>
</div>
</li>
EDIT CODE :
I have updated fiddle.Please check it.
HTML :
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1 " ng-controller="ListCtrl">
<li><div class=" fixed-class input-group input-group-sm search-control "> <span class="input-group-addon ">
<span class="glyphicon glyphicon-search"></span>
</span>
<input type="text" class="form-control" placeholder="Query" ng-model="query"></input>
</div>
</li>
<ul class="presentation-li">
<li role="presentation" ng-repeat='item in items | filter:query'> {{item.name}}
</li>
</ul>
</ul>
CSS:
ul.presentation-li li{
list-style: none;
}
ul.presentation-li li a{
color: black;
text-decoration: none;
}
.fixed-class{
position: fixed;
border-width: 0 0 1px;
width : 141px;
top: 37px;
bottom : 35px;
background-color: white;
}
you can add a new css class where you fix high and you overflow-y property to scroll:
.anyClass {
height:150px !important;
overflow-y: scroll !important;
}
In your HTML code, for example you will have something like that:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton01" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
</button>
<ul (click)="$event.stopPropagation()" class="dropdown-menu" aria-labelledby="dropdownMenuButton01">
<li>
<input type="text" class="form-control" placeholder="Search">
</li>
<div class="anyClass" >
<app-item-component *ngFor="let item of array"></app-item-component>
</div>
</ul>
</div>
The (click)="$event.stopPropagation()" I added just to stop closing the select window after picking an item.
I am using the Bootstrap 3 custom buttons but can't for some reason change the brand text color nor the dropdown triangles. I've tried a couple of things, but still no luck...
<div class="container">
<div class="row" style="margin-top: -30px;">
<ul class="nav nav-tabs" role="tablist">
<li class="dropdown" style="margin-right: 70px; margin-left: 60px;" >
<a class="btn btn-inverse :active" data-toggle="dropdown" href="#">
Wristbands <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
...
</ul>
</li>
<li class="dropdown" style="margin-right: 70px;">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Hawaii <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
...
</ul>
</li>
In your example, I don't see any text in the navbar-brand div. Is that what you're talking about?
Anyhow, to answer your question, if you have text in navbar-brand, you'd use something like:
.navbar-default .navbar-brand {
color: blue !important;
}
And for the dropdown arrows, something like:
span.caret {
color: red;
}
I have a drop down menu that opens a row of icons underneath it (see picture 1, names and pictures were removed to maintain privacy)
I am trying to make this menu to open to the right of choose child, and not underneath it (see picture 2, of what I am trying to get. the Images will open to the right of the drop down and not under it)
My current code is:
<div class="span4">
<div class="btn-group">
<a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
<h3>Choose Child</h3>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent">
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<div class="btn-group">
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>A</h5>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>J</h5>
<img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>
</div>
</li>
</ul>
I tried to use the following example, that helps push the drop down to the left
how to make twitter bootstrap submenu to open on the left side?
but I could not figure out a way to use this to what I am looking to do
Thanks
How does this look:-
Demo
Demo2 Submenu dropping down.
<div class="span4">
<div class="btn-group"> <a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
<h3>Choose Child</h3>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent">
<span class="right-caret right"></span>
</a>
<ul class="dropdown-menu rightMenu">
<li>
<div class="btn-group"> <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>A</h5>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>J</h5>
<img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>
</div>
</li>
</ul>
</div>
css
.rightMenu {
position:relative;
float:right;
}
.right-caret {
border-bottom: 4px solid transparent;
border-top: 4px solid transparent;
border-left: 4px solid #000000;
display: inline-block;
height: 0;
opacity: 1;
vertical-align: top;
width: 0;
}
.right
{
float:right;
}
Just add the class "pull-right" into the <ul class="dropdown-menu"> this way...
<li class="dropdown">
<a class="dropdown-toggle" href="#">Link</a>
<ul class="dropdown-menu pull-right">
<li>...</li>
</ul>
</li>
I just add this class to the dropdown-menu:
.rightMenu {
position:absolute;
float:right;
top: 0;
left: 160px;
}
And it aligns perfectly.
To those who may find this page in the future, the now official way of doing this is with adding the .dropdown-menu-right class to your dropdown list.