I am building a webpage with HTML & CSS, using the bootstrap framework. It is based on the grid layout system. I would like to have my navbar and first row of my grid in a group and the second row in a group, where each group fills 100% of the screen height. I can't see how a div definition would work as it spans the middle of two div classes. I have tried this, using the calc function, but it doesn't seem to be working.
Here is a JSFiddle. (NB: try expanding the output window to show the problem properly)
<div class="PageView">
<nav class="navbar navbar-default">
<div class="container-fluid" id="logoStripe">
<!-- Brand and toggle get grouped for better mobile display -->
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav links">
<li>About<span class="sr-only">(current)</span>
</li>
<li>Pre-Order
</li>
<img src="Images/Logo.png" alt="Logo" style="width:auto; height:75px; padding-top:5px; padding-bottom:5px;">
<li>News
</li>
<li>Contact Us
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="container-fluid">
<div class="PageView">
<div class="row">
<div class="col-md-12">.col-md-1</div>
</div>
<div class="row">
<div class="col-md-6">Button 1 (align Right)</div>
<div class="col-md-6">Button 2 (align Left)</div>
</div>
</div>
</div>
and the CSS:
.links {
width: 100%;
display: flex;
justify-content: space-between;
font-size: 28px;
color: #FFFFFF;
}
#logoStripe {
background-color: #54534a;
}
.PageView {
height: calc(100% - 75px);
}
Can anyone see what I have done wrong? Any ideas would be much appreciated.
Percentage heights calculate from their parents height so you have to start from the most parent element and cascade it down to the element you want with the modified height. You also have two divs with .PageView that cannot use the same CSS to work properly; I'm not sure if this was done on purpose.
Also, if you are using calc, you will need to adjust the pixel amount for each of Bootstrap's breakpoints.
html, body, .PageView {
height:100%;
}
.links {
width: 100%;
display: flex;
justify-content: space-between;
font-size: 28px;
color: #FFFFFF;
}
#logoStripe {
background-color: #54534a;
}
.adjustedHeight {
height: calc(100% - 77px);
background-color:red; /* For emphasis */
}
.PageView .navbar {
margin:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="PageView">
<nav class="navbar navbar-default">
<div class="container-fluid" id="logoStripe">
<!-- Brand and toggle get grouped for better mobile display -->
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav links">
<li>About<span class="sr-only">(current)</span>
</li>
<li>Pre-Order
</li>
<img src="Images/Logo.png" alt="Logo" style="width:auto; height:75px; padding-top:5px; padding-bottom:5px;">
<li>News
</li>
<li>Contact Us
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="container-fluid adjustedHeight">
<div class="PageView2">
<div class="row">
<div class="col-md-12">.col-md-1</div>
</div>
<div class="row">
<div class="col-md-6">Button 1 (align Right)</div>
<div class="col-md-6">Button 2 (align Left)</div>
</div>
</div>
</div>
Related
i am trying to use the flex box technique in https://css-tricks.com/couple-takes-sticky-footer/ to responsively push down the footer in my page http://apple.mdsc1.com/test/
i used:-
<style>
#wrapper {flex: 1 0 auto;}
body, html {height: 100%}
body {
display: flex;
flex-direction: column;
}
</style>
but it failed. something in the ready made layout that i am using is spoiling the flex
how i make it work?
because the parent of #wrapper is not a flex element, so you need to change the rules from body to jPanelMenu-panel and add height:100% to it
body,
html {
height: 100%;
margin: 0
}
.jPanelMenu-panel {
display: flex;
flex-direction: column;
height: 100%
}
#wrapper {
flex: 1;
}
#footer-bottom {
background: lightgreen
}
<div class="jPanelMenu-panel">
<div id="wrapper">
<!-- Top Bar
================================================== -->
<div id="top-bar">
<div class="container">
<!-- Top Bar Menu -->
<div class="sixteen columns">
<ul class="top-bar-menu" style="float: right">
<li><i class="fa fa-phone"></i>00 971 2 6130700</li>
</ul>
</div>
</div>
</div>
<div class="clearfix"></div>
<!-- Header
================================================== -->
<div class="container">
<!-- Logo -->
<div class="four columns">
<div style="margin-top: 18px; margin-bottom:15px; float: left">
<h1>
<img src="images/mdsc1logo.png" alt="mdsc1">
</h1>
</div>
</div>
</div>
<!-- Navigation
================================================== -->
<div style="background-color: #292929">
<div class="container">
<div class="sixteen columns">
<i class="fa fa-bars"></i> Menu
<nav id="navigation">
<ul class="menu js-enabled arrows" id="responsive" style="margin: 0px">
<li>Home</li>
<li>About Us</li>
<li class="dropdown">
Solutions
<ul style="display: none;">
<li>Apple</li>
<li>Microsoft</li>
<!-- <li>Online Ordering</li>-->
</ul>
</li>
<li>Contact Us</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- Slider
================================================== -->
<div class="container">
<div class="sixteen columns">
<p style="font-size: 50px; margin-top: 40px">The Home Page For MDS ONE As A Whole</p>
</div>
</div>
</div>
<div id="footer-bottom">
<!-- Container -->
<div class="container">
<div class="eight columns">© Copyright 2017 by MDSC1. All Rights Reserved.</div>
</div>
<!-- Container / End -->
</div>
</div>
I'm trying to vertically center the menu links of my header, but does not work. I'm using Bootstrap.
HTML
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 header">
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-2" style="font-size: 40px;">
<p>Capelli</p>
</div>
<div class="col-xs-3"></div>
<div class="col-xs-6">
<ul class="list-group list-inline">
<li>Vestidos</li>
<li>Meus Pedidos</li>
<li></li>
<li></li>
<li>Login</li>
<li>Cadastro</li>
<li></li>
<li></li>
<li>Carrinho</li>
</ul>
</div>
<div class="col-xs-1"></div>
</div>
</div>
</div>
</div>
CSS
body {
background-color: #CFCFCF;
}
.header {
min-height: 3.7em;
color: #FFFFFF;
background-color: #002A43;
font-family: Arial, sans-serif;
font-size: 20px;
}
.vertical {
float: none;
display: inline-block;
vertical-align: middle;
}
When a run the code, nothing happens.
I've tried many things, like use the class directly in row or in col-, but nothing work. I also trie diferent methods to align vertically, but did not work.
P.S.: Sorry for my bad english.
You want to create a nav bar menu?
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Capelli</a>
</div>
<div>
<ul class="nav navbar-nav push-right">
<li class="active">Vestidos</li>
<li> etc</li>
<li>etc</li>
<li>etc</li>
</ul>
</div>
</div>
</nav>
in css you shoud define the font-size of X pixels, because you are using relative font-size.
its 3.7em of 10px or 20px. depending the browser the value can change.
html{ font-size: 16px;}
.header{font-size: 1.25em; // 20/16 = 1.25 and you have sure the font size is relative to 16 because you have define html font size to 16px;.
I have the following HTML:
<nav class="navbar pr-navbar navbar-fixed-top" role="navigation">
<div class="navbar-header">
<div class="row">
<div class="navbar-left">
<a plat-tap='goBack()'><span class="fui-arrow-left pr-back"></span></a>
</div>
<div class="navbar-right">
<a plat-tap='goHome()'><span class="glyphicon glyphicon-home pr-home"></span></a>
</div>
<p class="pr-navbar-text">Manage/Add Users</p>
<div class="navbar-right">
<div class="pr-add-item">
<a plat-tap='addUser()'><span class="fui-plus"></span></a>
</div>
</div>
</div>
</div>
</nav>
Coupled with the following LESS:
#primaryColor: red;
#secondaryColor: blue;
#borderColor: white;
#textColor: white;
.pr-back{
color: #textColor;
}
.pr-home{
color: #textColor;
}
.pr-navbar-text{
color: #textColor;
text-align: center;
}
.pr-navbar {
background-color: #secondaryColor;
background-image: none;
background-repeat: no-repeat;
filter: none;
}
body { padding-top: 75px; }
#media screen and (max-width: 768px) {
body { padding-top: 53px; }
}
.pr-add-item {
padding-right: 75px
}
For some reason, the row element in my HTML does nothing. The plus icon is always put on a row beneath all the other buttons. How can I fix this so I have one row with a left aligned button, a center text, and two right aligned buttons?
Here, I started a fiddle for this.
JSFiddle here
<nav class="navbar pr-navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="nav navbar-nav navbar-left">
<a plat-tap='goBack()'><span class="fui-arrow-left pr-back"></span></a>
</div>
<div class="nav navbar-nav navbar-right">
<a plat-tap='goHome()'><span class="glyphicon glyphicon-home pr-home"></span></a>
</div>
<p class="nav navbar-nav pr-navbar-text">Manage/Add Users</p>
<div class="nav navbar-nav navbar-right">
<div class="pr-add-item">
<a plat-tap='addUser()'><span class="glyphicon glyphicon-plus"></span></a>
</div>
</div>
</div>
</nav>
This HTML is closer to what you want. There were some unnecessary tags included in your original HTML, and also some important tags (like nav and navbar-nav) that were excluded. I suggest you read over this section of the bootstrap components page to understand how to get NavBars to work more cooperatively.
(I changed the glyph for your plus button and back arrow button so something would show up without including flat ui).
Edit: Altered the JSFiddle so that the text could be centered in the navbar.
I'm using a modified version of the Bootply (Bootstrap 3.0) example to create a sidebar navigation. In our case we want the navigation not to scroll with the rest of the page, so we created a wrapper to keep it in place. This has the unfortunate side effect of window.scrollTo not to work, since the page size is the same as the screen size. As such, it doesn't hide the browser chrome. I was wondering if anyone had any suggestions on this (removing the browser chrome).
<div class="wrapper clearfix">
<div class="container">
<div class="row row-offcanvas row-offcanvas-left">
<!-- sidebar -->
<div class="column col-sm-3 col-lg-2 col-xs-6 sidebar-offcanvas clearfix" id="sidebar" role="navigation">
<ul>
<li>Menu item</li>
<li>Menu item</li>
</ul>
</div>
<!-- main right col -->
<div class="col-sm-9 col-lg-10 col-xs-12" id="main-mobile">
<!-- top menu -->
<div class="navbar navbar-inverse navbar-main navbar-static-top collapse-group" role="navigation" id="mobile-main-nav">
<div class="collapse in no-ani">
<div class="nav-buttons">
<button type="button" class="btn btn-success icn-only visible-xs pull-left offcanvas-toggle" data-toggle="offcanvas"><i class="icon-th"></i></button>
<div class="text-center top-buttons">
<ul>
<li>Topmenu</li>
<li>Topmenu</li>
</ul>
</div>
</div>
</div>
</div>
<!-- main content -->
<div class="row navbar-top-padding" name="top">
<div class="col-md-12 page" id="col3">
<!--scrollable content here-->
</div>
</div>
</div>
</div>
</div>
</div>
The relevant CSS is here. I've removed styling etc. The relevant element is the absolutely positioned container as this basically sets the page size to the screen size.
LESS
#main-mobile{
height:100%;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
overflow-x:hidden;
> .row{
height: 100%;
}
}
.container{
width:100%;
}
.wrapper{
height:100%;
> .container{
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
}
.row-offcanvas{
height:100%;
}
.sidebar-offcanvas{
padding:0px;
height:100%;
}
#media screen and (max-width: #screen-xs-max) {
.row-offcanvas {
position: relative;
transition: all .2s ease-out;
left:0;//necessary to make the animation work
}
.sidebar-offcanvas {
position: absolute;
top: 0;
}
}
I hope you can all help :)
I have a sidebar on my website but because I don't want it going under the fold I would like to split this ten li sidebar into two 5 li sidebars with a div inbetween them showing content using Jquery. I have coded up the website so it looks good but I need the sidebars to act as one menu instead of two so only one selection can be made at a time , one current class etc. Anyone know how to do this? My mark-up is as follows:
<div id="sidebar">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
</div>
<div id="repcontent">
</div>
<div id="sidebar">
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
You just have to remove tags that commented in the following code:
<div id="sidebar">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
<!-- </div> -->
<div id="repcontent">
</div>
<!-- <div id="sidebar"> -->
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
Edited: To get three columns layout, I will use zurb-foundation CSS framework as follows:
<body>
<div id="header" class="row">
<div class="twelve columns">
Header
</div>
</div>
<div class="row">
<div id="left-sidebar" class="three columns">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
</div>
<div id="repcontent" class="six columns">
Middle contents
</div>
<div id="right-sidebar" class="three columns">
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
</div>
</body>
take it easy.. use
-webkit-column-count: 2;
this will splits your contents into two columns..Or if you want to display the sidebars in two sides separately then use 2 separate divisions and float:left|right; property. Or you can query for this using JQuery.
<body>
<div class="container">
<div class="sidebar1">
<ul class="nav">
<li>Link one</li>
<li>Link two</li>
<li>Link three</li>
<li>Link four</li>
</ul>
<p> </p>
<!-- end .sidebar1 --></div>
<div class="content">
<!-- end .content --></div>
<div class="sidebar2">
<!-- end .sidebar2 --></div>
<!-- end .container --></div>
</body>
css
.sidebar1 {
float: left;
width: 20%;
background-color: #93A5C4;
padding-bottom: 10px;
}
.content {
padding: 10px 0;
width: 60%;
float: left;
}
.sidebar2 {
float: left;
width: 20%;
background-color: #93A5C4;
padding: 10px 0;
}
Try this code. this may clarifies your problem .