Adding profile option next to navbar - css

I have made a navbar, but I still have to add such thing:
A profile picture and name next to it and then company name below the name and two buttons below them (red lines). I can't get through this.
Here is the code:
<nav class="navbar navbar-default">
<div class="container-fluid" style="height: 100px; max-width:1200px">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="logo.png">
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav" style="padding-top: 35px">
<li class="active">Home</li>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>About Us</li>
</ul>
<img src="obrazek.jpg" style="width:80px; height: 80px; border-radius: 50%; margin-top: 10px">
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>

Working example:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid" style="height: 100px; max-width:1200px">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="logo.png">
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav" style="padding-top: 35px">
<li class="active">Home</li>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>About Us</li>
</ul>
<img src="obrazek.jpg" style="width:80px; height: 80px; border-radius: 50%; margin-top: 10px"> <div style="display:inline-block;">
<span>some name</span><br>
<span>company name</span><br>
<button>btn1</button><button>btn2</button>
</div>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>
I just want to remind you, that SO is not a free coding service, nor a tutorial website.
Hope this helps!

Related

How to keep a Bootstrap navbar link from collapsing

If I have a Bootstrap3 navbar like in the snippet below, how can I prevent items from collapsing with the rest of the menu items when the viewport shrinks, while maintaining their styling?
In the example, Text and Link 1 menu items don't collapse, but they screw up the menu.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
<ul class="nav navbar-nav">
<li><p class="navbar-text" href="#">Text </p></li>
<li>Link 1</li>
</ul>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link 2</li>
<li>Link 3</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Link4</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
Just added a class 'navbar-nav--static-left' to the left nav and applied some styles on it. Hope it will help you. Please check.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<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.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
<ul class="nav navbar-nav navbar-nav--static-left">
<li>
<p class="navbar-text" href="#">Text </p>
</li>
<li>Link 1</li>
</ul>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link 2</li>
<li>Link 3</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Link4</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<style>
.navbar-nav--static-left {
float: left;
width: auto;
}
.navbar-nav--static-left>li {
float: left;
position: relative;
}
#media (max-width:767px) {
.navbar-nav--static-left .navbar-text {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px;
}
}
</style>

In Bootstrap, how would you change background color of dropdown menu header whose parent is transparent?

I searched the whole Internet, but none of the solutions work.
What I am trying to do?
I want to change the background color of the dropdown menu header.
https://ibb.co/cthhTk
HTML:
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> Blackbird </a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li> Search </li>
<li class="dropdown">
Sign In/Up <b class="caret"></b>
<ul class="dropdown-menu" class="dropdownMenu">
<li> Sign Up </li>
<li> Sign In </li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="seperator"></li>
<li> Article </li>
<li> Contact </li>
</ul>
</div>
</div>
</nav>
CSS:
/* Neither does this work: */
.dropdown {
background-color: #E32636;
}
/* Nor this: */
/* .navbar .navbar-default .navbar-nav .dropdown-menu li > a {
background-color: #E32636;
}
*/
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> Blackbird </a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li> Search </li>
<li class="dropdown">
Sign In/Up <b class="caret"></b>
<ul class="dropdown-menu" class="dropdownMenu">
<li> Sign Up </li>
<li> Sign In </li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="seperator"></li>
<li> Article </li>
<li> Contact </li>
</ul>
</div>
</div>
</nav>
I have added an ID to the hyperlink which opens the signIn/signOut menu.
and then add a background color to it, so
#authentication{
background-color: #f60;
}
or, if you really dont wanna add a new ID or a class, you can query the element as something like,
navbar navbar-collapse>ul>li:nth-child(2)>a{
background-color: #f60;
}
Check this working code:
.navbar-nav > li.dropdown.open a, .navbar-nav > li.dropdown.open a:focus, .navbar-nav > li.dropdown.open a:hover{
background-color: #E32636;
}
.navbar-nav > li > .dropdown-menu {
background-color: #E32636;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> Blackbird </a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li> Search </li>
<li class="dropdown">
Sign In/Up <b class="caret"></b>
<ul class="dropdown-menu" class="dropdownMenu">
<li> Sign Up </li>
<li> Sign In </li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="seperator"></li>
<li> Article </li>
<li> Contact </li>
</ul>
</div>
</div>
</nav>
You can also check this working Fiddle

bootsrap nav not responding well when layout changes

<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-brand pull-left">
<a href="#" class="pull-left">
<img width="150" height="45" class="navbar-left" src="Intellicell_files/IntelliCell-Logo.png" /></a>
</div>
<button class="navbar-toggle pull-right" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navHeaderCollapse pull-right">
<ul class="nav navbar-nav navbar-right navbar-text">
<li><a id="homeLink" href="#" data-target="home_container">Home</a></li>
<li><a id="contractslink" href="Contracts.aspx">Contracts</a></li>
<li><a id="accounts" href="AccountHistory.aspx">Account History</a></li>
<li>Contact Us</li>
<li><a id="refer" href="#">Refer a Friend</a></li>
<li><a id="tracker" href="#">Incentive Tracker</a></li>
</ul>
</div>
</div>
<div class="center-block" id="divider">
<div class="nav-divider">
<h4 class="text-center">HOME</h4>
<%--<asp:Button Text="Logout" CssClass="btn btn-group-sm form-control" ID="btnLogOut" runat="server" align="right" OnClick="btnLogOut_Click"/>--%>
</div>
</div>
</div>
the problem comes when I test the Navbar on a tablet and that causes the navbar to go under the logo that i have put there, so i was wondering if there is a way of making sure that the nav logo and the nav options are always on the same line. i am using bootstrap by the way
One option is to reduce the padding between your links.
Also, see the Docs regarding how to structure a default navbar.
.navbar .navbar-brand {
padding-top: 3px;
}
#media (min-width: 768px) {
.navbar .navbar-nav > li > a {
padding-left: 8px;
padding-right: 8px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navHeaderCollapse" aria-expanded="false"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img width="150" height="45" src="http://placehold.it/150x45/f00" />
</a>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-right">
<li><a id="homeLink" href="#" data-target="home_container">Home</a>
</li>
<li><a id="contractslink" href="Contracts.aspx">Contracts</a>
</li>
<li><a id="accounts" href="AccountHistory.aspx">Account History</a>
</li>
<li>Contact Us
</li>
<li><a id="refer" href="#">Refer a Friend</a>
</li>
<li><a id="tracker" href="#">Incentive Tracker</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<button class="navbar-toggle pull-right" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navHeaderCollapse">
<div class="navbar-brand">
<a href="#">
<img height="45" class="navbar-left" src="http://i.ytimg.com/vi/PDfWeUP09TA/hqdefault.jpg" /></a>
</div>
<ul class="nav navbar-nav navbar-right navbar-text">
<li><a id="homeLink" href="#" data-target="home_container">Home</a></li>
<li><a id="contractslink" href="Contracts.aspx">Contracts</a></li>
<li><a id="accounts" href="AccountHistory.aspx">Account History</a></li>
<li>Contact Us</li>
<li><a id="refer" href="#">Refer a Friend</a></li>
<li><a id="tracker" href="#">Incentive Tracker</a></li>
</ul>
</div>
</div>
<div class="center-block" id="divider">
<div class="nav-divider">
<h4 class="text-center">HOME</h4>
<%--<asp:Button Text="Logout" CssClass="btn btn-group-sm form-control" ID="btnLogOut" runat="server" align="right" OnClick="btnLogOut_Click"/>--%>
</div>
</div>
</div>
ul li a{
padding-left: 10px !important;
padding-right: 10px !important;
}
Im not frontend, but it should help :)
I wrapped img and ul by div, and thru smaller padding get img to row with menu.
Its just a suggest, problem is, ul li a is too big, and push img up

collapsible navigation bar become invisible on mobile screen

I am trying to implement twitter bootstrap collapsible navigation bar. On Desktop navigation bar is visible but on mobile screen it's not visible.
Here is View Part
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand"><img src="/x/img/X.png" style="width:80px; position:relative; top:-20px;"></img></h3>
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right" style="margin-top:15px;background-color:rgba(255,255,255,.4)">
<li class="active"><a class="call_us btn btn-default no-rounded btn-hollow" th:text="${'+91 444}" style="cursor:default; pointer-events:none;"> Call Us 555</a></li>
<li ><a th:href="#{/X}" href="#">X</a></li>
<li><a th:href="#{/Y}" href="#">Y</a></li>
<li><a th:href="#{/Z}" href="#">Z</a></li>
<li><a th:href="#{/T}" href="#">C</a></li>
<li class="active"><a th:href="#" href="#">Blog</a></li>
<!--li>Help</li-->
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
Can some one help me to fix this issue. I have included collapse.js in my path.
You're missing the navbar class which is the first line of the default navigation in Bootstrap. See Docs.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand"><img src="http://placehold.it/350x150" style="width:80px; position:relative; top:-20px;"></img></h3>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right" style="margin-top:15px;background-color:rgba(255,255,255,.4)">
<li class="active"><a class="call_us btn btn-default no-rounded btn-hollow" th:text="${'+91 444}" style="cursor:default; pointer-events:none;"> Call Us 555</a>
</li>
<li><a th:href="#{/X}" href="#">X</a>
</li>
<li><a th:href="#{/Y}" href="#">Y</a>
</li>
<li><a th:href="#{/Z}" href="#">Z</a>
</li>
<li><a th:href="#{/T}" href="#">C</a>
</li>
<li class="active"><a th:href="#" href="#">Blog</a>
</li>
<!--li>Help</li-->
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
</div>
</div>

bootstrap navigation not working

This is my code for navbar it works with desktop but when i go with responsive the menu links does't work . i click on menu and nothing happen please help.
<header class="header">
<div class="header-nav">
<nav role="navigation" class="navbar navbar-default navbar-fixed-top navbar-slide show-menu" style="background-color:#7c3a1c;">
<div class="container">
<div class="navbar-header">
<button aria-controls="navbar" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<a id="header-logo" href="index.php" class="navbar-brand"><img class="margin-top" src="images/logo.jpg" alt=""></a> </div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" role="menu" style="height: 1px;">
<ul class="nav navbar-nav style2 navbar-right">
<li>Home</li>
<li>About Us</li>
<li>Gallery</li>
<li>Contact</li>
<li style="background-color: #cc1b47;">805-305-2630</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
`
Check this snippet..
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<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>
<header class="header">
<div class="header-nav">
<nav role="navigation" class="navbar navbar-default navbar-fixed-top navbar-slide show-menu" style="background-color:#7c3a1c;">
<div class="container">
<div class="navbar-header">
<button aria-controls="navbar" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<a id="header-logo" href="index.php" class="navbar-brand">
<img class="margin-top" src="images/logo.jpg" alt="">
</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" role="menu" style="height: 1px;">
<ul class="nav navbar-nav style2 navbar-right">
<li>Home
</li>
<li>About Us
</li>
<li>Gallery
</li>
<li>Contact
</li>
<li style="background-color: #cc1b47;">805-305-2630
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>

Resources