Multiple line Carousel Caption for Bootstrap - html

I've used the Carousel Container to create a Page Header with Text centred (horizontally & vertically), as it was the easiest way to centre text over an image - refer image.
My client wants me to add a horizontal line above & below the text, as its done in this image below, but im not sure on the best way to achieve this - given everything still needs to be centred & it has to be responsive.
Here is my HTML code (excluding Navbar, as its Bootstrap);
<div class="container">
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<img src="images/community-group.jpg" alt="" class="center-block img-responsive" style="opacity: 0.8;">
<div class="carousel-caption">
<div class="text-center full-width"><h1>Contact Us </h1></div>
</div>
</div>
</div>
</div>
</div>
And here's the current CSS for handling the Carousel & Carousel Caption and making sure they're centred:
.full-width {
width: 100%;
}
h1 {
color: #ffffff;
font-size: 400%;
text-shadow: 2px 2px #9e9e9e;
}
.carousel-caption {
position: absolute;
top: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-moz-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
height: 100%;
vertical-align: middle;
}

<div class="container">
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div class="carousel-caption">
<div class="row">
<div class="col-sm-4">
<div>
<div class="col-sm-4">
<div class="text-center full-width">
<hr/>
<h1>Contact Us </h1>
<hr/>
</div>
</div>
<div class="col-sm-4">
<div>
</div>
</div>
</div>
</div>
</div>
</div>
Simple Way:
<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" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div class="carousel-caption">
<div class="row">
<div class="col-sm-4"><div>
<div class="col-sm-4">
<div class="text-center full-width">
<hr/>
<h1>Contact Us </h1>
<hr/>
</div>
</div>
<div class="col-sm-4"><div>
</div>
</div>
</div>
</div>
</div>
</div>

You can add an other class to carousel and change this carousel caption styles, whit this you have orginal carousel caption and your carousel caption.
Just change top to 50 percent and margin-top = caption height / 2
.verticalCarousel .carousel-caption {
bottom:inherit;
top: 50%;
margin-top:-150px;
border-top:1px solid #fff;
border-bottom:1px solid #fff;
}

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>

float left floating elements with steps down to the right

I am trying to create thumbnails for images in a div to appear with three columns. These elements are in a form tag. when i try to float my images which are produced with a loop they are creating a step down to the right. I tried using grid css it still gives me the same result.
sample image
image
blade file
<form action="/p/update/{{ $post->id}}" enctype="multipart/form-data" method="POST">
<div class="form-group ">
#foreach($posts as $post)
<div id="carouselExampleControls" class="carousel slide" data-interval="false">
<div class="carousel-inner">
#for($i=0; $i< count($image=$post->images()->get()); $i++)
#if($i==0)
<div class=" ">
<div class="editImages ">
<div class="img-order"> <img class="posts-img crop" src="/images/{{$image[$i]['image']}}" alt="first slide"> </div>
<div class="bottom-right"> more images </div>
</div>
</div>
#else
<div class="">
<div class="editImages">
<div class="img-order"> <img class="posts-img crop" src="/images/{{$image[$i]['image']}}" alt="first slide"> </div>
<div class="bottom-right"> more images </div>
</div>
</div>
#endif
#endfor
</div>
</div>
#endforeach
</div>
</form>
css file
.form-group{
background:brown;
}
.editImages{
display:flex;
float: left;
border: 1px solid black;
}
.editImages > div > img {
width: 7rem;
height: 7rem;
}
idk if I got the question right but try to add this
.editImages{
vertical-align: top;
}

Div not being centered when using margin: auto; (Bootstrap)

I have a working example website from the bootstrap template website and was analysing the code to understand how they created it. Namely how they centered the text on the first page located here. The code for that snipplet is,
<header class="masthead text-center text-white d-flex"> <!-- Background image set here -->
<div class="container m-auto">
<div class="row">
<div class="col-lg-10 mx-auto">
...
</div>
<div class="col-lg-8 mx-auto">
...
</div>
</div>
</div>
</header>
So then I noticed that the m-auto was doing the centering. However, when I attempt to create it from scratch for myself and create this basic code,
<style>
#frontpage {
height: 100vh;
width: 100vw;
}
</style>
<section id="frontpage">
<div class="container m-auto">
<div class="row">
<div class="col-8">
<h1> YOU CAN DO IT </h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
It doesn't center at all.
What am I forgetting here?
I would suspect that the container gets centered inside it's parent, which takes up the page.
you have copied the code but styles not included for them if guess correctly. anyway, I have corrected please try this one.
<style>
#frontpage {
height: 100vh;
width: 100%;
}
.center-me{
margin: auto;
width: 60%;
text-align: center;
}
</style>
<section id="frontpage">
<div class="center-me">
<div >
<h1> YOU CAN DO IT </h1>
</div>
<div >
<h1> I should be centered </h1>
</div>
</div>
</section>
Is this what you're after?
Version 1
https://codepen.io/panchroma/pen/YdEWZJ
HTML
<section id="frontpage">
<div class="container m-auto">
<div class="row">
<div class="col-8">
<h1> YOU CAN DO IT </h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
CSS
#frontpage{
background-color:pink;
height: 100vh;
width: 100vw;
}
.col-8{
border:1px solid grey;
margin-left:auto !important;
margin-right:auto !important;
text-align:center;
}
Version 2
This also centers the text vertically
https://codepen.io/panchroma/pen/KbygzX
HTML
<section id="frontpage">
<div class="container m-auto">
<div class="row vert-align">
<div class="col-8">
<h1>YOU CAN DO IT</h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
CSS
#frontpage{
background-color:pink;
height: 100vh;
width: 100vw;
}
.col-8{
margin-left:auto !important;
margin-right:auto !important;
text-align:center;
}
.row.vert-align{
position: absolute;
top: 50%;
left:50%;
-ms-transform: translateY(-50%);
transform: translate(-50%, -50%);
}

Image slider with stacked cells

I am writing a web application which has a design that requires an scrolling div with stacked images (see image)
I have written the following HTML
<div class="row">
<div class="col-md-12">
<div class="item-image-craousel-left"></div>
<div class="item-image-carousel">
<div style="background-image: url('http://img2.timeinc.net/people/i/2014/stylewatch/blog/140915/blake-lively-600x450.jpg')" class="main-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o1_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o2_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o3_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o4_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ncdgtvSlUc1rjtt9yo2_1280.jpg')" class="sub-image"></div>
</div>
<div class="item-image-craousel-right"></div>
</div>
</div>
And CSS:
.item-image-carousel {
width: 100%;
display: inline-block;
overflow-x: auto;
}
.item-image-craousel-left {
height: 399px;
width: 20px;
background-color: #40d1b0;
position: absolute;
text-align: center;
vertical-align: middle;
padding-top: 166px;
display: none;
}
And currently I am getting this which is not overflowing and when I increase the width the images stack inline rather than in blocks of two as in the image above
Can someone tell me how I can achieve the layout as in the first picture. I am using Bootstrap 3 for its grid.
From my comment I meant something like this...(not knowing the correct 'col-md-xx' to use)
<div class="row">
<div class="col-md-12">
<div class="item-image-craousel-left"></div>
<div class="item-image-carousel row">
<div class="col-md-8 main-image" style="background-image: url('http://img2.timeinc.net/people/i/2014/stylewatch/blog/140915/blake-lively-600x450.jpg')"></div>
<div class="col-md-4">
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o1_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o2_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o3_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o4_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ncdgtvSlUc1rjtt9yo2_1280.jpg')" class="sub-image"></div>
</div>
</div>
<div class="item-image-craousel-right"></div>
</div>
</div>

Text inside bootstrap carousel active item aligned with and outside text

I have this code:
<section class="container">
Logo
</section>
<section class="col-xs-12">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="http://placehold.it/1500x400/888&text=Item 1" />
<div class="container">My intro</div>
</div>
</div>
</div>
</section>
It's a bootstrap carousel with only one item. The item is a picture and over the picture a text. Here is the jsfiddle code and here is the jsfiddle live example.
The thing is that i want to place the My intro text over the picture (with a margin top 10px) and in the same time to be aligned with the Logo text. How can i do this?
Solved it!
Make both text absolutely position like this jsfiddle
html
<div id="logo">Logo</div>
<section class="col-xs-12" class="slider">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="http://placehold.it/1500x400/888&text=Item 1" />
<div class="myintro">My intro</div>
</div>
</div>
</div>
</section>
css
.slider {
position:relative;
}
.myintro {
position:absolute;
bottom:10px;
left:10px;
z-index:100;
}
#logo {
margin-left:10px;
}
As anpsmn posted in the comment, seems like this answer was right and here it is:
HTML:
<section class="container">
Logo
</section>
<section class="col-xs-12">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="http://placehold.it/1500x400/888&text=Item 1" />
<div class="container test-over"><h2>My intro</h2></div>
</div>
</div>
</div>
</section>
CSS:
.test-over h2 {position: absolute; top: 10px;}
Jsfiddle here