Fullscreen no-scrollbars image carousel - html

I have a Bootstrap 3.1.1 page with a fixed navbar and a sticky footer.
I need to show fullscreen (minus fixed navbar and sticky footer) images in a carousel. The cropping can be both from x and y, but the center of the image needs to be at the center of the viewport.
This is where I'm at now:
Bootply
Problem is I can't make the carousel appear. heght: 100% doesn't seem to work.
A CSS only solution is preferred, but I don't mind a little javascript though.

You can add the img-responsive class to your images, leaving your code like this:
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<!-- Begin page content -->
<div class="container-fluid">
<!-- Begin carousel -->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-pause="false">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="http://placehold.it/1600x1200/0000aa" alt="...">
</div>
<div class="item">
<img class="img-responsive" src="http://placehold.it/2592x1944/00aa00" alt="...">
</div>
<div class="item">
<img class="img-responsive" src="http://placehold.it/3264x2448/aa0000" alt="...">
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example courtesy Martin Bean and Ryan Fait.</p>
</div>
</div>
This will make your images behave just as you want, but with your approach, the fixed footer will leave some blank space. This depends on what you try to achieve, of course, but I think you would be better with a position:relative or position:absolute footer, otherwise you'll need to make some measurements with JS or jQuery.
Optionally, you can use vh length for everything and instead of img elements, make those images be the backgrounds for their respective item, so you can apply a background-size:cover property and be a happy camper

If you want no scroll you should use overflow: hidden but it is imposible that your image will be displayed without any crop because your image has a fixed size and there are lots of diferent devices with diferent view ports. It's just a matter of from what you want to crop. (width or height) If you want to crop from the width you should use height: 100% for that image and if you want to crop the width you should use the img-responsive class.
I guess for your case you should add the height of the image 100%, the overflow of the body hidden and center the image with margin: 0px auto;

Related

Laravel website with boostrap4 : FOUC on pages using container-fluid

Building a website with Laravel5 and Bootstrap4.
I'm getting a FOUC with a brief width of my page at 1/5 of width before expanding to real width.
The reason seems to be attached to how i use container-fluid.
I am using 'container-fluid' as i want to have a vertical left sidebar with content at the left of main page.
On a simple page, code is as per below :
<div class="container-fluid px-0">
<div class="d-lg-flex flex-lg-row justify-content-center ">
#yield('left_side')
<div class="col-12 col-lg-10 col-xl-10 custom-width">
<div class="container">
<div class="row justify-content-center" >
<div class="col-12">
<div class="card page_card" >
<div class="mx-auto" style="min-height: 70vh">
<p> example..</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
When removing my side-bar and using 'container' instead of container-fluid, the display is at correct width as soon as the page loads.
Correction
It is not about a width change. It seems briefly this is my side column which appears blank in the center with main page aligned vertically, before having the 2 pieces being put aligned horizontally
Addition1 - GIF of my FOUC-error
Here is an example of the FOUC:
It seems the FOUC is caused by my 'Google Ad'-div (in Yellow) i have inserted in my topbar containing my navbar. Some website have their ads appearing above the navbar so this can be done. Any clues?
<!-- for navigation and title on screen < lg -->
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark navbar-fixed-top d-lg-none">
<div class="container">
<div class="row" >
<div class="col-2">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMain" aria-controls="navbarsMain" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsMain">
<ul class="navbar-nav mr-auto" style="width: 200px">
<li class="{{Request::is('/') ? 'active' : ''}} nav-item">
<a class="nav-link">AAA </a>
</li>
<li class="{{Request::is('sentiment') ? 'active' : ''}} nav-item">
<a class="nav-link" >BBB</a>
</li>
<li class="{{Request::is('exchanges') ? 'active' : ''}} nav-item">
<a class="nav-link" >CCC</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="top-bar d-lg-none">
<hr class="divider-under-title mt-0 d-lg-none" />
<div class="container">
<div class="row justify-content-center" >
<div class="col-12">
<div class="top-ad d-none d-sm-block">
<script async defer src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- top-ad2 when removed, FOUC disappears -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-66666"
data-ad-slot="44444"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script async defer>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
<div class="col-12">
<!--<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">-->
<div class="ad_block_message_id">
Oh nasty adblocker. <i class="em em---1"></i>
</div>
</div>
</div>
</div>
</div>
<!-- for market segment on screen >= lg -->
<div class="top-large-bar d-none d-lg-block">
<!-- for Title on screen >= lg -->
<div class="row">
<div class="col-lg-12">
<h1 id="title" class="d-none d-lg-block">
<a class="deco-none" href="/">TEST</a><sup><code class="code_sup_text"></code></sup>
</h1>
</div>
</div>
<div class="container">
<div class="row justify-content-center" >
<div class="col-12">
<div class="top-ad d-none d-sm-block">
<script async defer src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- top-ad2 when removed, FOUC disappears -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-666666"
data-ad-slot="444444"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script async defer>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
<div class="col-12">
<!--<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">-->
<div class="ad_block_message_id">
Oh nasty adblocker. <i class="em em---1"></i>
</div>
</div>
</div>
</div>
</div>
<!-- for navbar on screen >= lg -->
<nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-dark navbar-fixed-top d-none d-lg-block mb-2">
<div class="container">
<a class="navbar-brand" href="/">{{ config('app.name') }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMain" aria-controls="navbarsMain" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsMain">
<ul class="navbar-nav mr-auto">
<li class="{{Request::is('/') ? 'active' : ''}} nav-item">
<a class="nav-link" >AAAA <</a>
</li>
<li class="{{Request::is('sentiment') ? 'active' : ''}} nav-item">
<a class="nav-link" >BBBBB</a>
</li>
<li class="{{Request::is('exchanges') ? 'active' : ''}} nav-item">
<a class="nav-link" >CCCCC</a>
</li>
</ul>
</div>
</div>
</nav>
It sounds like that you have something else going on, on your site that is causing the FOUC - and that it doesn't have something to do with the styles. Your styles looks fine to me.
If it were the styles that were the problem, then it would be because the HTML was loaded before the stylesheet was loaded. So unless you have your stylesheet in the footer, then I don't think that's the problem.
My best guess is that you have some Javascript doing something to the content that is being yielded in the left-column, - and that that isn't completed when the page is loaded. If so, - then you could work your way around it by adding a placeholder in your JavaScript until the content is loaded, - or to setup a preloader on your entire site.
In order to prove/disprove this theory, you could remove all scripts from your site and just insert som standard HTML in the left-column (temporarily), to see if that is loaded without the FOUC.
Answer to your edit (and GIF)
Thanks for the elaboration.
The first thing I'm seeing is, that you have content for < lg content and >= lg content. I wouldn't do that. Just have it once and modify it, whenever the browser-size changes. It's easier to maintain and will get you less errors. Also (currently) you have data-target="#navbarsMain" twice.
But here's the code that is giving you problems:
<div class="container">
<div class="row justify-content-center" >
<div class="col-12">
#include('inc.ad_top') <-- when removed, FOUC disappears
</div>
<div class="col-12">
#include('inc.ad_block_message')
</div>
</div>
</div>
I don't know what is happening in #include('inc.ad_top'). But if that is pulling some content, upon the page is loading, then that can be the root of the problem, since that content isn't pulled until after that page is loaded. And in that case, it would just display a blank col-12-container (0px height).
To debug you can change this:
<div class="col-12">
#include('inc.ad_top') <-- when removed, FOUC disappears
</div>
to this:
<div class="col-12" style="min-width: 500px; width: 100%; min-height: 500px; height: auto; display: block; overflow: hidden;">
#include('inc.ad_top') <-- when removed, FOUC disappears
</div>
... and see what that will get you.

Placing content DIV on bootstrap carousel

I am trying to place a content DIV on bootstrap carousel. So I tried it using CSS position. But still could not figure this out.
This is my HTML -
<div id="homepage-feature" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#homepage-feature" data-slide-to="0" class="active"></li>
<li data-target="#homepage-feature" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/1500X600">
<div class="container">
<div class="carousel-caption">
<h1>Changes to the Grid</h1>
<p>Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.</p>
<p><a class="btn btn-large btn-primary" href="#">Learn more</a>
</p>
</div>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1500X600">
<div class="container">
<div class="carousel-caption">
<h1>Percentage-based sizing</h1>
<p>With "mobile-first" there is now only one percentage-based grid.</p>
<p><a class="btn btn-large btn-primary" href="#">Browse gallery</a>
</p>
</div>
</div>
</div>
</div><!-- /.carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#homepage-feature" data-slide="prev">
‹
</a>
<a class="right carousel-control" href="#homepage-feature" data-slide="next">
›
</a>
<div class="container">
<div class="red"></div>
</div>
</div><!-- /#homepage-feature.carousel -->
This is JSFIDDLE with my current code
Can anybody tell me how to fix this proble?
Thank you.
So something like this? http://jsfiddle.net/LzdUa/131/
I just removed the container div from around the div with class="red":
<div class="red"></div>
The css your applying to the red box is only positioning it inside of the container, you will need to position the container itself. And then add extra css inside of media queries to move it below the carousel on smaller screen sizes. Or you can add an extra container and hide it on large screens and show it on small screens.
Bootstrap comes with classes already defined for hiding and showing depending on the device size so it saves you creating your own media queries.
see this here http://www.bootply.com/DzwnA7zrw6# think this is what your looking for.
The bits of the code to update are
html:
<div class="container red-position hidden-sm hidden-xs">
<div class="red"></div>
</div>
<div class="container visible-sm visible-xs">
<div class="red"></div>
</div>
css:
.carousel .red-position{
position:absolute;
top:0;
right:0;
}

How do I style a div in between a Header and Footer to always take up 100% of the remaining space?

I am using Bootstrap 3 to create a header and footer for my website. Both the header and footer are static so they can move accordingly if the user is on mobile to ensure the best visibility of the middle content. My question becomes how do I set the middle content to always take up 100% of the remaining space? The header and footer aren't always the same height because Bootstrap navbars are responsive. So the footer might be 50 pixels high on the desktop but in mobile it will be something like 62 pixels high because it stacked the footer content (text). Here's the code that I have:
<body>
<!-- Header -->
<div class="navbar navbar-default navbar-static-top">
<div class="navbar-inner">
<div class="container">
<div class="navbar-header">
<div class="navbar-brand">
Brand
</div>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left tabs">
<li>
<a href="#"><div>
<label class="IconText">Home</label>
</div></a>
<a href="#"><div>
<label class="IconText">Settings</label>
</div></a>
<a href="#"><div>
<label class="IconText">About</label>
</div></a>
<a href="#"><div>
<label class="IconText">Contact</label>
</div></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Header End -->
<!-- Middle Content -->
<div id="background" style="margin-top: -20px;">
<div class="mainContent">
</div>
</div>
<!-- Middle Content End -->
<!-- Footer -->
<div class="navbar navbar-default navbar-static-bottom">
<div class="container">
<p><label id="Label" class="navbar-text"></label></p>
</div>
</div>
<!-- Footer End -->
</body>
And here's my attempt at the CSS. I've been browsing this website and others for a while trying everything that I found but nothing seems to work.
.mainContent {
height: calc(100% - 120px); /* IE9+ and future browsers */
height: -moz-calc(100% - 120px); /* Firefox */
height: -webkit-calc(100% - 120px); /* Chrome, Safari */
}
#background {
background : #000000 url("./Images/black_background.jpg") no-repeat bottom left;
overflow:hidden;
height: 100%;
}
In desktop mode the Header takes up 70px and the Footer takes up 50px so that's where the 120px in the mainContent style section comes from but again the Header and Footer sizes are responsive.
An age old question, with a good answer/starting point here: http://css-tricks.com/snippets/css/sticky-footer/.
It's not bootstrap specific, so you may have to hammer some stuff into place, but the gist of it is there.

Giving camuflage to home page image that isn't wide enough

I am trying to make one of these modern designs where there's a carousel of images in the top of the home page of the webpage.
I am using Bootstrap 3 and so far I have managed to make it behave the way it should, but I feel like that's only going to happen in my screen, because I worked partially with fixed proportions so the images would look perfect in my screen, so they all have the same width and height. Here's how it looks:
If these images are displayed in a thinner screen I guess there would be no problem, or would there? I still have to test this, but I am pretty sure that there would not be any problem; anyway this is not that much of a concern for me right now, I am focused in the other issue. But if they're displayed in a wider screen an ugly border will appear, just like this:
That looks really bad, I think that I should center the image and treat those borders in a way that goes well along with the image, like if both image and borders were one whole. Any ideas?
Also I would need to reposition the carousel slide buttons to be fitted in the image instead outside. I am not that sure about how to do that either.
Here the code in case you need it:
<!-- Carousel -->
<div class="this-centrar-contenido this-margen-vertical">
<div id="carousel-inicio" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-inicio" data-slide-to="0" class="active"></li>
<li data-target="#carousel-inicio" data-slide-to="1"></li>
<li data-target="#carousel-inicio" data-slide-to="2"></li>
<li data-target="#carousel-inicio" data-slide-to="3"></li>
<li data-target="#carousel-inicio" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="img/img1.jpg">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img2.jpg">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img3.png">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img4.png">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img5.png">
<div class="carousel-caption">
text
</div>
</div>
</div> <!-- /.carousel-inner -->
</div> <!-- /#carousel-inicio -->
<!-- Controls -->
<a class="left carousel-control" href="#carousel-inicio" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left this-icono-grande"></span>
</a>
<a class="right carousel-control" href="#carousel-inicio" data-slide="next">
<span class="glyphicon glyphicon-chevron-right this-icono-grande"></span>
</a>
</div> <!-- /.col-md-12 -->
<!-- /Carousel -->
And custom css (the rest is Bootstrap 3 default for carousels)
.carousel-control
{
height: 600px;
}
For fitting the images I would use the images as background-images for each div.item, and set background-size: cover; in the css. For that each div.item needs an id or a specific class:
HTML:
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div id="img_1" class="item active">
<div class="carousel-caption">
text
</div>
</div>
<div id="img_2" class="item">
<div class="carousel-caption">
text
</div>
</div>
...
<div id="img_5" class="item">
<div class="carousel-caption">
text
</div>
</div>
</div> <!-- /.carousel-inner -->
CSS:
#img_1 {
background: url('img/img1.png') no-repeat center center;
background-size: cover;
}
#img_2 {
background: url('img/img2.png') no-repeat center center;
background-size: cover;
}
...
#img_5 {
background: url('img/img2.png') no-repeat center center;
background-size: cover;
}
Now, you won't have any problem with the different viewports. Change the size of your browser's window to test it.

Bootstrap with navbar fixed top and Bootstro

I am using Bootstrap + Bootstro but can't make the top navbar to get behind the overlay.
http://jsfiddle.net/NJsYw/5/ (click on Tutorial)
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="#" id='tutorial'>Tutorial</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
</div>
<p class="lead bootstro" data-bootstro-title='Title' data-bootstro-content="Description." data-bootstro-width="400px" data-bootstro-placement='bottom' data-bootstro-step='0'>Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added within <code>#wrap</code> with <code>padding-top: 60px;</code> on the <code>.container</code>.</p>
<p class="bootstro" data-bootstro-title='Title' data-bootstro-content="Description." data-bootstro-width="400px" data-bootstro-placement='bottom' data-bootstro-step='1'>Back to the sticky footer minus the navbar.</p>
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">Example courtesy Martin Bean and Ryan Fait.</p>
</div>
</div>
Looks like this was address here https://github.com/clu3/bootstro.js/issues/15 but I didn't know how to apply (if it is necessary)
Thanks
This can be done using CSS the key is z-index which specifies the stack order of an element.
The bootstrap navbar has a z-index of 1030 so in order for the bootstro backdrop to cover the navbar you need to adjust the z-index to be higher than 1030.
e.g.
.bootstro-backdrop
{
....
z-index: 2000;
}
You also need to make sure that the bootstrap popover is not covered so you need to increase its z-index to be higher than 2000.
.popover {
z-index:2001;
}
FIDDLE