Flexbox in Firefox - html

I have been building a site and have been experimenting with display:flexand had some success in implementing what I feel is a nice enough thumb-nail block element.
However, in Firefox it does this:
I have tested it and it seems to be an issue with the use of display:flex and position:absolute.
I have read that Firefox treats absolute positioning differently than others browsers I have tested in.
Chrome
Edge
Opera
I have experienced a similar issue in:
Internet Explorer 11
Safari 5.1.7
Firefox 50.1.0
HTML
<section id="services" class="text-center center-block">
<div class="container">
<div class="row">
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="img/picto/originals/png/Pound/Newable_Pictogram_CoolGrey_POUND.png" width="156" height="200" alt="" />
<div class="caption">
<p class="bold">Attractive commissions for business introductions, paid promptly.</p>
</div>
</div>
</div>
<!-- Block -->
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="img/picto/originals/png/Arrows/Newable_Pictogram_Navy_ARROWS.png" width="200" height="199" alt="" />
<div class="caption">
<p class="bold">We’re committed to delivering fast, and treating you and your clients fairly.</p>
</div>
</div>
</div>
<!-- Block -->
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="img/picto/new/Newable_Pictogram_Navy_GROWTH.png" width="271" height="200" alt="" />
<div class="caption">
<p class="bold">We are a trusted, long established and large-scale Responsible Finance Provider.</p>
</div>
</div>
</div>
<!-- Block -->
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="img/picto/new/Newable_Pictogram_cool_grey_PARTNER.png" width="200" height="200" alt="" />
<div class="caption">
<p class="bold">Incentive-led schemes to promote long term business development partnership.</p>
</div>
</div>
</div>
<!-- Block -->
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey">
<img src="img/picto/originals/png/Speech Bubbles/Newable_Pictogram_CoolGrey_SPEECHBUBBLES.png" width="263" height="200" alt="" />
<div class="caption">
<p class="bold">Best in class broker support package including dedicated account manager.</p>
</div>
</div>
</div>
<!-- Block -->
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey">
<img src="img/picto/originals/png/Infinity/Newable_Pictogram_Navy_INFINITY.png" width="215" height="100" alt="" />
<div class="caption">
<p class="bold">We partner with finance brokers, financial advisors, High Street banks, solicitors and accountants.</p>
</div>
</div>
</div>
<!-- Block -->
</div>
</div>
</section>
CSS
.thumbnail {
border: none;
min-height: 500px;
position: relative;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
}
.thumbnail img {
padding-top: 0;
max-height: 50%;
max-width: 50%;
padding-bottom: 25%;
}
.caption {
position: absolute;
bottom: 0;
}
Am I just using display:flex incorrectly?

Check this basic example of your scenario (commented .caption padding just to make it clearer):
Added flex-flow: column wrap; to .thumbnail.
div.thumbnail {
border: none;
min-height: 500px;
position: relative;
display: -webkit-flex;
display: flex;
flex-flow: column wrap;
justify-content: center;
align-items: center;
}
.thumbnail img {
padding-top: 0;
max-height: 50%;
max-width: 50%;
/* padding-bottom: 25%; */
}
.caption {
/* position: absolute; */
/* bottom: 0; */
max-width: 50%;
margin: 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section id="services" class="text-center center-block">
<div class="container">
<div class="row">
<!-- Block -->
<div class="col-xs-12 col-sm-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="http://placehold.it/300x300" width="156" height="200" alt="" />
<div class="caption">
<p class="bold">Attractive commissions for business introductions, paid promptly.</p>
</div>
</div>
</div>
</div>
</div>
</section>

Related

Center horizontally and vertically a div in a section and make each section fill the whole page when scrolling

I am trying to code a page where each section fills the whole page. And I am also trying to center vertically and horizontally the divs in each section.
I don't know if it's possible, if you guys can enlighten me it would be great.
I also would like to know if it's possible that, when I scroll it automatically goes to the next section. I don't know if it's clear enough to understand.
Here's the CSS :
.presta .container {
width: 100%;
position: relative;
}
.presta .h1 {
font-size: 80px;
font-weight: bold;
}
.presta card {
padding: 30px;
margin: 0 auto;
}
.logoPresta:hover {
transition: transform 0.3s ease-in;
transform: translateY(-10px);
}
.prestaShow {
text-align: center;
}
.wrapper {
min-height: 100%;
}
<div class="navbar ">
<div class="container flex">
<div class="logo" data-aos="fade-right">
<img src="images/linko_bg_transp.png" alt="" />
</div>
<nav data-aos="fade-in">
<ul>
<li>Accueil</li>
<li>Présentation</li>
<li>Nos Prestations</li>
<li>Nous contacter</li>
</ul>
</nav>
</div>
</div>
<section class="presta bg-light wrapper">
<div class="container">
<div class="text-center">
<h1>Nos domaines d'expertises</h1>
</div>
<div class="grid grid-4">
<div class="logoPresta card">
<img src="images/1.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/2.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/3.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/4.jpg" alt="">
</div>
</div>
</div>
</section>
<section class="prestaShow wrapper">
<div class="container info">
<div class="text-center">
<h2>Informatique</h2>
</div>
<div class="textePresta card">
Conception & développement d'applications web
</div>
<div class="textePresta card">
Création & amélioration de bases de données
</div>
<div class="textePresta card">
Déploiement d'infrastructures réseaux
</div>
</div>
</section>
Here are the images of the page :
You can resize section to full page height by changing 100% to 100vh
Also, take a look at CSS section to see how to center wrappers' content (expand Code snippet to see differences).
UPD:
.snap-wrapper will help you to scroll full sections, take a look at Code snippet on full-screen.
.presta .container {
width: 100%;
position: relative;
}
.presta .h1 {
font-size: 80px;
font-weight: bold;
}
.presta card {
padding: 30px;
margin: 0 auto;
}
.logoPresta:hover {
transition: transform 0.3s ease-in;
transform: translateY(-10px);
}
.prestaShow {
text-align: center;
}
.wrapper {
/* centering wrapper content */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
}
/* use .snap-wrapper to scroll page by full sections */
.snap-wrapper {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
scroll-snap-type: y mandatory;
overflow: auto;
height: 100vh;
}
.snap-wrapper > .wrapper {
scroll-snap-align: center;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="navbar ">
<div class="container flex">
<div class="logo" data-aos="fade-right">
<img src="images/linko_bg_transp.png" alt="" />
</div>
<nav data-aos="fade-in">
<ul>
<li>Accueil</li>
<li>Présentation</li>
<li>Nos Prestations</li>
<li>Nous contacter</li>
</ul>
</nav>
</div>
</div>
<div class="snap-wrapper">
<section class="presta bg-light wrapper">
<div class="container">
<div class="text-center">
<h1>Nos domaines d'expertises</h1>
</div>
<div class="grid grid-4">
<div class="logoPresta card">
<img src="images/1.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/2.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/3.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/4.jpg" alt="">
</div>
</div>
</div>
</section>
<section class="prestaShow wrapper">
<div class="container info">
<div class="text-center">
<h2>Informatique</h2>
</div>
<div class="textePresta card">
Conception & développement d'applications web
</div>
<div class="textePresta card">
Création & amélioration de bases de données
</div>
<div class="textePresta card">
Déploiement d'infrastructures réseaux
</div>
</div>
</section>
</div>

horizontally center multiple divs within a div in small devices (xs)

My page has 3 div(s) within a div. In tablet and desktop screens they look good (center-aligned), but on a very small device such as cellphone the inner div(s) are left aligned (I want them to be horizontally center aligned). I applied text-center, and center-block to the outer div but it does not work. Any suggestion? Here are the html, and css codes.
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
portfolio-caption {
max-width: 281px;
background-color: #994ACC;
text-align: center;
padding: 10px;
border-top: 3px solid #ffffff;
margin-bottom: 10px;
}
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div style="max-width: 281px">
<a href="#" ">
<img src="./x/pilotproject1.jpg " class="img-responsive " style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div style="max-width: 281px ">
<a href="# ">
<img src="./x/pilotproject2.jpg " class="img-responsive "
style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div style="max-width: 281px ">
<a href="# " class="pilot-link ">
<img src="./x/pilotproject3.jpg " class="img-responsive "
style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
</div>
The reason that I have is that the width of the pictures is 281 px, if I do not set the width, the width of the div that comes after the img will be bigger than 281 px which is not something that I want.
as you can see in this picture, the images are all left-aligned
I added a class centered as a container to center elements (please remove the border border: 1px solid red; it is used to show you the container block ):
.centered {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
border: 1px solid red;
}
.img-responsive {
display: block;
max-width: 281px !important;
height: auto;
margin: 0 auto;
}
wrap each element you want to be centered.
Also in your css portfolio-caption should be .portfolio-caption to select a class.
I moved your in-line style to css class img-responsive so you can update your style in one place.
.img-responsive {
display: block;
max-width: 281px !important;
height: auto;
margin: 0 auto;
}
.portfolio-caption {
width: 281px;
background-color: #994ACC;
text-align: center;
padding: 10px;
border-top: 3px solid #ffffff;
margin-bottom: 10px;
float: right;
}
.centered {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
/* border: 1px solid red; */
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="#">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="# ">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="# " class="pilot-link ">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
</div>
You should not apply classes to outer divs, apply them exactly to what you want to be centered : class="img-responsive center-block", and
also check the bootstrap version center-block is new in Bootstrap version 3.0.1 i believe.
Use
Text align : center ;
text-align:center
<div style="max-width: 281px; text-align : center">
Plunker link :
https://plnkr.co/edit/UaW436KiylzfqOCU1cg1?p=preview

Bootstrap - aligning figures with col-sm-4 command

I am trying to align horizontaly three elements using the col-sm-4 function but for whatever reason I am missing it is not working. No matter what I do, the items are still displayed aligned to left and vertically. The images are all the same size.
Here's the code snippet:
<section class="container">
<div class="row">
<figure class="col-sm-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-sm-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-sm-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>
and the css:
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
It puzzles me because I have looked over other websites using the same technique and I cannot spot the error. Thanks.
you want like this ?
section .row img {
border: 4px dotted #000;
clear: none;
display:inline-block;
}
.col-sm-4
{
display:inline-block;
}
DEMO HERE
After making a few adjustments, I managed to get your code working (see comments in snippet for details)
/* made the boxes use flexible boxes to lay themselves out in a row */
.flexgrid {
display: flex;
flex-direction: row;
align-items: center;
}
/* fixed css because there were no 'row' elemeents */
/* added the > operand */
section > .col > img {
margin: 30px 0 30px;
width: 50%;
border: 4px dotted #000;
clear: none;
align: center;
}
.col > div, .col > img {
content-align: center
}
<section class="container">
<div class="flexgrid">
<figure class="col">
<!-- change <p> to <div> to avoid newline -->
<div>PLAY</div>
<center>
<img src="img/m1.jpg" />
</center>
</figure>
<figure class="col">
<div>LEARN</div>
<center>
<img src="img/m2.jpg" />
</center>
</figure>
<figure class="col">
<div>HELP</div>
<center>
<img src="img/m3.jpg" />
</center>
</figure>
</div>
</section>
Seems to be an issue with the screen size your using not being specified in the col-- format. I've added col-lg-4 col-md-4 col-sm-4 col-xs-4 as the class to support all screen sizes and it is working perfectly now.
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section class="container">
<div class="row">
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>
You just need to use predefined bootstrap class text-center for <div class=row...:
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section class="container">
<div class="row text-center">
<figure class="col-xs-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-xs-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-xs-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>

One page site - images overflow on responsive versions

I've put together a one page site but am having problems with the top section.
It's fine on a desktop, but on any other device the three main photographs on the section stack, instead of the section expanding to allow this, the images just overflow (or are hidden if using overflow hidden property).
I'm not sure what the issue is that's causing this and would be grateful for your guidance.
Here's the html:
<!-- Jumbotron -->
<section class="jumbotron" id="header">
<div class="container">
<div class="main-photo" id="header-photo">
</div>
<div class="transparent-box" style="padding-top: 3%;">
<img src="images/logo.png" style="width: 100%;"></img>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1" style="padding-top:5%">
<div class="row">
<div class="col-md-3 col-sm-offset-1">
<figure class="round-outline">
<img class="round-photo img-responsive" src="assets/photo1-sm.jpg" alt="">
<div class="round-caption-bg"></div>
</figure>
</div>
<div class="col-md-3">
<figure class="round-outline">
<img class="round-photo img-responsive" src="assets/photo2-sm.jpg" alt="">
<div class="round-caption-bg"></div>
</figure>
</div>
<div class="col-md-3">
<figure class="round-outline">
<img class="round-photo img-responsive" src="assets/photo3-sm.jpg" alt="">
<div class="round-caption-bg"></div>
</figure>
</div>
</div>
<div class="row">
<a href="#quote-one" style="color: #d5b17c;">
<i class="fa fa-chevron-down fa-2x pulsate-opacity chevron"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<!-- End of Jumbotron -->
and the css:
/* ==========================================================================
Jumbotron Section
========================================================================== */
.jumbotron {
padding: 100px 0 60px;
margin-top: 0;
margin-bottom: 0;
background: transparent url('../images/black-red-background.jpg') no-repeat top center;
background-size: auto auto;
background-attachment: fixed;
font-size: 1em;
height: auto;
overflow: hidden;
}
.jumbotron .container {
text-align: center;
}
If I understood correctly then the problem is your col-md classes cause breakpoints at the MD size which is tablets lower.
Change <div class="col-md-3 col-sm-offset-1"> to <div class="col-xs-4">
And the other 2 <div class="col-md-3" also to <div class="col-xs-4">
Is that what you want?

Vertical align of two md column with Bootstrap

I've searched and tried all Stackoverflow solutions without success.
I've this code and I'm using bootstrap3
<footer>
<div class="container">
<div class="row">
<div class="col-md-4">
<img src="Images/social/facebook.png" alt="facebook" class="footerimg" />
<img src="Images/social/twitter.png" alt="twitter" class="footerimg" />
<img src="Images/social/youtube.png" alt="youtube" class="footerimg" />
</div>
<div class="col-md-4 col-md-offset-4">
<p class="text-right">© <%: DateTime.Now.Year %> Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
</div>
</div>
</div>
</footer>
I would like to vertically center col-md-4 elements and I have footer styles like this:
footer {
background-color: #000;
color: #fff;
height: 120px;
}
I've already tried with table-cell applied to col-md-4 but without success.
Can you suggest a solution?
If you want something like this : (images are not shown)
I made a live example.
This is the code :
<footer>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="centered">
<img src="Images/social/facebook.png" alt="facebook" class="footerimg" />
<img src="Images/social/twitter.png" alt="twitter" class="footerimg" />
<img src="Images/social/youtube.png" alt="youtube" class="footerimg" />
</div>
</div>
<div class="col-md-4 col-sm-4 col-sm-offset-4 col-md-offset-4">
<div class="centered">
<p class="text-right">© Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
</div>
</div>
</div>
</div>
</footer>
And the CSS
footer {
background-color: #000;
color: #fff;
height: 120px;
display: table;
width: 100%;
}
.centered {
display: table-cell;
vertical-align: middle;
height: 120px;
}
Ref : centering-in-the-unknown