I have a header.top-bar element at the top (with div.top-bar-left and div.top-bar-right elements inside), then everything after that is inside a div.row element. What's the simplest way to make the items in the top bar line up with the edges of the row? I tried putting the header itself inside a row but that just completely messed up the placement of everything.
<div class="container">
// place your html code here
</div>
Check this!
<!-- Navigation Start -->
<nav class="navbar navbar-default navbar-fixed-top">
<!-- Container Start -->
<div class="container">
<!-- Note that the .navbar-collapse and .collapse classes have been removed from the #navbar -->
<div id="navbar">
<form class="navbar-form navbar-right">
<div class="form-group">
<input class="form-control" placeholder="Search" type="text">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-left">
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div><!--/.nav-collapse -->
</div>
<!-- Container End -->
</nav>
<!-- Navigation End-->
Put the row and top-bar in a div and use flex-property
<div class="container">
<div class="top-bar">
</div>
<div class="row">
</div>
</div>
.container{
display:flex;
flex-direction:column;
}
Related
I have made a layout for showing shopping products of an online store using Bootstrap 3 and it looks like this:
As you can see there is a gap between Films container and the separator line and I need to remove this gap. So the Films container would stick to the right side.
And here is the code for that:
<section>
<div class="flex-kit-game-shop-main">
<!--Books -->
<div id="training-kit" style="background-color: #339966 !important;" class="">
<div class="card bg-transparent border-0 m-r-card">
<div class="">
<div class="title-tab-shop">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
...
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane container active" id="latest-products">
...
</div>
<div class="tab-pane container fade" id="most-bied">
...
</div>
<div class="tab-pane container fade" id="popular-products">
...
</div>
</div>
</div>
</div>
</div>
</div>
<!--Films -->
<div id="training-kit" style="background-color: #0066ff !important;" class="" >
<div class="card bg-transparent border-0 m-r-card" >
<div class="">
<div class="title-tab-shop">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
...
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane container active" id="latest-products">
...
</div>
<div class="tab-pane container fade" id="best-selling-products">
...
</div>
<div class="tab-pane container fade" id="popular-products">
...
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
I can stick the Films container elements to the right by saying margin-right:-10px; but will affect the added products and make them bigger than their normal size.
So how can I properly make this Films container stick to the right in Bootstrap?
CSS File:
.flex-kit-game-shop-main {
display: flex;
flex-direction: row;
}
#media screen and (max-width: 1200px) {
.flex-kit-game-shop-main {
flex-direction: column;
}
}
Go to the your css file. Find ".flex-kit-game-shop-main" selector. Probably, display value of your top parent div element is "flex"(display:flex;). If it is, I would recommend that you research about conseption of "flexbox" in css. And then, you will be aware of what you should do.
A better option over here is to use the float property in CSS
select the box you wanna align to a side and then add float: left; also remember to clear the float if later you don't wanna use it further, for that add clear: both;
I have a navbar inside the tab-content that has pull-right bootstrap class ,we are rendering element js-property-panel based on user selection so when this element loads it is overlapping on navbar. So both are iniside cols 10. How can i set position of navbar using pull-right when js-property-panel loads it should moved to right ?
main.html
<div class="col-md-10" ng-class="{'col-md-12':isCollapsed,'col-md-10':!isCollapsed,'tabContentCollapse-padding':isCollapsed}">
<div class="tab-content">
<nav class="navbar navbar-default pull-right">
<div class="container-fluid">
//navbar stuff here
</div>
<!-- /.container-fluid -->
</nav>
<div role="tabpanel" class="active" id="tab">
<div>
<div id="home" class="fade in active">
<div class="modeler">
<div id="canvas" style="height:80vh;"></div>
<div id="js-properties-panel"></div>
</div>
</div>
</div>
</div>
</div>
</div>
Are you looking for a pure css solution? As this can be achieved with
javascript pretty easily.
Also here is a link of css tricks that might be useful to
introduce conditional styling using css.
Update:
Here is how far I could get to- please follow the fiddle here
<div class="col-md-10" ng-class="{'col-md-12':isCollapsed,'col-md-10':!isCollapsed,'tabContentCollapse-padding':isCollapsed}">
<div class="tab-content row">
<div class="col-md-6 col-md-push-6 navwrapper">
<nav class="navbar navbar-default">
<div class="container-fluid">
//navbar stuff here
</div>
<!-- /.container-fluid -->
</nav>
</div>
<div role="tabpanel" class="col-md-6 col-md-pull-6" id="tab">
<div>
<div id="home" class="fade in active">
<div class="modeler">
<div id="js-properties-panel" class="panel-contents">
sample content
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Observations:
What you are trying to achieve is controlling the style of an element
higher up the DOM tree using a state an element lower down the tree.
Neither those elements are direct parent-child nor are those siblings
so you could control using common class and may be adding a
:not(:empty) selector.
You could still use the column-ordering to a certain extend though
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>
EDIT: My source is at https://bitbucket.org/kunaladhia01/studentaccounts/src
css file is under static/css/main.css
html is at template/student/index.html
So far, my code looks like this
<div class="content-wrap">
<header class="hero-area" id="home">
<div class="container">
<div>
<div class="nav navbar-inverse sticky-navigation navbar-fixed-top" data-spy="affix" data-offset-top="200">
<div class="container">
<nav>
<div class="nav-wrapper">
<form onsubmit="return false;">
<div class="input-field">
<input id="search" type="search" required placeholder="Search">
<label for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
<button class="menu-icon" id="open-button">
<i class="mdi-navigation-menu"></i>
</button>
</div>
</nav>
</div>
</div>
</div>
There are two problems I have so far, which should be an easy fix, but its been 3 hours and I still have no progress
zippyshare com/v/h2ThM1Xi/file.html
zippyshare com/v/0h9KvaQI/file.html
(add the dot in)
I need to make the menu icon go into the same row as the search bar (class="row" wont work) and there's this blue bar behind the search bar, which i have no idea where it came from
So basically I have a sidebar which I wan't to be fixed in my page and have only the other column in my row be scrollable.
I tried changing the position css attribute of the element, but then the original content would be squished into the first column.
A demo of what I have is available here: JSFiddle
Here is my HTML:
<div class="container">
<div class="row">
<div class="col-4" role="sidebar">
<div class="diamond"><span>RS</span></div>
<br />
<div class="brief">
Text here...
</div>
<form class="search">
<input type="text" placeholder="Search...">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
<ul class="sidebar-menu">
<li class="github">Github</li>
<li class="twitter">Twitter</li>
<li class="stackoverflow">StackOverflow</li>
<li class="linkedin">LinkedIn</li>
</ul>
</div>
<div class="col-8" role="content">
<h1 class="title">Title</h1><div class="horizontal-rule"></div>
<nav class="subnav">
<ul>
<li>Link</li> /
<li>Link</li> /
<li>Link</li> /
<li>Link</li>
</ul>
</nav>
</div>
</div>
</div>
I don't know which element you want to have fixed, but you could use this method:
<div id="id">
Content of the div
</div>
And the CSS:
#id {
position: fixed;
left: 30px; // or whatever you want
top: 100px; // or whatever you want
}
I hope this helped for you!