I'm using this template:
http://bootstrap4.guide/
And I want to modify menu a bit, instead of having blue Bootstrap 4 text, I'd like to have a image there. It's looking all fine until I look at mobile view.
I'm expecting to have my image in the same place as the text:
However my image happens to appear under hamburger menu:
This is what I have at the moment:
<nav id='topNav' className='navbar navbar-default navbar-fixed-top'>
<div className='container'>
<button className='navbar-toggler hidden-md-up pull-right' type='button' data-toggle='collapse' data-target='#collapsingNavbar'>
☰
</button>
<a className='navbar-brand page-scroll' href='#first'><img src='logo.png'/></a>
<div className='collapse navbar-toggleable-sm' id='collapsingNavbar'>
<ul className='nav navbar-nav'>
<li className='nav-item'>
<a className='nav-link page-scroll' href='#one'>Cards</a>
</li>
<li className='nav-item'>
<a className='nav-link page-scroll' href='#two'>Flexbox</a>
</li>
<li className='nav-item'>
<a className='nav-link page-scroll' href='#three'>5 Tiers</a>
</li>
<li className='nav-item'>
<a className='nav-link page-scroll' href='#four'>More</a>
</li>
</ul>
<ul className='nav navbar-nav pull-xs-right'>
<li className='nav-item'>
<a className='nav-link page-scroll' data-toggle='modal' title='A free Bootstrap theme' href='#aboutModal'>About</a>
</li>
</ul>
</div>
</div>
</nav>
I've just replaced Bootstrap 4 with this img tag: <img src='logo.png'/>. I'm quite new to bootstrap, if someone would help me to figure out how to sort this out, that'd be great.
I would suggest to divide the the hamburger and the logo in two equal parts by using bootstrap classes for small devices.(col-xs-6)
<div class="col-xs-12">
<div class="col-xs-6">
<button className='navbar-toggler hidden-md-up' type='button' data-toggle='collapse' data-target='#collapsingNavbar'>
☰
</button>
</div>
<div class="col-xs-6">
<a className='navbar-brand page-scroll' href='#first'><img src='logo.png'/></a>
</div>
</div>
Adjust the navbar-brand class as needed for your logo image..
/* responsive nav */
#media(max-width:48em) {
.navbar-default .navbar-nav>.nav-item {
float: none;
margin-left: .1rem;
}
.navbar-default .navbar-nav {
float:none !important;
}
.navbar-default .navbar-brand {
float:none;
}
.navbar-default .navbar-brand img {
display:inline;
}
}
http://codeply.com/go/7HJgyK6nxQ
Related
I have a materialize css web app with a side-nav.
In the side-nav there are two "sub-menus" as dropdown-content.
It works perfectly fine on all browsers except Safari/iOS, where a click in the sub-menu will open another link than the one clicked. Looks a little random, but maybe it selects the link below in the sidenav menu.
The really weird thing is, that it works on iPhone 5.
It also works on iPhone 7 but here comes the weird part: only if you make long-click (tap and hold) on the menu item, then it displays a preview of the link and you can select open. In that case it is the correct menu item from the drop-down content that is displayed.
I am very puzzled and is excited to see if anyone can see through this...
I have tried a few different css options besided the standard materialize css, they are included in the code.
(Version 1.0.0 of materialize)
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
header, main, footer {
padding-left: 300px;
}
.hide-on-menu-out {
display: none;
}
/*https://github.com/Dogfalo/materialize/issues/1123 */
.navbar-fixed nav {
position: fixed;
/* width is 100% minus the fixed left navbar (240px) */
width: -moz-calc(100% - 300px); /* Firefox */
width: -webkit-calc(100% - 300px); /* Chrome, Safari */
width: calc(100% - 300px); /* IE9+ and future browsers */
}
.dropdown-content a {
/*background-color:red;*/
position:relative;
z-index: 10000 !important;
}
#media only screen and (max-width : 992px) {
header, main, footer {
padding-left: 0;
}
.show-on-menu-out {
display: block;
}
.hide-on-menu-out {
display: block;
}
/* https://github.com/Dogfalo/materialize/issues/1123 */
.navbar-fixed nav {
width: 100%;
}
}
</style>
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FormBody" runat="server">
<ul id="langdrops" class="dropdown-content">
<asp:Literal ID="litLangs" runat="server"></asp:Literal>
</ul>
<ul id="dropFriends" class="dropdown-content">
<li><i class="material-icons blue-text">map</i><%=Resources.KSLab.KS2020WithMenu_menuFriendRadar%></li>
<li><i class="material-icons blue-text">people</i><%=Resources.KSLab.KS2020WithMenu_menuFriends%></li>
<li><i class="material-icons blue-text">search</i><%=Resources.KSLab.KS2020WithMenu_menuSearchFriends%></li>
<li><i class="material-icons blue-text">clear_all</i><%=Resources.KSLab.KS2020WithMenu_menuFriendReq%></li>
</ul>
<ul id="dropMore" class="dropdown-content">
<li><i class="material-icons blue-text">flag</i><%=Resources.KSLab.KS2020WithMenu_menuMultitrack%></li>
<li><i class="material-icons blue-text">supervised_user_circle</i><%=Resources.KSLab.KS2020WithMenu_menuGroups%></li>
<li><i class="material-icons blue-text">star</i><%=Resources.KSLab.KS2020WithMenu_menuChallenges%></li>
<li><i class="material-icons blue-text">timeline</i><%=Resources.KSLab.KS2020WithMenu_menuRouteMeas%></li>
</ul>
<header>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper blue">
<ul id="nav-mobile" class="left">
<!-- show-on-large show-on-extra-large -->
<li><i class="material-icons">menu</i></li>
<%--<li><i class="material-icons">language</i></li>--%>
</ul>
<span data-target="slide-out" style="cursor: pointer" id="navbarBoatName" class="sidenav-trigger center hide-on-menu-out"></span>
<a href="/" style="margin-top: 4px; margin-right: 5px;" class="right brand-logo">
<img style="height: 50px;" src="/Public/Images/LogoWhite150x57.png" /></a>
</div>
</nav>
</div>
<ul id="slide-out" class="sidenav sidenav-fixed blue">
<li>
<div class="user-view">
<div class="background">
<img src="/Public/Images/ocean.jpg">
</div>
<div id="notifyAlert" class="notifyAlert">
<a href="/notifications" class="btn-floating btn-large waves-effect pulse waves-light alert-red">
<i class="fa large fa-bell"></i></a>
</div>
<img id="menuBoatImage" class="circle" src="/Public/Images/noimage.png">
<div style="clear: both"></div>
<div id="menuBoatName" class="white-text name"></div>
<div id="menuBoatType" class="white-text email"> </div>
</div>
</li>
<li><i class="material-icons white-text">home</i><%=Resources.KSLab.KS2020WithMenu_menuHome%></li>
<li><i class="material-icons white-text">map</i><%=Resources.KSLab.KS2020WithMenu_menuMyLog%></li>
<li><i class="material-icons white-text">share</i><%=Resources.KSLab.KS2020WithMenu_menuShare%></li>
<li><i class="material-icons white-text">people</i><%=Resources.KSLab.KS2020WithMenu_menuSubFriends%></li>
<li><i class="material-icons white-text">filter_9_plus</i><%=Resources.KSLab.KS2020WithMenu_menuMore%></li>
<li><i class="material-icons white-text">settings</i><%=Resources.KSLab.KS2020WithMenu_menuMyProfile%></li>
<li>
<div class="divider"></div>
</li>
<li><i class="material-icons white-text">language</i><%=Resources.KSLab.generalSelectLanguage%></li>
<li><i class="material-icons white-text">help_outline</i><%=Resources.KSLab.KS2020WithMenu_menuHelp%></li>
<li><i class="material-icons white-text">info</i><%=Resources.KSLab.KS2020WithMenu_menuAbout%></li>
<li><i class="material-icons white-text">close</i><%=Resources.KSLab.KS2020WithMenu_menuLogOff%></li>
</ul>
</header>
<main>
<asp:ContentPlaceHolder ID="BelowMenu" runat="server"></asp:ContentPlaceHolder>
</main>
<asp:ContentPlaceHolder ID="OutsideMain" runat="server"></asp:ContentPlaceHolder>
</asp:Content>
I added inDuration, outDuration and closeOnClick options to fix this. Here are all my options for this particular example.
var dropdownOptionsMobile = {
coverTrigger: false,
inDuration: 0,
outDuration: 0,
hover: false,
closeOnClick: false
}
var elems = document.querySelectorAll('.dropdown-trigger-mobile');
var instances = M.Dropdown.init(elems, dropdownOptionsMobile);
It is a known issue, here you can read about it and the solution:
Select element is misbehaving on iOS
Shortly, the dropdown issue itself is caused by the animation. You can use the materialize-css-helper package to keep the animation and fix the issue, or just remove the animation through css:
.dropdown-content {
transform: none !important;
}
I have the same problem and I've founded out that it is a bug. They've already fixed it, but didn't released :(
Look here, there are some tips, like set closeOnClick to false
On wider screens my login button is visible, but on smaller screens it is hidden.
JSBIN http://jsbin.com/nowubuseqeza/1/edit?html,js,output
Relevant code:
<div class="top-bar" data-topbar="" style="background:#074e68">
<ul class="title-area">
<li class="name">
<h1><img class="left" src="images/pluslogo.png" style="margin:2px 1em;height:40px;width:40px" alt="Pacific Medical Training"> Pacific Medical Training</h1>
</li>
</ul>
<div class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="active">
Login
</li>
</ul>
</div>
</div>
Is it possible to have this visible in all circumstances? Otherwise my users cannot login.
Change your code to this DEMO
<div class="top-bar" data-topbar="" style="background:#074e68">
<div class="top-bar-section right">
<!-- Right Nav Section -->
<ul class="right show-for-small">
<li class="active">
Login
</li>
</ul>
</div>
<ul class="title-area">
<li class="name">
<h1><img class="left" src="images/pluslogo.png" style="margin:2px 1em;height:40px;width:40px" alt="Pacific Medical Training"> Pacific Medical Training</h1>
</li>
</ul>
<div class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="active">
Login
</li>
</ul>
</div>
</div>
In the smaller screen, a number of css properties are changing for the title-area and the links in the top-bar. If you add the following, it should bring the login button back on small screens:
//Only use it for screens under 40.063em, using the media query
#media only screen and (max-width: 40.063em) {
.top-bar .name h1 a {
width: auto;
}
.top-bar-section ul {
width: auto;
}
.top-bar-section ul li.active > a {
padding: 0px 15px;
line-height: 45px;
}
.top-bar .title-area {
float: left;
}
}
However, it may need a bit more refinement for very small screens where the "Pacific Medical Training" takes up the whole top-bar and pushes the login button down
I'm trying to move my navbar to the right, tried both navbar-right, and pull-right, but all I get is something like this -
<div class="container" >
<h1 align="center">My Site</h1>
<div class="container" >
<ul class="nav nav-tabs navbar-right" >
<li class="active">tab1</li>
<li>tab2</li>
<li>tab3</li>
<li>tab4</li>
</ul>
</div>
<br>
Hello
</div>
So there are 2 problems here -
The grey line underneath the tabs is much shorter, and the tabs themselves aren't aligned properly - I want "tab1" to be the rightmost one, and correspondingly "tab4" the leftmost one.
I get the same results for navbar-right and pull-right. How can this be fixed?
Thanks!
you can easily have that behavior by just extending the Bootstrap.
Demo on JSBin: http://jsbin.com/zaniz/1/edit?html,css,output
all I did was added a right-to-left class to the <ul> and the CSS Style should be:
.right-to-left li { float: right; }
I've added the following rules to solve the problem without losing the border on the ul or reordering the markup:
.nav-tabs-right { text-align: right; }
.nav-tabs-right > li { display: inline-block; float: none; }
you can apply that to .nav-tabs directly but I prefer to create a separate class to replace .navbar-right
You can try this; if you want that gray line to cover the entire page horizontly
<div class="container" >
<h1 align="center">My Site</h1>
<div class="container" >
<ul class="nav nav-tabs" >
<li class="active pull-right" >tab1</li>
<li class="pull-right">tab2</li>
<li class="pull-right">tab3</li>
<li class="pull-right">tab4</li>
</ul>
</div>
<br>
Hello
</div>
I just added a float: right; (equal to pull-right) style to the <ul> and it seemed to produce the desired output, as for the tab1 being the rightmost one, it's probably best to reorder your markup to say:
<ul class="nav nav-tabs navbar-right" >
<li class="active">tab4</li>
<li>tab3</li>
<li>tab2</li>
<li>tab1</li>
</ul>
Using Bootstrap 5 you can simple add justify-content-end to the <ul> class
<div class="container" >
<h1 align="center">My Site</h1>
<div class="container" >
<ul class="nav nav-tabs justify-content-end" >
<li class="active">tab1</li>
<li>tab2</li>
<li>tab3</li>
<li>tab4</li>
</ul>
</div>
<br>
Hello
I am trying to make this website:
http://knightforged.com/stout/index5.html
I am trying to place a logo on top of the slider. It shows behind the slider. The navigation menu shows up on top just fine.
I have tried modifying z-indexes, and I have tried modifying the slider CSS (which comes from here: http://codepen.io/anon/pen/cImqB ) by changing position modifiers.
My professor tried several different things and we still couldn't figure it out.
I'm not sure if it's okay to omit the text since it can be viewed from source via the actual webpage; so if you prefer I can paste it on here.
Thank you.
Here is relevant code:
HTML:
<div class="grid_12">
<div class="grid_4 alpha">
<img src="images/logo.png" class="imgresponsive" />
</div>
<div class="grid_8 omega">
<ul id="nav" class="dropdown menu horizontal">
<li>About
<ul>
<li>Company History</li>
<li>Customer Testimonials</li>
</ul>
</li>
<li>Products
<ul>
<li>Tile</li>
<li>Metal</li>
<li>Shingle</li>
<li>Flat</li>
</ul>
</li>
<li>Project Gallery</li>
<li>Contact Us</li>
<li>Pay Invoice</li>
</ul>
</div>
</div>
<ul class="slides">
<input type="radio" name="radio-btn" id="img-1" checked />
<li class="slide-container">
<div class="slide">
<img src="images/tile_04big.jpg" class="slider_image" />
</div>
<div class="slider_nav">
<label for="img-2" class="prev">‹</label>
<label for="img-2" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-2" />
<li class="slide-container">
<div class="slide">
<img src="images/tile_13.jpg" />
</div>
<div class="slider_nav">
<label for="img-1" class="prev">‹</label>
<label for="img-1" class="next">›</label>
</div>
</li>
<li class="nav-dots">
<label for="img-1" class="nav-dot" id="img-dot-1"></label>
<label for="img-2" class="nav-dot" id="img-dot-2"></label>
</li>
</ul>
CSS (unworking code):
.imgresponsive {
width:100%;
height:auto;
}
CSS (working code):
.imgresponsive {
width:100%;
height:auto;
position: relative;
z-index: 597;
/* z-index: 10 !important; */
}
You have the z-index on the navigation ul set to 597 and it is showing up. Try setting the class .imgresponsive (which is the class for the logo not th parent div) z-index to 597 and set its position to relative.
You can do it for example by styling your logo with this:
#logo {
position: relative;
z-index: 1;
}
The logo id should be for the image of your logo
This is how it looks: screenshot
Can you try this one,
inline css:
<img style="z-index:10!important;position:relative;" src="images/logo.png" class="imgresponsive">
css:
.imgresponsive{
z-index:10!important;
position:relative;
}
I want to create fluid layout using LESS and without using Bootstrap grid clasess like .span6 on html code. How can I do this?
When I wrote without LESS I create layout like this:
<div class="container-fluid">
<div class="row-fluid" id="header">
<div class="span4 block">
<h1 class="title">Sample Site</h1>
<h2 class="sub-title">Powered by Twitter Bootstrap</h2>
</div>
<div class="span6 block">
<ul class="nav nav-pills">
<li class="active">Home</li>
<li>Pages</li>
<li>Typography</li>
<li>UI</li>
<li>Calendar</li>
<li>Tables</li>
</ul>
</div>
<div class="span2 block">
<div class="btn-group open">
<button class="btn">Dropdown</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Change password</li>
<li>Log in with another user</li>
<li>Change token</li>
<li>Log out</li>
</ul>
</div>
</div>
</div>
<div class="row-fluid" id="slider">
<div class="span12 block">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
Now, my layout looks next way:
<div id="wrap">
<div id="header">
<div id="logo">SiteLogo</div>
<div id="top-menu">
<ul>
<li>Home</li>
<li>Page 1</li>
<li>Page 2</li>
</ul>
</div>
<div id="logout">
Logout
</div>
</div>
<div id="slider">
and what I should write on my .less file if I want to make div#wrap -> .container-fluid,
div#header -> .row-fluid, div#logo -> .span4, div#top-menu -> .span6, div#logout -> .span2
without writting this clasess on html code?
First, this wouldn't really be semantic, at least, no more so.
The semantic form of <div id="top-menu"> is <nav> or <nav id="top">
The semantic form of <div id="header"> is <header>
In any case, there are instructions on doing this here:
Please stop embedding Bootstrap classes in your HTML
Honestly, though, it's not as simple as the author makes it look. Just because you have a <nav> inherit the styles of .nav from Bootstrap doesn't mean its children will inherit inherited styles as well.
So if I define a style from .nav ul, a <ul> element will not receive this style if it's in a <nav>.
This worked for me.. posting in case it helps anyone else.
Mixins for semantic fluid grid:
.makeFluidRow(){
width: 100%;
.clearfix();
}
.makeFluidCol(#span:1,#offset:0){
float: left;
#grid > .fluid .span(#span);
#grid > .fluid .offset(#offset);
&:first-child {
margin-left: 0;
.offsetFirstChild(#offset);
}
}
Use them just like the non-fluid mixins:
div#header{
.makeFluidRow();
div#logo {
.makeFluidCol(4); //Spans 4 cols
}
div#top-menu {
.makeFluidCol(6); //Spans 6 cols
}
div#logout {
.makeFluidCol(2); //Spans 2 cols
//Or you could have span1, offset1 using .makeFluidCol(1,1);
}
}