I have the following page menu
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation" >
<div class="container">
<div class="row">
<div class="col-xs-11 col-xs-offset-1" >
<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>
<div class="navbar-brand">
My logo
</div>
</div>
<div class="navbar-collapse collapse">
<div class="navbar-right">
<ul class="nav navbar-nav">
<li><div class="some_class" style="margin: auto;"></div></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
also I have the following bootstrap carousel:
<div id="carusel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox" >
<div class="active item" id="item1">
<img class="new" src="../image1.png" style="min-height:496px;max-height: 896px;width: 100%" alt="...">
<div class="carousel-content">
<div class="row">
<div class="col-xs-11 col-xs-offset-1" >
<div class="col-md-8 center-block" >
Content1
</div>
<div class="col-md-8 center-block" >
Content2
</div>
</div>
</div>
Menu consists of left part and right part.
There is a content placed over my carousel.
The content consists of left column and right column.
How can the left column be placed just below the left part of menu(the same X coordinate), and the right column be placed just below right part of menu. (The same Y coordinate).
Telling in another words:
How can I place "Content 1" just below the "My Logo" of menu. I mean place them in a way, that they both will have the same x coordinate, the same left margin.
So I want to align content of my carousel according to bootstrap menu.
Related
I am using Bootstrap 4 in my project and I seem to be having a problem keeping a div with the class "sticky-top" just under a fixed navbar. I've tried using javascript to replace the css on scroll, but that doesnt seem to work. I know there is a way to set an id to the navbar and tell it not to scroll past that point, but I cant seem to Google well enough to find the solution. Any help is greatly appreciated.
Below is the code I am using.
<header class="header_area">
<nav class="navbar navbar-expand-lg menu_one menu_four">
<div class="container">
<a class="navbar-brand sticky_logo" href="#"><img src="images/upayify-logo-white.png" srcset="images/logo2x-2.png 2x" alt="logo"><img src="images/upayify-logo.png" srcset="images/logo2x.png 2x" alt=""></a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="menu_toggle">
<span class="hamburger">
<span></span>
<span></span>
<span></span>
</span>
<span class="hamburger-cross">
<span></span>
<span></span>
</span>
</span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav menu w_menu ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.php">
<i class="fa fa-home"></i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
How It Works
</a>
</li>
</ul>
</div>
<a class="btn btn-outline-light ml-3 hidden-sm hidden-xs" href="#"><i class="fa fa-lock"></i> Login</a>
<a class="btn btn-outline-light ml-3 hidden-sm hidden-xs" href="#"><i class="fa fa-user-plus"></i> Sign Up</a>
</div>
</nav>
<div class="row row-eq-height featured_item">
<div class="col-md-5 send-card order-md-last">
<div id="get-started" class="card sticky-top">
<div class="card-body">
<form>
<div class="row">
<div class="col-12 form-group">
<label for="exampleInputEmail1">I'm sending money from...</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text"><span class="flag-icon flag-icon-us"></span></div>
</div>
<select class="form-control">
</select>
</div>
</div>
<div class="col-12 form-group mt-2 mb-0">
<label>I'm sending to...</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text"><span class="flag-icon flag-icon-in"></span></div>
</div>
<select class="form-control">
</select>
</div>
</div>
<div class="col-12">
<hr>
</div>
<div class="col-12 mb-3 text-center conversion">
<span class="flag-icon flag-icon-us mr-2"></span>1 <span class="mr-2 ml-2">=</span> <span class="flag-icon flag-icon-in mr-2"></span>69.64
</div>
<div class="col-12 mt-2 index-form-btn">
<i class="fa fa-rocket"></i> Get Started Now!
</div>
<div class="col-12 text-center">
<p class="small">View Terms & Conditions for more details and fees</p>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-7 d-flex order-md-first">
<div class="row">
</div>
</div>
</div>
.send-card{
top: -225px;
z-index: 4;
margin-bottom: -200px;}
The div you want under the navbar can get styled with top: ##px; (where ## is the pixel height of the navbar you want it to go under). And then also add either position: sticky; or position: fixed; depending whether you want the sticky behavior or the fixed behavior.
Here's a jsfiddle with the described sticky behaviour.
I want to have the navigation bar I made convert to a dropdown-menu when viewed on a smaller screen (like phones and tablets). The problem is, I didn't use the conventional bootstrap nav bar system, and just made my own. I know that the usual bootstrap solution involves using the nav classes, but I'm not really sure how I'd integrate those into my own code since I didn't use them to begin with. For tablets, I was hoping to have the main menu buttons hide into a dropdown menu with a toggle button, while keeping the logo there. Here is my code:
<header class="main-header" id="Navigation">
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<img class="HeaderLogo img-responsive" src="http://res.cloudinary.com/duocsoiqy/image/upload/v1499450095/Enpowered_Logo_k69cqw.png">
</div>
<div class="col-md-6 text-center">
<div class="row text-center">
<div class="col-md-2 offset-md-1">
<p class="NavBarButtons"> WHY US </p>
</div>
<div class="col-md-2">
<p class="NavBarButtons"> FIX YOUR BILL </p>
</div>
<div class="col-md-2">
<p class="NavBarButtons"> HOW IT WORKS </p>
</div>
<div class="col-md-2">
<p class="NavBarButtons"> LEARN WITH US </p>
</div>
<div class="col-md-2">
<p class="NavBarButtons"> COMMERCIAL </p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="row">
<div class="col-md-3 offset-md-4">
<p class="NavBarButtons"> LOG IN </p>
</div>
<div class="col-md-4 md-offset-3">
<button class="SignUp"><b> UNLOCK YOUR POWER </b></button>
</div>
</div>
</div>
</div>
</div>
</header>
Since I used the grid system, everything collapses pretty well until a certain point, then the entire header completely messes up and stacks, which is why I wanted to try having the menu buttons go into a dropdown menu when that breakpoint is reached. Any help at all is much appreciated. Thanks!
You lose a lot of baked-in functionality when you try to do this outside a .navbar but it's manageable. The .navbar-collapse component itself isn't directly tied to the use of the larger component; you just need to include the <button> and wrapper element for the collapse:
<header class="main-header" id="Navigation">
<div class="container-fluid">
<div class="row">
<div class="col-xs-3">
<img class="HeaderLogo img-responsive" src="http://res.cloudinary.com/duocsoiqy/image/upload/v1499450095/Enpowered_Logo_k69cqw.png">
</div>
<div class="col-xs-9 text-right">
<div class="row">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-collapse" 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>
</div>
<div class="collapse navbar-collapse text-center" id="menu-collapse">
<div class="col-md-2"><p class="NavBarButtons">WHY US</p></div>
<div class="col-md-2"><p class="NavBarButtons">FIX YOUR BILL</p></div>
<div class="col-md-2"><p class="NavBarButtons">HOW IT WORKS</p></div>
<div class="col-md-2"><p class="NavBarButtons">LEARN WITH US</p></div>
<div class="col-md-2"><p class="NavBarButtons">COMMERCIAL</p></div>
<div class="col-md-1"><p class="NavBarButtons">LOG IN</p></div>
<div class="col-md-1"><button class="SignUp"><b>UNLOCK YOUR POWER</b></button></div>
</div>
</div>
</div>
</div>
</div>
</header>
...
Where you run into problems (and why I would recommend using the whole .navbar structure, is that you need to style the aforementioned button and its various states. You'll also need to address spacing concerns (the dropdown pushes elements down in this fashion).
It's pretty nasty, but.. You could do it with some adjustments to your code so that you'll end up with this:
<nav class="main-header navbar navbar-default" id="Navigation">
<div class="container-fluid">
<div class="col-md-3 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="#">
<img class="HeaderLogo img-responsive" src="http://res.cloudinary.com/duocsoiqy/image/upload/v1499450095/Enpowered_Logo_k69cqw.png" style="width: auto;">
</a>
</div>
<div class="col-md-6 text-center collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="text-center nav navbar-nav">
<li class="col-md-2 offset-md-1">
<p class="NavBarButtons"> WHY US </p>
</li>
<li class="col-md-2">
<p class="NavBarButtons"> FIX YOUR BILL </p>
</li>
<li class="col-md-2">
<p class="NavBarButtons"> HOW IT WORKS </p>
</li>
<li class="col-md-2">
<p class="NavBarButtons"> LEARN WITH US </p>
</li>
<li class="col-md-2">
<p class="NavBarButtons"> COMMERCIAL </p>
</li>
</ul>
</div>
<div class="col-md-3">
<div class="row">
<div class="col-md-3 offset-md-4">
<p class="NavBarButtons"> LOG IN </p>
</div>
<div class="col-md-4 md-offset-3">
<button class="SignUp"><b> UNLOCK YOUR POWER </b></button>
</div>
</div>
</div>
</div>
</nav>
Here's what I did:
give the col-md-3 class navbar-header
In there add
<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>
Add <a class="navbar-brand" href="#"> around your img
the col-md-6 column, add classes collapse navbar-collapse and
id="bs-example-navbar-collapse-1"
The div in that one add classes nav navbar-nav
Make the header a nav element
Give the nav classes navbar navbar-default
Remove the row
The div in the col-md-6 column, remove the row and make it an ul
Turn the divs in there into lis
Basically what you have done now is take the steps necessary to write a bootstrap nav. Take a good look at the example at http://getbootstrap.com/components/#navbar
You'll see that it actually doesn't use the grid system.
Keep in mind you need to include the bootstrap javascript to be able to use toggle functionality.
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
Also also, don't put p elements in your navigation. Paragraphs don't make any sense there.
When i click on a element(MMA)in my left navigation bar i want it show up on the page and when i click on a other element(boxing) in my navigation i want that to be shown instead, like tabs.
I have tried but cannot get it to work, heres my code:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Startsida</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="jquery.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<!-- header -->
<div class="jumbotron">
<h1>Top five facts about different martial arts</h1>
</div>
<!-- Top navigation -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
</div>
<ul class="nav navbar-nav">
<li >Start</li>
<li class="active">Martial arts</li>
</ul>
</div>
</nav>
<!-- side navigation -->
<div class="row" id="row">
<div class="col-sm-3" "col-lg-2" id="menu" >
<div class="sidebar-nav" "list-group">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-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>
<h1 class="head">Martial arts:</h1>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<h3 class="side">Martial arts:</h3>
<ul class="nav navbar-nav" id="ul">
MMA
Boxing
Muay thai
Kickboxing
Takwando
Karate
Braziliansk jijutsu
Wrestling
</ul>
</div>
</div>
</div>
</div>
<!-- Main content -->
<div class=" col-sm-9 menu-tab">
<div class="menu-tab-content ">
<h1>Top 5 fact about MMA</h1>
</div>
<div class="menu-tab-content active">
<h1>Top 5 fact about Boxing</h1>
</div>
</div>
</body>
</html>
jquery:
$(document).ready(function() {
$("div#menu>div.sidebar-nav>a").click(function(e) {
e.preventDefault();
$(this).siblings('a.active').removeClass("active");
$(this).addClass("active");
var index = $(this).index();
$("div.menu-tab>div.menu-tab-content").removeClass("active");
$("div.menu-tab>div.menu-tab-content").eq(index).addClass("active");
});
});
Your selector is wrong. div#menu>div.sidebar-nav>a looks for an a that's an immediate child of div.sidebar-nav. But in your HTML, the a is nested several levels below that, so it should be div#menu>div.sidebar-nav a
$(document).ready(function() {
$("div#menu>div.sidebar-nav a").click(function(e) {
e.preventDefault();
$(this).siblings('a.active').removeClass("active");
$(this).addClass("active");
var index = $(this).index();
$("div.menu-tab>div.menu-tab-content").removeClass("active");
$("div.menu-tab>div.menu-tab-content").eq(index).addClass("active");
});
});
.active {
background-color: yellow;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
v
<!-- header -->
<div class="jumbotron">
<h1>Top five facts about different martial arts</h1>
</div>
<!-- Top navigation -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
</div>
<ul class="nav navbar-nav">
<li>Start</li>
<li class="active">Martial arts</li>
</ul>
</div>
</nav>
<!-- side navigation -->
<div class="row" id="row">
<div class="col-sm-3" "col-lg-2" id="menu">
<div class="sidebar-nav" "list-group">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-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>
<h1 class="head">Martial arts:</h1>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<h3 class="side">Martial arts:</h3>
<ul class="nav navbar-nav" id="ul">
MMA
Boxing
Muay thai
Kickboxing
Takwando
Karate
Braziliansk jijutsu
Wrestling
</ul>
</div>
</div>
</div>
</div>
<!-- Main content -->
<div class=" col-sm-9 menu-tab">
<div class="menu-tab-content ">
<h1>Top 5 fact about MMA</h1>
</div>
<div class="menu-tab-content active">
<h1>Top 5 fact about Boxing</h1>
</div>
</div>
I have this template of code here and I want to make the panel in the center column full height of the visible page. Keyword 'visible' page. And then I want to place the button at the bottom of that panel, while the rest of the panels elements are at the top.
I tried setting the div to 'height: 100vh' but it makes the div higher then the visible page. I'm not sure why, maybe it has something to do with the navbar at the top?
The desired effect is that I will always see the button at the bottom of the page, regardless of the page size.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
/* Set black background color, white text and some padding */
footer {
background-color: #555;
color: white;
padding: 15px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>Messages
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group input-group">
<input type="text" class="form-control" placeholder="Search..">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-user"></span> My Account
</li>
</ul>
</div>
</div>
</nav>
<div class="container text-center">
<div class="row">
<div class="col-sm-3 well">
<div class="well">
<p>My Profile
</p>
<img src="bird.jpg" class="img-circle" height="65" width="65" alt="Avatar">
</div>
<div class="well">
<p>Interests
</p>
<p>
<span class="label label-default">News</span>
<span class="label label-primary">W3Schools</span>
<span class="label label-success">Labels</span>
<span class="label label-info">Football</span>
<span class="label label-warning">Gaming</span>
<span class="label label-danger">Friends</span>
</p>
</div>
<div class="alert alert-success fade in">
×
<p><strong>Ey!</strong>
</p>
People are looking at your profile. Find out who.
</div>
<p>Link
</p>
<p>Link
</p>
<p>Link
</p>
</div>
<div class="col-sm-7">
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default text-left" style="height:100vh">
<div class="panel-body">
<p contenteditable="true">Status: Feeling Blue</p>
<button type="button" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-thumbs-up"></span> Like
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-2 well">
<div class="thumbnail">
<p>Upcoming Events:</p>
<img src="paris.jpg" alt="Paris" width="400" height="300">
<p><strong>Paris</strong>
</p>
<p>Fri. 27 November 2015</p>
<button class="btn btn-primary">Info</button>
</div>
<div class="well">
<p>ADS</p>
</div>
<div class="well">
<p>ADS</p>
</div>
</div>
</div>
</div>
</body>
</html>
Yeah as you already said, the navbar is the "problem" here.
If you try to subtract the navbar height from the desired height of the panel it should work:
element.style {
height: calc(100vh - 100px);
}
I have to place my accordion in a <div style="display:none;"> and then div which also have an id tag ( <div id="outerid"> ) because I am popping up my accordion by tooltip.js, where <div id="outerid"> defines the target for tooltip.js.
My tabs
( <a class="accordion-header" data-toggle="collapse" data-parent="#accordion" onmouseover="this.click();" href="#tab2">HOVER ME FOR TAB 2</a> ) works fine out of <div style="display:none;">, even within <div id="outerid">. As soon as i place <div id="outerid"> with in <div style="display:none;"> the following happening.
My accordion shows up beautifully when you hover over outerid's target,
but the tabs in the accordion do not work.
(NOTE: If I have an external target e.g href="http://helloworld.com in that case,the tabs work, but with anchor target e.g href="#tab2", they don't.
Anyone has any idea why is that?
<div style="display:none;">
<div id="outerid">
<div id="accordion">
<div class="accordion-group panel">
<a class="accordion-header" data-toggle="collapse" data-parent="#accordion" onmouseover="this.click();" href="#tab1">
HOVER FOR TAB 1
</a>
<div id="tab1" class="collapse in">
<div class="accordion-body">
<p>HELLO WORLD 1st</p>
</div>
</div>
</div>
<div class="accordion-group panel">
<a class="accordion-header" data-toggle="collapse" data-parent="#accordion" onmouseover="this.click();" href="#tab2">
HOVER ME FOR TAB 2
</a>
<div id="tab2" class="collapse">
<div class="accordion-body">
<p>HELLO WORLD 2nd </p>
</div>
</div>
</div>
<div class="accordion-group panel">
<a class="accordion-header" data-toggle="collapse" data-parent="#accordion" onmouseover="this.click();" href="#tab3">
HOVER ME FOR TAB3
</a>
<div id="tab3" class="collapse">
<div class="accordion-body">
<p>HELLO WORLD 3rd</p>
</div>
</div>
</div>
</div>
</div>
<!---End Accordion---->
</div>
<!--- Outerid end---->
</div><!---End Non Display--->