I am trying to share the navbar across all devices, but I want it to format differently on small screens than on large. I am new to Bootstrap so this might be obvious, but I am having trouble getting the menu right with a single set of code and not trying to do it with different rows and col-* settings.
Bootply Sample
I want two things actually. I would like the win and loss to be on the same line (which is close without the navbar-right) except they are not even in vertical position.
EDIT: I am able to correct this when removing navbar-right etc..., but do not get the navbar-right when the menu is condensed.
Secondly, I wanted the navbar-right, so when on a small display, all the badges align on the right hand side of the menu.
Is there a way to keep the menu smaller as well, so on a tablet it is not the whole width of the screen while on a phone it might be?
When the navbar normally draws, I want the badges beside the labels to keep the menu items smaller/closer together. Only on the pull down menu do I want them to go to the right.
Do I need to create two copies of the navigation to achieve this?
First, the badges seem aligned to me if you remove those navbar-right classes. If you are using that class just to float them right, you should be using pull-right but in this case there's no need.
Second, if you wrap your badges inside another span, then you can use media queries to float the container right on mobile devices.
<span class="badges">
<span class="badge alert-success">Win: 3</span>
<span class="badge alert-danger">Loss: 1</span>
</span>
/* Note that you can use Bootstrap's '#screen-sm-min' variable if using LESS.*/
#media (max-width: 767px) {
.badges {
float: right;
}
}
If you want your navbar to be full width on mobile but not any other device, you could try something like this:
#media (min-width: 768px) {
.navbar {
width: 80%;
margin: 0 auto;
}
}
Demo
Edit
For the changing width you can use Bootstrap's col-*-* classes like this:
<div class="wrap">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
...
</div>
</div>
</div>
That means for mobile it'll be full width, but anything from portrait tablet upwards will take up 10 of the 12 grid.
Demo
Related
This is currently what I have in my HTML code:
I have 3 of the "col-md-4" div's in the row, along with container--wrap in each of those, so that it fills the webpage with 3 equally sized containers. (div row is inside another div with class = container-fluid). When I adjust the window, the containers will stack on top of each other, but only after I make it much smaller (like 2/3). Also, on mobile, it does not stack at all and the containers are all really small. How can I make it so that these containers are able to stack (flex?) easier, and have them stack on mobile automatically? I also have a navbar that looks fine on mobile, but it remains small on mobile, just collapsed. How can I make it larger on mobile? Here is the navbar code:
cov19.cc (website) is an example of what I would like my site to do. The navbar is enlarged on mobile, and the container are stacked on top of each other rather than side by side. Thanks
For the First Problem, use display:flex for the row.I have also used media query so that when the user is on mobile screen or the size of screen is less than 991px, the containers will be on the top of each other.Please run it full screen and shrink the browser window to see the effect.
#media all and (max-width:991px){
.row{
flex-direction:column;
}
.container--wrap{
width:98vw!important;
}
}
.row{
display:flex;
}
.container--wrap{
width:33vw;
text-align:center;
border:1px solid;
transition:all 0.3s;
}
<div class="row">
<div class="col-md-4">
<div class="container--wrap">
This is one
</div>
</div>
<div class="col-md-4">
<div class="container--wrap">
This is two
</div>
</div>
<div class="col-md-4">
<div class="container--wrap">
This is three
</div>
</div>
</div>
I'm using bootstrap 4 and I've created a partially collapsible sidebar which is actually working perfectly for me.
My problem is, I'm trying to add a top header/nav bar that holds the toggle to collapse the sidebar and on the right of the header navbar I want my user icon for logging in and out, etc.
I created a header called #userHeader, which expands the width of the page and houses the toggle (again, this part works) but I used 100vw for the header and that's too much width because it extends off the page and you can't see the icon.
My question is this: How can I create a responsive header here that always extends the remaining width of the page from the space the sidebar takes up already?
In other words, if it's not collapsed and the sidebar takes up 15% of the page and then once collapsed it takes up 5%, the header would compensate in the way it does now but with the right side always stuck to the right side of the page.
The HTML block in question:
#userHeader {
width: 100vw;
height: 40px;
background-color: red;
position: fixed;
}
#userHeader i {
color: #FFFFFF;
float: right;
}
<div id="secondHeader">
<!--Note: I have no styling for this id yet-->
<div id="userHeader">
<button type="button" id="sidebarCollapse" class=".btn">
<span></span>
<span></span>
<span></span>
</button>
<i id="user" class="far fa-user-circle fa-2x"></i>
</div>
</div>
Here is a working codepen, thought I've only kept the most necessary html. All CSS and JS is what I'm using in my page currently:
https://codepen.io/anon/pen/gKPJgq
For this,since you are using bootstrap, grid system documentation may help https://getbootstrap.com/docs/4.0/layout/grid/
The width you set is fixed. You may want to try setting max-width or put a '%' as a unit since percentage units are relative to the parent element, or in your case (as i assume) body.
On the other hand, putting sidebar and #userHeader into separate columns may help solve your problem. Since Bootstraps grid works in 12 column system, giving your sidebar a, (lets say) col-3 class, #userHeader should fill out the rest.
Also, you may want to check out flexbox for overall easier layout positioning and responsiveness.
My Goal is to view bootstrap page on mid to large screen as col-screen-8 (screen-lg-md,sm,xs) as image to left. col-screen-4 as form to right in single row and on next row col-screen-12 as content at center eg. Banking.For mobile view or small screens I want to view Image at top -> Banking at middle -> Form as bottom in mobile view vertically.I am able to achive the mobile view as expected and see result by shrinking window. push pull demo.When it comes to mid or big screen it is not working as expected.When i played using push-pull bootstrap classes they are just moving left to right.
What is happening:
When i increase screen size Image column is getting bigger and Form and Banking remain at bottom
What is expected:
When i increase screen size Image should move to left side with size col-screen-8 as Image, Form col-screen-4 at right and content Banking col-screen-12 as Banking to the next row at bottom. Mobile view must not affected.
Thanks.
As far as I make of it, .col-XX-pull-N and .col-XX-push-N classes only
add left and right negative margins, which means you can only use them to offset columns left and right on the same .row. You can't push a column on the next row. You're only pushing it outside the layout. It won't magically wrap.
You should add a class to your special row and use flexbox's order property to re-order columns at desired widths:
.reorder-md {
display: flex;
flex-wrap: wrap;
}
#media (min-width: 992px) {
.reorder-md-last {
order: 2;
}
}
<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>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row reorder-md">
<div class="col-xs-12 col-md-8">
<div class="alert alert-danger">Image</div>
</div>
<div class="col-xs-12 reorder-md-last">
<div class="alert alert-info text-center">Banking</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="alert alert-success">Form</div>
</div>
</div>
</div>
Please note .reorder-md and .reorder-md-last are custom classes I added. So don't expect .reorder-lg to work in Bootstrap. You need to add the CSS for reordering yourself, as well as match Bootstrap's responsive breakpoints.
I'm trying to use a label to tell when something is InProcess but the label moves another span in the panel even though it has plenty of room to move around.
How it is right now:
http://imgur.com/Q9VgJMs
How it should be:
http://imgur.com/5yXGGCs
Here's the code for it.
<div class="panel-body log-work-lot-container">
<ul class="list-unstyled">
<li class="log-work-item-lot" data-ng-click="vm.SetActiveBatch(batch);" data-ng-class="{'selected' : batch.IsActive}"
data-ng-repeat="batch in vm.Batches" data-ng-show="!batch.IsScrapped && !batch.IsCompleted">
<div style="text-align:center;">
<span class="pull-left">0000{{batch.Name}}</span>
<span class="pull-right label label-info" data-ng-show="batch.InProcess"> In Process </span>
<span style="">QTY {{batch.Quantity}}</span>
</div>
</li>
</ul>
</div>
This should do it:
.list-unstyled .pull-left { margin-right: -100%; }
.list-unstyled .pull-right { margin-left: -100%; }
Please note this is a hack-ish way of doing it and makes your left/right elements overlap the centered content if they don't fit on one row. In order not to overlap when on very small screens, I updated your fiddle based on your markup. It's not perfect, but it's better than overlapping them :).
Use bootstrap grid structure to organize data in column formats.
An example - http://www.bootply.com/5FLFCdIny1
(Above example uses only col-xs-*, which will display data in column format for all kind of devices. You can customize display based on screen size)
I am modifying my website that uses a style sheet with a sixteen column grid layout. I am trying to make a custom page where the left side is big, and the right side is more or less a narrower sidebar:
http://tecinfrared.com/the-backyard-development-ii/
screen shot:
Here is my simple html so far:
<div class="sixteen columns"><!-- Sixteen Columns Layout Start -->
<div class="twelve columns" style="background-color:#ff9900;">
left
</div>
<div class="four columns" style="background-color:#99ff00;">
right
</div>
</div><!-- Sixteen Columns Layout End -->
What I expect to happen is that the "right" div (lime colored) lines up to the right of the "left" or orange div. I have made a page that uses floats, but the problem is it's not responsive, so on mobile devices the sidebar div has to push below the left column div.
I thought this css & html should work similar to Zurb's Foundation responsive framework, where the divs will drop vertically for smaller screens, but line up horizontally for wider screens.
add this CSS
.columns {
display: inline-block;
}
in order to allow side-by-side display of these elements.
And if you don't like the margins between the elements, also add margin: 0 !important; to that rule.