I have a bootstrap carousel on which I want to place a card with text.
The problem is that that whatever I try, it's not putting it on top.
This is what I want:
Thi is the code:
<section id="hero">
<div class="vh-72">
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/carousel_1.jpg" class="d-block w-100" alt="Carousel image one">
</div>
<div class="carousel-item">
<img src="images/carousel_2.jpg" class="d-block w-100" alt="Carousel image two">
</div>
</div>
</div>
<div class="container bg-danger">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="card">
<h1>Some title text <br> bla bla </h1>
Optimieren Sie Ihre Unternehmenserfolg durch Auslagerung Ihrer Produktionsleistung und gestalten Sie Ihre
Prozesse zukunftsorientiert.
Unser Team Nord Ihnen kompetente Mitarbeiter in Produktionsprozessen der industriellen Herstellung. <br>
<button> test </button>
</div>
</div>
</div>
</div>
</div>
</section>
I've tried using position: absolute with z-index, but it just moves it wrong.
Here is the JSFiddle: https://jsfiddle.net/txyzs8fk/
Can you please check the below code? Hope it will work for you. We gave position relative to #hero div and added one parent div hero-description of Card and gave position absolute and z-index, also we have set it's position using bootstrap utility class.
Please refer this link https://jsfiddle.net/8mdaqoup/
.row {
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
#hero { position:relative;}
.hero-description { height:100%; width:100%; position:absolute; top:0; left:0; z-index:1;}
.hero-description .card { padding:30px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<section id="hero">
<div class="vh-72">
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://images.unsplash.com/photo-1608096299230-81c7b43d5dfc?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1349&q=80"
class="d-block w-100" alt="Carousel image one">
</div>
<div class="carousel-item">
<img src="https://images.unsplash.com/photo-1583513702439-2e611c58e93d?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1349&q=80"
class="d-block w-100" alt="Carousel image two">
</div>
</div>
</div>
<div class="hero-description">
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-md-6 col-sm-12">
<div class="card">
<h1>Some text <br> bla bla bla </h1>
<p>
Optimieren Sie Ihre Unternehmenserfolg durch Auslagerung Ihrer Produktionsleistung und gestalten Sie Ihre Prozesse zukunftsorientiert. Unser Team Nord Ihnen kompetente Mitarbeiter in Produktionsprozessen der industriellen Herstellung.
</p>
<button> test </button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
Related
Hi I am having trouble centering elements on mobile.
Website: https://dachsteinkaffee.myshopify.com/
I have set the margin-right of elements col-12 col-md-6 col-lg-4 to 0px but it looks like the margin is still appearing.
Tried to apply text-align:center to the class .img-box. But it did not help.
I have tried different options like this that did not work:
#media (max-width: 991px) {
#home-spotlight-1541414200176 .container-fluid .spotlight-3-blocks {
text-align: center;
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<div class="row spotlight-3-blocks">
<div class="col-12 col-md-6 col-lg-4">
<div class="spotlight-item">
<div class="img-box">
<a href="" class="animate-scale">
<img
data-src="//cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
src="https://cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
alt="Dachsteinkaffee"
itemprop="logo"
class="lazyautosizes lazyloaded"
data-sizes="auto"
sizes="370px"
/>
</a>
</div>
<div class="content spotlight-inner">
<h3 class="title"><span> MORGENGRUSS </span></h3>
<p class="des"><span> Der Filterkaffee eignet sich nicht nur für Frühaufsteher... </span></p>
<span> ZUM KAFFEE </span>
</div>
</div>
</div>
</div>
Any idea how to fix this?
First, in your demo code here, there is no #home-spotlight-1541414200176 .container fluid so it won't work here.
Then this margin right is auto generated to fill the empty as your image is not enought large to cover the whole space.
Just apply text-align:center to your class .img-box:
DEMO:
#media (max-width: 991px) {
.img-box {
text-align: center;
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<div class="row spotlight-3-blocks">
<div class="col-12 col-md-6 col-lg-4">
<div class="spotlight-item">
<div class="img-box">
<a href="" class="animate-scale">
<img
data-src="//cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
src="https://cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
alt="Dachsteinkaffee"
itemprop="logo"
class="lazyautosizes lazyloaded"
data-sizes="auto"
sizes="370px"
/>
</a>
</div>
<div class="content spotlight-inner">
<h3 class="title"><span> MORGENGRUSS </span></h3>
<p class="des"><span> Der Filterkaffee eignet sich nicht nur für Frühaufsteher... </span></p>
<span> ZUM KAFFEE </span>
</div>
</div>
</div>
</div>
Try this
there was an issue in #home-spotlight-1541414200176 .container-fluid
#media (max-width: 991px) {.spotlight-3-blocks {
text-align: center;
}}
<div class="row spotlight-3-blocks">
<div class="col-12 col-md-6 col-lg-4">
<div class="spotlight-item">
<div class="img-box">
<a href="" class="animate-scale">
<img
data-src="//cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
src="https://cdn.shopify.com/s/files/1/0571/1786/8231/files/Dachstein-Kaffee-Morgengruss-Startseite_800x800_crop_center.jpg?v=1621598467"
alt="Dachsteinkaffee"
itemprop="logo"
class="lazyautosizes lazyloaded"
data-sizes="auto"
sizes="370px"
/>
</a>
</div>
<div class="content spotlight-inner">
<h3 class="title"><span> MORGENGRUSS </span></h3>
<p class="des"><span> Der Filterkaffee eignet sich nicht nur für Frühaufsteher... </span></p>
<span> ZUM KAFFEE </span>
</div>
</div>
</div>
i'm currently developing a landing page for a startup, while i was making the "hero section" i wanted to use a carousel, everything worked fine until i tried adding the next section, to my surprise the next section was BEHIND the hero section, i tried reading through my code and tweaking a bit on chrome dev tools but i can't seem to find the problem, could you help me?
I've tried changing the position for all of the items in the carousel to static and their display to block to see if it went back to normal without success.
CODE:
HTML
<section id='hero-section'>
<div class="hero-carousel carousel slide" data-ride="carousel">
<div class="carousel-item active" data-interval="8000">
<img class="d-block w-100" src="includes/media/images/slide1.png" alt="">
<div class="carousel-caption d-none d-md-block">
<h2>Alcanza tus sueños</h2>
<p>Los créditos de nómina Axelera son fáciles de obtener y de pagar</p>
<button class='cta-button btn btn-md' type="button" name="button">Solicita tu crédito</button>
</div>
</div>
<div class="carousel-item" data-interval="8000">
<img class="d-block w-100" src="includes/media/images/slide2.png" alt="">
</div>
<div class="carousel-item" data-interval="8000">
<img class="d-block w-100" src="includes/media/images/slide3.png" alt="">
</div>
</div>
</section>
<section>
<h2>Test</h2>
</section>
CSS
.carousel-item img{
height: 500px;
object-fit: cover;
}
The next section (the one with the h2 "test" tag) should be below not behind the other section.
Just add the Bootstrap class clearfix and you are good to go!
.carousel-item img{
height: 500px;
object-fit: cover;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<section class="clearfix" id='hero-section'>
<div class="hero-carousel carousel slide" data-ride="carousel">
<div class="carousel-item active" data-interval="8000">
<img class="d-block w-100" src="https://via.placeholder.com/960x500" alt="">
<div class="carousel-caption d-none d-md-block">
<h2>Alcanza tus sueños</h2>
<p>Los créditos de nómina Axelera son fáciles de obtener y de pagar</p>
<button class='cta-button btn btn-md' type="button" name="button">Solicita tu crédito</button>
</div>
</div>
<div class="carousel-item" data-interval="8000">
<img class="d-block w-100" src="https://via.placeholder.com/960x500" alt="">
</div>
<div class="carousel-item" data-interval="8000">
<img class="d-block w-100" src="https://via.placeholder.com/960x500" alt="">
</div>
</div>
</section>
<section class="clearfix">
<h2>Test</h2>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.bundle.min.js"></script>
I want to make 3 columns horizontal and ı use col-md-12 for main column and for child columns col-md-4 but my row have only one columns and sub divs are vertical.My english not good enough but please help me.All divs are under other div and all divs are left side of page.I try my html in other project this is worked but in this projecy one thing corrupted my grid system but ı cant find it.
This is my nested Layout
#model HomeViewModel
#*#{
ViewData["Title"] = "News";
}*#
#section PageTitle{
etwyrjs
}
#section PageDesc{
etwyrjs
}
#*<div class="col-md-12">
<h2>News</h2>
</div>*#
#foreach (var pie in Model.Pies)
{
<div class="col-sm-4 col-lg-4 col-md-4">
<div class="thumbnail">
<img src="#pie.ImageThumbnailUrl" alt="" />
<div class="caption">
<h3 class="pull-right">#pie.Price.ToString("c")</h3>
<h3>
<a asp-controller="Home" asp-action="Details"
asp-route-id="#pie.Id">#pie.Name</a>
</h3>
<p>#pie.ShortDescription</p>
</div>
</div>
</div>
}
This is my nested Layout.
#{
ViewData["Title"] = "LayoutForOthers";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
<div class="col-md-12">
<img src="~/images/büyük foto-1.png" alt="Snow" style="width:100%;">
#*<div class="bottom-left">
</div>*#
<div class="top-left">
<h1 style="text-align:left; color:white">#RenderSection("PageTitle")</h1>
<br />
<br />
<p style="text-align:left; color:white;">#RenderSection("PageDesc") Dijital sağlık alanında dünyanın önde gelen isimlerinden olan ve İngiltere'nin en büyük sağlık teknolojisi topluluğu Health 2.0 London'ı kuran Maneesh Juneja, yapay zekanın geleceği hakkında önemli açıklamalarda bulundu. Kendisini ''dijital sağlık fütüristi'' olarak nitelendiren Juneja, geçtiğimiz hafta İstanbul'da katıldığı etkinlikte yapay zeka ile ilgili soruları yanıtlarken 2040 yılının önemli bir dönüm noktası olabileceğini işaret etti.</p>
</div>
#*<div class="top-right">Top Right</div>
<div class="bottom-right">Bottom Right</div>
<div class="centered">Centered</div>*#
</div>
</div>
<div class="row">
<div class="col-md-12">
#RenderBody()
</div>
</div>
This is from my main layout.
<div class="col-md-12">
#RenderBody()
</div>
Are you looking for something like this? This should work regardless of what your Bootstrap version is. (Open it in fullscreen)
<!-- Include this in your <head> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row">
<div class="col-sm-12 bg-primary">
<!-- This is you full width column -->
<p>This is you full width column</p>
</div>
<div class="row">
<div class="col-sm-4 bg-danger">
<!-- This is 1/3 columns -->
<p>Column 1</p>
</div>
<div class="col-sm-4 bg-info">
<!-- This is 2/3 columns -->
<p>Column 2</p>
</div>
<div class="col-sm-4 bg-success">
<!-- This is 3/3 columns -->
<p>Column 3</p>
</div>
</div>
</div>
My Jumbotron cut's the text and button, when I have a low resolution.
Do I need to solve this problem with a media query?
Or is there a "nicer" solution for this? at the moment I have only media query for the width.
.hero-bg {
background-color: #2e82b0;
}
.img-logo {
max-width: 100%;
}
.jumbotron {
height: 100vh;
}
<!-- Header -->
<section id="home" class="hero-bg jumbotron">
<div class="container">
<div class="row align-items-center justify-content-center mx-auto">
<div class="col mt-0 pt-0">
<hr class="mt-0 pt-0 mb-5 sichtbar" style="background: white;">
<br>
<img class="img-logo mt-5 pt5 mx-auto img-fluid d-block img-responsive" src="assets/img/logo.png" alt="Rollywood-Logo">
</div>
</div>
<div data-aos="zoom-in" class="row align-items-end justify-content-center mx-auto text-center mt-5 pt-5">
<div class="col pb-3">
<h2 class="jumb-title">Willkommen in meiner Welt:</h2>
<p class="lead jumb-p">
Mit emotionalen Worten und kreativen Konzepten die passende Bühne bereiten. <br />
<span>Überzeugen. Begeistern. Bewegen – und der Star sind SIE!</span></p>
<a href="#texting" role="button" class="jumb-btn btn-round mt-2 smooth">
<large><span class="icon-arrow-down"></span></large>
</a>
</div>
</div>
<!-- col -->
</div>
<!-- container -->
</section>
</header>
<!-- Header -->
You should use min-height instead of height...
.jumbotron {
min-height: 100vh;
}
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