i have a problem that my slider on mobile screen is very small i tried to use media query to make it bigger on mobile screen but did not work
here is my code for slider
<section id="watch-app">
<h2 class="watch-head">watch app</h2>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="imgs/watch-app.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="imgs/watch-app1.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="imgs/watch-app.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class=" carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
</section>
and here is my css code for that section
#watch-app{
padding: 7rem;
text-align: center;
}
.img-fluid{
margin: 0 auto;
max-width: 650px;
padding-top: 6rem;
}
.carousel-indicators li{
width: 20px;
height: 20px;
background-color:white;
border-radius: 50%;
border: 1px solid #f16054;
}
.carousel-indicators {
bottom: -5rem;
}
.carousel-indicators .active{
background-color:#ef473a;
}
.carousel-control-next-icon{
width: 90px;
height: 80px;
background-image: url(../imgs/right-arrow.jpg);
margin-top: 5rem;
}
.carousel-control-prev-icon{
width: 90px;
height: 80px;
background-image: url(../imgs/left-arrow.png);
margin-top: 5rem;
}
and here is my media query
#media (max-width: 768px) {
.img-fluid{
max-width: 900px;
margin: 0 auto;
}
}
this how my slider look like in the normal screen
normal screen
and that how it look like on mobile screen
mobile screen
You have to add a width: 100%; with your max-width
Related
I'm trying to make a slider (imported from bootstrap) with captions on the bottom of the images using HTML and CSS, it does work on two images but not the third one.
Here's the code for the slider and the style.css portion that is used for the slider and caption.
HTML:
<!-------Slider------>
<div id="slider">
<div id="headerSlider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#headerSlider" data-slide-to="0" class="active"></li>
<li data-target="#headerSlider" data-slide-to="1"></li>
<li data-target="#headerSlider" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/slider1.jpg" class="d-block w-100" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption</h5>
</div>
</div>
<div class="carousel-item">
<img src="img/slider2.jpg" class="d-block w-100" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption 1</h5>
</div>
</div>
<div class="carousel-item">
<img src="img/slider3.jpg" class="d-block img-fluid" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption 2</h5>
</div>
</div>
<a class="carousel-control-prev" href="#headerSlider" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#headerSlider" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
#slider
{
margin: 0 auto;
width: 800px;
}
.carosuel-caption
{
top: 100%;
transform: translateY(-50%);
bottom: initial!important;
}
.carosuel-caption h5
{
color: #fff;
font-size: 42px;
}
.carousel-item
{
width: 80%;
height: 50%;
background-color: black;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 5%;
margin-top: 5%;
}
Picture of the slider:
Working slider image with caption
The slide in which it has no caption
I apologize if I missed something in the post.
I have tried to reduce the width of my carousel so that it doesn't take up the whole width of the page but it doesn't seem to be working. I would like the width to only span over 8 columns and to be centred. I have tried changing the CSS code so that the width was 50% and not 100% but this did not work.
.item {
height: 300px;
}
.item,
img {
height: 500px !important;
width: 100% !important;
}
.item h3 {
font-family: 'Anton', sans-serif;
font-size: 48px;
color: cornsilk;
}
.item p {
font-family: 'Anton', sans-serif;
font-size: 18px;
color: cornsilk;
}
<!--Start of carousel-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"> </li>
<li data-target="#carousel-example-generic" data-slide-to="1"> </li>
<li data-target="#carousel-example-generic" data-slide-to="2"> </li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="images/c1.jpg" alt="First slide" />
<div class="carousel-caption">
<h3>Welcome to my amazing website</h3>
<p3>Hope you enjoy!</p3>
</div>
</div>
<div class="item">
<img src="images/c2.jpg" alt="Second slide" />
</div>
<div class="item">
<img src="images/c3.jpg" alt="Third slide" />
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
Why wouldn't you work with the upper level, i.e. with the outer div element (id="carousel-example-generic" class="carousel slide")?
E.g.
.carousel{
width: 50%;
margin: 0 auto;
}
With bootstrap you could also use the bootstrap-grid including offsets: https://getbootstrap.com/docs/4.0/layout/grid/
I'm trying to create a carousel slider with carousel indicators at the bottom using Bootstrap-4.1.3. The problem is that the carousel indicators are invisible, but they do work when you click them.
I've already tried z-index, and background colors on the indicators, but they don't seem to work.
Here is my code:
.carousel-indicators {
z-index: 3;
#slide-buttons {
background-color: #999 !important;
background-color: rgba(70, 70, 70, .25) !important;
}
.active {
background-color: #444 !important;
}
}
<div class="carousel slide col-9 mx-auto pt-5 position-relative" data-ride="carousel" id="slides">
<!--Carousel Content-->
<div class="carousel-content carousel-inner" role="listbox">
<div class="slide-1 col-12 carousel-item active" id="slide1">
<h5>Example</h5>
</div>
<div class="slide-2 col-12 carousel-item" id="slide2">
<h5>Example</h5>
</div>
<div class="slide-3 col-12 carousel-item" id="slide3">
<h5>Example</h5>
</div>
</div>
<!-- Carousel Indicators -->
<ul class="carousel-indicators mt-5 pt-5 ">
<li data-target="#slides" id="slides-buttons" data-slide-to="0" class="active"></li>
<li data-target="#slides" id="slides-buttons" data-slide-to="1" class=" "></li>
<li data-target="#slides" id="slides-buttons" data-slide-to="2" class=" "></li>
</ul>
</div>
You should not use the same id multiple times on your page. Try using this solution instead:
.carousel .carousel-indicators li {
background-color: red;
}
.carousel .carousel-indicators li.active {
background-color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://cdn.pixabay.com/photo/2016/06/18/17/42/image-1465348_1280.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://cdn.pixabay.com/photo/2016/06/18/17/42/image-1465348_1280.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://cdn.pixabay.com/photo/2016/06/18/17/42/image-1465348_1280.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
There is a typepo error in your code css id.
'slides-buttons' and '#slide-buttons
Based on Cristiano Soares solution, I have also added some further suggestions.
To ensure that the main carousel component wrapper has indicators set to active;
<Carousel indicators={true} .... <Item><ProjectImg><Caption> ... >
I also added further styling, as I still couldn't see the indicators once they where enabled;
.carousel-indicators li {
background-color: red;
height: 5px;
width: 20px;
z-index: 5 !important;
margin: 0 5px;
cursor: pointer;
}
.carousel-indicators li.active {
background-color: blue;
height: 5px;
width: 20px;
z-index: 5 !important;
padding: 0 5px;
cursor: pointer;
}
I had the same problem with bootstrap 4. Then i figured display of indicators is none.
so this fixed my problem:
.carousel-indicators{
display: block !important;}
Is this carousel style possible for Bootstrap?
I've been trying this for days, I need help :(
First picture is the wireframe, ...
and the second picture is the actual look in the browser I'm working on...
...but it seems like it's not responsive when moved into larger screens
Here's the HTML-code:
<section id="wow_h>
<div class="container-fluid">
<div class="row">
<div id="carouselExampleIndicators" class="carousel slide carousel-style " data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="/assets/Untitled-1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="/assets/Untitled-2.jpg" alt="Third slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="/assets/Untitled-3.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div id ="hero-title" class="">
<h1>Headline
</br>
goes here</h1>
<p>Hero subtitle goes here
</br>
lorem ipsum dolor sit amet</p>
</div>
</div>
</div>
</section>
And here's the CSS-code:
// HOME
.carousel{
z-index: 1000;
margin: -5% 0 0 0;
}
#carouselExampleIndicators{
img{
background: cover;
}
}
.carousel-indicators > li {
border-radius: 50%;
}
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
display: block;
}
#wow_home{
position: relative;
#hero-title{
border-radius: 25px;
background: #f2efef;
color: #000;
z-index: 1080;
padding: 5%;
margin: 0 0 0 60%;
position: absolute;
h1{
text-transform: none;
}
}
}
I want on hover to change the opacity of the carousel-caption (centered)! I tried to achieve this but when this event happens and i have the opacity i want, then the controls of the carousel don't work. any ideas?
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="media1/1.png">
<div class='carousel-caption'>
<h3><span class='glyphicon glyphicon-asterisk' style='font-size: 50px;'></span><br>GET ... - DEVELOP ... - ENTER ...</h3>
</div>
</div>
<div class="item">
<img src="media1/3.png">
<div class="carousel-caption">
<h3>FLUENCY IN AVAILABLE TOOLS AND LANGUAGES CAN BE BETTER OBTAINED THROUGH COLLABORATIVE, INTENSE, HANDS-ON LEARNING</h3>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" id='carousL'></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" id='carousR'></span>
</a>
</div>
Here Is My Css:
.carousel-caption {
position:absolute;
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
}
.carousel-caption:hover{
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
background: grey;
opacity:0.1;
}
.carousel-caption {
display: none;
}
#carousel-example-generic:hover .carousel-caption {
display: block
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
background: grey;
opacity:0.1;
}