I made a website with a Bootstrap navbar, but on mobiles, I want to show my Snap.js shelf instead. How do I do that?
What you are looking for is the .hidden-xx class.
You can do the following to hide the Bootstrap navbar on a phone and show the Snap.js shelf instead:
// Snap.js
// Visible only on xs screen sizes
<div class="snap-drawers hidden-lg hidden-md hidden-sm">
...
</div>
// Bootstrap
// Hidden on xs screen sizes
<nav class="navbar hidden-xs">
...
</nav>
Related
I was reading bootstrap Collapse docs and decided to try horizontal collapse. Here is the code of a Vue component that used same code as bootstrap docs:
Vue component:
<template>
<section>
<div>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapsId" aria-expanded="false" aria-controls="collapsId">
Toggle width collapse
</button>
</div>
<div>
<div class="collapse collapse-horizontal" id="collapsId">
<div class="card card-body" style="width:50%;">
This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
</div>
</div>
</div>
</section>
</template>
But the transition to expand the .card does not work correctly. At first the .card has the whole height of the page and then suddenly it expands completely to 50% width! If I use style="width:500px;" instead of style="width:50%;", that works correctly. Could any developer please help me why it does not work with relative width? Bootstrap docs said:
Feel free to write your own custom Sass, use inline styles, or use our width utilities.
But that does not work correctly!
Is there no better way to handle this in Bootstrap 3 ?
I want to add class btn-full when its on visible-xs and class btn-xl on hidden-xs
<div class="visible-xs">
Click Me
</div>
<div class="hidden-xs">
Click Me
</div>
I've read a lot about bootstraps breakpoints and grid system now and perused many stackoverflow questions but remain bamboozled.
I have a simple bootstrap v3 container like this:
<div class="container">
<div class="row col-md vertical-align">
<div class="col-md-5">
image
</div>
<div class="col-md-7 d-flex">
text
</div>
</div>
</div>
And in a web browser this renders beautifully, but on my phone the image and text continue to occupy one row with no break and the image is thus scaled tiny and ugly and I'd like Bootstrap to do what it does best, render that image at the full phone width and the next beneath it, that is, break these two columns.
A live sample is her, at present:
http://hobart.gamessociety.info/
and I would be most grateful if anyone with experience could lend some insight into why this doesn't render as I'd like on my phone.
As I understood bootstrap it's phone first, and md says apply the 5/7 split on medium and larger screens and on smaller ones do what it does sensibly, i.e. not scale that image to tiny proportions and show both columns side by side, but break between them and show one above the other.
The class "vertical-align" adds the css style "display:flex" if you remove that you will see the items behaving as you currently desire (I think). Use chrome and inspect to add/remove css styles.
You could just add col-xs-12 to each div class.
<div class="container">
<div class="row col-md vertical-align">
<div class="col-md-5 col-xs-12">
image
</div>
<div class="col-md-7 col-xs-12 d-flex">
text
</div>
</div>
</div>
Here is an alternative to your second question
create a css class
.myClass {
float:none;
display:inline-block;
vertical-align:middle;
margin-right:-4px;
}
And add it to the inner divs
<div class="container">
<div class="row">
<div class="col-md-5 myClass">
image
</div>
<div class="col-md-7 myClass">
text
</div>
</div>
</div>
Found the answer here Twitter Bootstrap 3, vertically center content
I want to have a page with the following responsive layout:
Image 1) A responsive page layout with 3 boxes (on small/medium screen)
Image 2) A responsive page layout with 3 boxes (on wide screen)
The goal is to make this page responsive so that whenever screen is too wide, box 3 will jump next to box 2 (like image 2). For this I use grid system of Bootstrap with allocating "8" spans for Box 1 and "4" for box 2 and 3. It works the way I described. Now I want to fix the position of Box 2 and Box 3 so when I scroll the page (to see the content of Box 1) I will see Box 2 and 3 in my viewport and I don't want to make Box 1 scrollable! I want the whole page to scroll! Do you know any Bootstrap solution that will handle this situation? (I want to keep the responsive layout of the whole page)
This is the basic code that I have for the page:
<div class=row>
<div class="col-md-8 col-lg-6">Box 1</div>
<div class="col-md-4 col-lg-3">Box 2</div>
<div class="col-md-4 col-lg-3">Box 3</div>
</div>
Right now I can make Box 1 scrollable but it will put the scrollbar next to box 1, but I want it to be at the right side of the page, so the whole page scrolls but box 2 and 3 are fixed. And at the same time, on large screens they will change their position and all 3 boxes will be next to each other!
Is there any suggestions?
FIXED
If i got you right :) Here is a fiddle : https://jsfiddle.net/fL2L0qnj/2/ , just resize the result area to see effect :)
HTML :
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="box0"></div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="row">
<div class="col-xs-6 col-md-12"> <!--do this at your preference, look at example and then
arrange it for your self :)
<div class="box1"></div>
</div>
<div class="col-xs-6 col-md-12">
<div class="box2"></div>
</div>
</div>
</div>
CSS:
.box1,.box2{
width:80%;
height:100px;
margin:10px auto;
}
.box0{
width:80%;
height:220px;
margin:auto;
margin-top:10px;
background:green;
}
.box1{
background:blue;
}
.box2{
background:red;
}
JQUERY:
$(window).scroll(function() {
var y = $(".keeptop").offset().top;
var scrollY = $(window).scrollTop();
if (scrollY > y) {
var padY = scrollY - y;
$(".keeptop").css("padding-top", padY);
}
});
I use jqueryUI tabs and want to implement a smooth scroll bar inside each tab. I tried several scrollable plugins like jQuery custom content scroller, TinyScrollbar and now areaaperta NiceScroll, but each time I stack with the same problem - scrollbar works only inside one tab..
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<div id="tabs" style="width:900px; font-size:100%;">
<ul>
<li><a href="#tabs-1" >FIRST</a></li>
<li>SECOND</li>
<li>THIRD</li>
</ul>
<div id="tabs-1">
<div id="thisdiv">
<p><b>FIRST SCROLLABLE PARAGRAPH</b>...</p></div></div>
<div id="tabs-2"><div id="thisdiv2">
<p><b>SECOND SCROLLABLE PARAGRAPH</b>...</p>
</div></div>
<div id="tabs-3">
<p>THIRD TAB </p>
</div>
</div>
<script>
$(document).ready(
function() {
$("#thisdiv").niceScroll({cursorcolor:"#00F"});
$("#thisdiv2").niceScroll({cursorcolor:"#00F"}); }
);
</script>
Here is jsfiddle that shows that there is no conflicts between UItabs and two scrollbars of niceScroll plugin: http://jsfiddle.net/Fluc/EhcqX/4/
And here I tried to use same divs with scroll bars inside each tab:
http://jsfiddle.net/Fluc/cJPT3/2/
As you can see, scrollable works only inside the first tab.. Same with other scrollable plugs..
I'm not jquery programmer but It feels like the problem is related to display property somewhere.
Any help would be very appreciated!