I am having some difficulty with a .NET MAUI Blazor project, I am not very familiar with the platform. The application in question was created from the template demo app created upon project setup in visual studio. (I am just testing this snippet to see if I can get it to work in isolation before adding it to the rest of my project). The issue I am having only seems to persist when running the application on iOS devices (The task bar is on the bottom of the screen on windows, Android and MacCatalyst). I am trying to create a task bar fixed to the bottom of the display. Upon launch the task bar is some distance from the bottom and I can't seem to override this to make it actually on the bottom. For some unknown reason the task bar does jump to the bottom of the display after you rotate the device 90 degrees and back. The project is unchanged from the template with the exception of the following code snippet pasted into the NavMenu.razor file:
<nav class="navbar navbar-expand fixed-bottom" style="background-color: beige">
<div class="container-fluid">
<div class="nav-item d-inline-flex">
<NavLink class="nav-link text-center" href="/">
<span class="oi oi-home"></span>
</NavLink>
</div>
<div class="nav-item d-inline-flex">
<NavLink class="nav-link text-center" href="search">
<span class="oi oi-magnifying-glass"></span>
</NavLink>
</div>
<div class="nav-item d-inline-flex">
<NavLink class="nav-link text-center" href="post">
<span class="oi oi-plus"></span>
</NavLink>
</div>
<div class="nav-item d-inline-flex">
<NavLink class="nav-link text-center" href="learn">
<span class="oi oi-bolt"></span>
</NavLink>
</div>
<div class="nav-item d-inline-flex">
<NavLink class="nav-link text-center" href="book">
<span class="oi oi-book"></span>
</NavLink>
</div>
</div>
</nav>
The project is using Bootstrap 5. The fixed-bottom tag does not seem to do anything (on iOS) as I understand it should. I have also tried putting this snippet directly in the MainLayout.razor in its own div and assigning the CSS properties manually, with little effect. I am familiar with the concept of safe-areas in iOS, but I have not been able to find a working solution to this problem.
Is there some property I am unaware of that allows you to properly assign something to the bottom of the screen?
I have tried using CSS to style the component with:
.mynav {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
}
with little effect. I also looked into webkit safe areas and The default project uses safe areas to prevent rendering overtop of things like the clock and such at the top of the screen, but I do not see any similar attribute to be causing this on the bottom.
It seems that the distance is due to the safearea in iOS. You could set safearea for iOS platform. Add the following code in your MainPage.xaml:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
....
BackgroundColor="{DynamicResource PageBackgroundColor}"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.UseSafeArea="True">
This reduce much of the distance from the bottom.
Hope my answer could help you.
Related
I want to deepen my knowledge about accessibility. So I appreciate any feedback. Please check this code whether it fulfills (hopefully high) standards of accessibility for a responsive menu. I think that there may be some issues with keyboard navigation – but I don’t know.
First the HTML. Pls. notice the comments inside the HTML:
For convenience I list them here too:
Wrap navigation in nav tag. Don't use <div class="navigation">
Give navigation a role="navigation"
Don't wrap button in a tag or div. Instead use button
Give screenreader a hint, whether menu is expanded or hidden with area-expanded="Boolean". Add hint dynamically with JS.
So the complete HTML is:
<header class="header">
<!-- role=navigation to ensure better support, since not all browsers/screen readers will recognize the <nav> element. -->
<nav role="navigation" class="navbar">
companyLogo
<ul class="nav-menu">
<li class="nav-item"><a class="nav-link" href="#">Services</a></li>
<li class="nav-item"><a class="nav-link" href="#">About</a></li>
<li class="nav-item"><a class="nav-link" href="#">nav</a></li>
</ul>
<!-- By using aria-expanded attribute, the user will be able to know that the button content is expanded or collapsed. At first, we will add the attribute by default and then JavaScript will help changing the value.
https://www.a11ymatters.com/pattern/mobile-nav/ -->
<button class="hamburger" aria-expanded="false">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
</nav>
</header>
I reduce the CSS part to this:
.hamburger {
display: none;
}
Is it appropriate to hide the .hamburger in the DOM? (I also gave it an area-expanded – does it make sense?)
The JS: Here I am primarily interested whether the if statement changing the area-expanded dynamically works as intended.
const hamburger = document.querySelector(".hamburger");
const navMenu = document.querySelector(".nav-menu");
hamburger.addEventListener("click", openMenu);
function openMenu() {
hamburger.classList.toggle("active");
navMenu.classList.toggle("active");
// Not sure whether, this is correct
if (navMenu.classList.contains("active")) {
hamburger.setAttribute("aria-expanded", "true");
} else {
hamburger.setAttribute("aria-expanded", "false");
}
}
It would be great, if:
you could provide feedback, which makes this menu more accessible.
you could give me an idea how to optimize the keyboard input.
you comment whether it is approppriate to hide the the hamburger with display: none
you could tell me whether the JS which dynamically changes the Boolean in area-expanded is correct.
Thank you for your time.
I would like to achieve a mobile menu which is always visible on the bottom of my page. I don't know if there is a specific name for such menus but I've found a page which does exactly this menu:
What is the best way to achieve exactly this for tablet and smaller devices using materialize?
There is something called a Toolbar in Materialize.
<div class="fixed-action-btn toolbar">
<a class="btn-floating btn-large red">
<i class="large material-icons">mode_edit</i>
</a>
<ul>
<li class="waves-effect waves-light"><i class="material-icons">insert_chart</i></li>
<li class="waves-effect waves-light"><i class="material-icons">format_quote</i></li>
<li class="waves-effect waves-light"><i class="material-icons">publish</i></li>
<li class="waves-effect waves-light"><i class="material-icons">attach_file</i></li>
</ul>
</div>
But it's not the same what you are looking for. You have to modify this or you need to create your own.
Fab for toolbar:
http://materializecss.com/buttons.html
Have you tried to use CSS, select the whole menu by class or id and set it to position fixed?
#fixedMenu{
position:fixed;
}
You can then play around as the where exactly you want to place it. By using width or margins set to auto then you can make it responsive for different viewports.
I have a bootstrap drop down on my modal dialog.
After clicking on drop down button drop down menu appears under form.
Is there any way to fix this issue, but without using "position:fixed",because by using fixed attribute I am facing with other issues.
<div id="dialog" title="Basic dialog" ng-show='showDialog'>
<div class="container">
<h2>Dropdown</h2>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li>AAAAAA</li>
<li>BBBBBB</li>
<li>CCCCCC</li>
<li>DDDDDD</li>
<li>EEEEEE</li>
<li>FFFFFF</li>
</ul>
</div>
</div>
</div>
See the dropdwon plnkr
The problem is that the dialog, wich is a div, efectively "contains" the dropdown and all it's contents, so the drowpdown stacking context is surrogated to it.
You can add this css rule to overcome your problem, but take it carefully so it doesn't have any side effects in other dialogs on your app:
<style>
.ui-dialog, #dialog, #container { overflow:visible; }
</style>
You also have a great article here explaining stacking contexts as Z-Index isn't what most people think...
I'm experimenting with Bootstrap 3.2. I'm trying to create a fixed at top navigation bar but I'm running into two problems:
The navigation bar overlaps the content below it.
The navigation bar seems to be going far off the screen to the right. This makes my button in the navigation bar not visible unless the window width is dragged to a smaller size.
For the first problem, I've followed the Bootstrap example tip by adding a class to my css file, including this file below the Bootstrap css file in the html document, and then referring to the class.
.navbar-height{
body{padding-top: 200px;}
}
<body class="navbar-height">
Though, this seems to do nothing (as you can see I specified the number really high hoping to see a dramatic change, which did not occur).
Here's my the navigation bar:
<header id="header-navigation">
<div id="nav-bar-container">
<nav id="nav-bar" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div id="nav-item-container" class="container-fluid">
<div id="drop-down" class="navbar-header">
<button type="button" class="btn btn-default navbar-btn navbar-toggle collapsed" data-toggle="collapse" data-target="#user-dropdown">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div id="home-button" class="navbar-left">
<a class="navbar-brand" href="#"><img alt="Brand" src=""></img></a>
</div>
</div>
<div id="user-dropdown" class="navbar-collapse collapse">
<ul class="dropdown-menu" id="dropdown-items" role="menu">
<li>
<div class="list-group-item">
<div class="row-picture">
<img class="circle" src="" alt="icon"></img>
</div>
<div class="row-content">
<h4 class="list-group-item-heading">Placeholder</h4>
<p class="list-group-item-text">Placeholder</p>
</div>
<div class="list-group-seperator"></div>
</div>
</li>
<li><span class="glyphicon glyphicon-log-out"></span></li>
</ul>
</div>
</div>
</nav>
</div>
</header>
As a quick break down of the above code, I have a <header> tag which will hold the navigation bar. Within this <header>, I have a containing <div> (id="nav-bar-container") which only purpose is to act as a container for the navigation bar (maybe I'll add something else to the header and want to keep the bar seperate). Then, I have the actual <nav> which has the appropriate classes (or so I think): "navbar navbar-default navbar-fixed-top". The next <div> (id="nav-item-container") holds the components of the navigation bar. The following <div> (id="drop-down") contains the button (which seems to disappear at full-screen) and a link with a "brand", which always seems to be visible. The last major <div> contains the "drop down" content for when the button is pressed.
My Question: why is my navigation bar overlapping the content below it and over extending to the right hiding the button?
Ok, first thing, you don't need the <header> tag, so feel free to remove that.
Second, from the Docs on navbar-fixed-top, you need to have padding:
body { padding-top: 70px; }
Notice you applied it to the heading style; that won't work. Apply it to the body and it works fine.
As far as the 2nd issue, I don't actually see any horizontal scrolling when I removed the
<header> tag, so I think that may have been causing an issue.
Checkout this Bootply example:
Bootply Example
To see what I mean. It's your code with the tag removed. Hope that helps!
Change..
.navbar-height{
body{padding-top: 200px;}
}
to..
body.navbar-height{
padding-top: 200px;
}
You want the padding on the body itself. This will push you body down 200px giving you a gutter at the top for your fixed navbar.
most likely you'd want to adjust this padding depending on the actual height of your navbar.
As for problem number two, where I believed the navigation bar to be overflowing off the screen to the right, was just a mistake in the layout of the code. I was grouping the button I wanted to display on the right with the brand in the "navbar-header". What this does is display the brand but use that button only on a mobile screen to hide or show its associated dropdown. That is why I was only seeing the button when I made the width smaller by dragging the window. To fix this problem I removed the button and placed it within the appropriate code block. So, my "navbar-header" now looks like this:
<div id="drop-down" class="navbar-header">
<div id="home-button" class="navbar-left">
<a class="navbar-brand" href="#"><img alt="Brand" src=""></img></a>
</div>
</div>
Now, next within the id="nav-item-container" parent div, I create a list of items (ul). This list contains the items within the navigation bar and has the classes "nav navbar-nav navbar-right". Each list item (li) within this list is an item within the navigation bar. Dropdown buttons and their contents must be contained within the same list item (li). Make sure the parenting list item to the dropdown elements contains the class "dropdown". Then, the button or link should have the "dropdown-toggle" class applied to it. And the dropdown items themselves (which too can be a list of items and often is) should have the class "dropdown-menu". For example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-align-justify"></span>
</a>
<ul class="dropdown-menu" id="dropdown-items" role="menu">
<li>
<div class="list-group-item">
<div class="row-picture">
<img class="circle" src="" alt="icon"></img>
</div>
<div class="row-content">
<h4 class="list-group-item-heading">Placeholder</h4>
<p class="list-group-item-text">Placeholder</p>
</div>
<div class="list-group-seperator"></div>
</div>
</li>
<li><span class="glyphicon glyphicon-log-out"></span></li>
</ul>
</li>
</ul>
Note, in the snippet I didn't include the parenting nav, div, or header so it may not work exactly how it should. Also, I figured the majority of this out on my own by referencing the Bootstrap component page, as well as, the Bootstrap material design page (a plugin to Bootstrap that gives everything the Google Material Design look and feel). So, I'm not sure if all the "rules" I stated are mandatory or if there are other ways to achieve this.
As for problem number one, I just made a silly mistake with the css and the two other answers provided correct ways of fixing it. All I had to do was fix the body css like so:
body{
padding-top: 200px;
}
I am using bootstrap 3 on a Rails 4 app.
I have a "normal" fixed navbar on the page headers. For the moment, when the viewport decreases (small device), all menu titles disappear and go into the "three bars" icon like here: http://getbootstrap.com/examples/navbar-fixed-top/ (try on a small screen/viewport).
Is it possible with bootstrap 3 to NOT make all menu titles go into this three bar icon, but to replace all texts by very small icons (for example Help would be replaced by a " ? "icon) so that there is enough space for all of them, when the viewport is very small.
Is there something already built-in inside Bootstrap allowing to do that ? or maybe some external libraries that play well with BS3?
thanks
That should not be to hard, and no need for a framework. You can use the responsive utility classes provided by BS3. With those, you can hide the icons on big screen and show the labels, and the opposite when on small screen. Your navbar markup would look something like this:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="#">
<i class='glyphicon glyphicon-user visible-xs-inline-block'></i>
<span class='hidden-xs'>Link</span>
</a></li>
<li><a href="#">
<i class='glyphicon glyphicon-user visible-xs-inline-block'></i>
<span class='hidden-xs'>Link</span>
</a></li>
</ul>
</div>
</nav>
And a small line of css is required to prevent the li from being displayed as block on small screens. Something like this should do the trick:
.nav>li {
display: inline-block;
}
And an example to demonstrate: http://www.bootply.com/a17IsJ0Pop