bootstrap navbar dropdown does not work on iphone - css

I am using "bootstrap": "~3.3.4" inside the mean.js framework. The navbar dropdown menu does not have any problem opening and staying put when the dropdown icon is clicked on desktop. But after getting pushed to the staging server, clicking the icon on the iphone and samsung galaxy browsers no longer opens the dropdown menu or it sometimes opens it but it does not stay opened.
Here is the code:
<div class="landing-page-header">
<div class="navbar-header" >
<button class="navbar-toggle mytoggle" type="button" data-ng-click="toggleCollapsibleMenu()">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a data-ui-sref="home" class="navbar-brand">
<img class="header-logo" ng-src="modules/core/img/home/myimg.png" height="">
</a>
</div>
<nav class="collapse navbar-collapse" data-ng-show="!authentication.user" collapse="!isCollapsed" role="navigation">
<ul class="nav navbar-nav navbar-right landing-page-nav" data-ng-hide="authentication.user">
<li class="text-center" data-ng-repeat="item in menu.items | orderBy: 'position'"
data-ng-if="item.roles.indexOf('guest') !== -1"
ng-switch="item.type"
data-ng-class="{active: $state.includes(item.state)}"
class="{{item.class}}"
target="{{item.target}}"
dropdown="item.type === 'dropdown'">
<a ng-switch-when="dropdown" class="dropdown-toggle">
<span data-ng-bind="item.title"></span>
<b class="caret"></b>
</a>
<ul ng-switch-when="dropdown" class="dropdown-menu">
<li data-ng-repeat="subitem in item.items | orderBy: 'position'" data-ng-if="subitem.shouldRender(authentication.user);" data-ui-sref-active="active">
<a data-ui-sref="{{subitem.state}}" data-ng-bind="subitem.title"></a>
</li>
</ul>
<a ng-switch-default data-ui-sref="{{item.state}}" data-ng-bind="item.title"></a>
</li>
<li class="divider-vertical"></li>
<li class="text-center " data-ui-sref-active="active">
<a data-ui-sref="authentication.signin" target="_self">SIGN IN</a>
</li>
</ul>
</nav>
</div>
And Here is the CSS:
.landing-page-header {
position: fixed;
left: 0px;
top: 0px;
opacity: 0.9;
background: #111;
width:100%;
height: 5em;
z-index: 99;
margin-bottom: 10em;
}
.navbar-brand img {
/*background: #fff;*/
}
.landing-page-header ul {
background: #111;
margin-right:0.5em;
}
I had looked at other answers on this site and googled the issue. One answer I came across suggested to use a or input instead of button, but I still faced the same issue.
What is happening in the browser is that, on button click (hamburger) (on galaxy and iphone) immediately after the code is pushed to the staging server the navbar renders, but once a menu item is clicked, when you go back and click on the hamburger menu again, the navbar will behave weird starting to render and stopping and going back immediately.
Anyone has any idea?

I have found a solution for it myself. I just had to set the position of the drop down to "static" for screens less than 480px.
#media (max-width: 480px) {
.landing-page-header ul{
position: static;
width:100%;
}
}

Related

Change starting direction of caret on Bootstrap 4 dropdown

I can't believe this is as difficult as it seems. I want to use a Bootstrap dropdown list, but I want the caret to start off facing right and then point downward when the dropdown has been expanded. Rotating the caret as it is 90 degrees, is not the issue. The issue is how do I begin with the caret pointing to the right. Do I have hide the caret and totally replace it with something different?
CSS for rotation:
.dropdown-toggle[aria-expanded="true"]:after {
transform: rotate(90deg);
}
/*for animation*/
.dropdown-toggle:after {
transition: 0.7s;
}
HTML:
<div class="dropdown">
<span class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span>
Dropdown Example
</span>
</span>
<ul class="dropdown-menu">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</div>
Update
For #mahan who believes 'I must be doing something wrong". Here is the code for my test page in which the caret does appear pointing to the right, but it does not rotate and the menu does not expand:
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>TestPage</title>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<style>
.dropdown-toggle::after {
border-top: .3em solid transparent !important;
border-right: .3em solid transparent !important;
border-bottom: .3em solid transparent !important;
border-left: .3em solid !important;
vertical-align: middle !important;
transition: 0.7s;
}
.dropdown-toggle[aria-expanded="true"]:after {
transform: rotate(90deg);
/*
You may transform origin of the caret.
*/
transform-origin: 0.15em 0.32em;
}
</style>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</body>
</html>
<script src="~/Scripts/jquery-3.4.1.slim.js"></script>
<script src="~/Scripts/popper.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
this one makes dropdown face down
<div class="dropdown">
</div>
this one makes it open to the right then down.
<div class="dropright">
</div>
Thats what bootstrap website shows.
In case of replacing your caret this solution should work after doing display none to your caret icon. I am giving this alternative answer because i can not see working code in question
.dropdown-toggle::after {
content: ">";
transform: rotate(270deg);
}

Bootstrap 4.5.0: My Toggle Button Appears Just to the Right of my Brand Image/Name?How Do I Position it to the Left?

I have a problem where the toggle button appears just to the right of my brand image. The same thing happens if I use a brand name. This is what it looks like.
I want the toggle to look like this.
I have searched for solutions but all of them are dealing with earlier versions of Bootstrap. I started having the problem when I upgraded the Bootstrap gem to 4.5.0.
Here is my html code.
<div class="navbar-header">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fas fa-bars"></i>
</button>
<%= link_to image_tag("ibraini_navbar.png", class: "img-fluid navbar-brand", alt: "#{t :page_title_home}"), home_path %>
</div>
Here is the related CSS code. I didn't include the code where I set the height of the navbar to adjust the size of the image.
.navbar-custom .navbar-brand, .navbar-custom .navbar-header, .navbar-custom .navbar-nav { a { color: $linkColorHeader; } a:hover, a:focus { text-decoration: none; color: $linkColorHover; } }
.navbar-custom .navbar-toggler { color: $linkColorHover; #include font-size(24px); border-radius: 2px; padding: 0 4px; }
.navbar-custom .navbar-toggler:hover, .navbar-custom .navbar-toggler:focus { background-color: #599ed7; color: $linkColorHeader; }
.navbar-custom .navbar-brand .navbar-toggler:focus, .navbar-custom .navbar-brand .navbar-toggler:active, .navbar-custom .navbar-brand:focus { outline: 0; }
I have the same problem if I use a brand name. The toggle is still positioned just to the right of the name.
I have similar html and css code in the other program that is working like the second picture.
I checked the current documentation and it says that the toggle goes to the left by default which is what I want. I have never had this problem with a toggle. Hopefully there is something that I'm not seeing that can be easily fixed.
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand text-light" href="#">
<img src="" alt="logo-here" style="width:40px;"> Brand Name
</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link text-light" href="#">Link Here</a>
</li>
</ul>
</div>
</nav>
I took another look at the Bootstrap documentation. I realized that class 'navbar-header' no longer exists in Bootstrap 4.5.0. I rewrote my markup to look like the documentation found here.
The markup in my question is gone. Here is my new code.
<nav class="navbar fixed-top navbar-expand-lg navbar-custom">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-main-collapse"> <i class="fas fa-bars"></i> </button>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<%= link_to locale_root_path(anchor: "overview"), class: "navbar-brand page-scroll" do %>
<span class="text-red">Light</span><span class="text-blue">Be Corp</span>
<% end %>
......
</div>
</nav>
I have the toggle to the left without the brand name as expected. All of my websites will need to be modified. That's why my second image shows the brand name.

navbar disappears at medium (768px) - bootstrap 3.3.7

I have two navbars on my page. The first one is working, but the second one is not.
I have the following code for the 2nd one:
<nav class="navbar navbar-default">
<!-- <div class="container-fluid"> -->
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<span class="hidden-md hidden-lg"><a class="navbar-brand" href="#"> PRODUCTS >> </a></span>
<button type="button" class="navbar-toggle1 collapsed" data-toggle="collapse" data-target="#cat-nav-mega">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="cat-nav-mega">
<ul class="nav navbar-nav">
<li class="dropdown menu-large">
SCOTTCREW'S OWN SILICONE MOLDS <i class="fa fa-angle-down"></i>
<ul class="dropdown-menu megamenu" role="menu">
<li>
The actual working page can be seen at (The site is currently in development and not a live site):
https://www.scottcrewcandlesupply.com/agoracart55/agora.cgi?keywords=books#
Can anyone tell me why the navigation doesn't show at medium and how I
can fix this?
Thanks!
on you main css class you have this :
your cat navbar will be hidden if screen size is blower than 1200px based this css code on responsive.css :
#media (max-width:1200px)
{
.navbar-collapse.collapse
{
display: none!important;
}
}
so your first navbar has a responsive css and is visible only if screen is more than 1200px.
and about second navbar :
if only screen is more than 768px, it would be shown in style.css
#media (min-width: 768px) {
navbar-toggle1 {
display: none;
}
So there is a gap between this two #media size , and there will be no navbar if screen is more than 768px and less than 1200px.
Anyway for fixing the navbar you asked do these steps:
1-
.navbar-toggle1 { // at style.css line 68
display: none;
}
2- add hidden-lg to this :
<`a href="#" class="navbar-brand hidden-lg"> PRODUCTS >> </a>`
3- and hidden-lg to this
<button type="button" data-toggle="collapse" data-target="#cat-nav-mega"
class="navbar-toggle1 collapsed hidden-lg">
4- remove hiden-md and add a new class name like navbarNew
finaly they they have to be like blow:
<span class="navbarNew"><a href="#" class="navbar-brand hidden-lg">
PRODUCTS >> </a></span>
And
<button type="button" data-toggle="collapse" data-target="#cat-nav-mega"
class="navbar-toggle1 collapsed hidden-lg">
And it would works Fine:)

In Bootstrap, what is the correct way to add a badge to a navbar image?

I've got a Bootstrap Navbar that is fairly basic and populated with image links over text. However, I'd like to also include a badge - IE, show the number of messages.
The problem is the badge position. It gets placed to the right, but I would prefer to justify it to the top-right relative to the image. It also directly affects the width and height of the link itself.
<li>
<a href="#">
<?= $this->Html->image('MessageIcon.png'); ?>
<span class="badge">42</span>
</a>
</li>
I have tried a few solutions that turned out to be fairly messy - forcibly setting the badge position, but ultimately they did not work too well. Does anyone have suggestions on how to handle badge position and link design in this case?
EDIT: To clarify, this is what I am trying to achieve:
Checkout this snippet
.icon.container a>img {
width: 40px;
}
.icon.container {
display: inline-block;
}
.badge-notify{
position: relative;
top: -10px;
left: -18px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul>
<li class="icon container">
<a href="#">
<img src="https://cdn4.iconfinder.com/data/icons/ios7-active-2/512/Envelope.png">
<span class="badge badge-notify">3</span>
</a>
</li>
<li class="icon container">
<a href="#">
<img src="https://cdn4.iconfinder.com/data/icons/ios7-active-2/512/Envelope.png">
<span class="badge badge-notify">3</span>
</a>
</li>
<ul>

Menu keeps hiding behind other elements on page

I know this seems silly, but this menu is driving me nutty. I've fixed it a few times, but it keeps coming back and biting me in the butt.
The menu looks like this. And as you can see half of it is cut off so you cannot read the words.
I have tried many ways to fix this. I have moved the menu around in the html, tried positioning it and adding a z-index. But I have had no luck.
The html looks like this
<div class="pull-right" style="padding-top: 0px;">
<!-- drop button -->
<div class="btn-group js_editTab-wrapper open" data-bind="attr: { 'data-id' : id, 'data-type' : entityType}" data-id="25402" data-type="KioskPageControl">
<!-- ko if : $data.editTabs -->
<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu dropBorder" role="menu" data-bind="foreach: $data.editTabs">
<li>Appearance</li>
<li>Identification</li>
<li>Parameters</li>
<li>Rules</li>
</ul>
<!-- /ko -->
</div>
<span class="drag btn-xs btn-labeled btn-info">
<span class="btn-label"><span class="glyphicon glyphicon-move"></span></span>
</span>
<span class="remove btn-xs btn-labeled btn-danger">
<span class="btn-label"><span class="glyphicon glyphicon-remove"></span></span>
</span>
</div>
and the css for the menu looks like this
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
list-style: none;
overflow: visible;
Obviously the display none turns to block when clicked on the dropdown menu and the blue bar does have a z-index on it of 1. Any help would be appreciated!

Resources