I have a problem with CSS overlay. I'm making a website for a dog breeder and I want to make a carousel with male and female dogs. So my idea is to have 3 circular shaped images of male dogs on one slide of a carousel and 3 of female dogs on another. All of my images are 1000x1000 so they give a perfect circle on border-radius 50%.
On the overlay of the image there should be like 80% transparent background with dog's name and pedigree over the image. But my code does not work as it should so please help :)
Here's a part of my HTML for images:
<article>
<h2>Naši psi</h2>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active kontejner">
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas.jpg"/>
<div class="info">
<h3>Sass Crveni Mayestoso</h3>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas3.jpg"/>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas2.jpg"/>
</div>
<h3 class="spol">Mužjaci</h3>
</div>
<div class="item kontejner">
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas.jpg"/>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas3.jpg"/>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<img class="slika_psa" src="slika_pas2.jpg"/>
</div>
<h3>Mužjaci</h3>
</div>
<br><br>
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</article>
And part of CSS:
.kontejner {width: 90%;
margin: 25px auto;}
.slika_psa {
width: 80%;
border: 16px solid #fff;
border-radius: 50%;
background-color: #1c1c1c;
overflow: hidden;
}
.info {position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
visibility: hidden;
transition: .5s ease;
background-color: #008CBA;
}
.slika_psa:hover .info {visibility: visible;}
.carousel-inner {height: 100%;}
article {display: table;
width: 100%;
height: 100vh;
margin-top: 50px;
background-image: url('background..jpg');}
I can't figure it out how to make perfect circular overlay...Any help appreciated.
Related
I am trying to implement a carousel with Bootstrap, where the images are centered and auto-resized. For example, in the JSFiddle, as you can see the first image (the vertical one) stretches the whole div, while the third image remains at the top. I would like to reproduce the behavior of the Facebook or Twitter carousel, where the images are positioned in the center and resized according to the Div where they are included. Can you help me?
<div id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active">One</li>
<li data-target="#myCarousel" data-slide-to="1">Two</li>
<li data-target="#myCarousel" data-slide-to="2">Three</li>
</ul>
<!-- Inner -->
<div class="carousel-inner">
<div class="item active">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/171147625_1208393786271117_8898528403586821491_n.jpg?_nc_cat=111&ccb=1-3&_nc_sid=730e14&_nc_ohc=dDKFCCAYB-oAX_m2xtu&_nc_ht=scontent.ffco3-1.fna&oh=aa418a1e5facad55e6e4781237602778&oe=609A1892"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 1 - Vertical</h1>
<p>Hello!</p>
</div>
</div>
</div>
<div class="item">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/173646266_1210629629380866_4626783539462302067_n.jpg?_nc_cat=111&ccb=1-3&_nc_sid=730e14&_nc_ohc=QelU_ZVtqAcAX9wHI-l&_nc_ht=scontent.ffco3-1.fna&oh=272c997f1febf514a031aefe9cb712cb&oe=609BBCA2"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 2 - Square</h1>
<p>Hello again!</p>
</div>
</div>
</div>
<div class="item">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/167432599_1203101340133695_8518788973824059736_n.png?_nc_cat=107&ccb=1-3&_nc_sid=730e14&_nc_ohc=CItpIApuYmgAX_zHj8t&_nc_ht=scontent.ffco3-1.fna&oh=83145492bb38c8c2148df70086382459&oe=609A928F"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 3 - Horizontal</h1>
<p>Hello again and again!</p>
</div>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>
</div>
CSS
.carousel-indicators > li, .carousel-indicators > li.active {
width: 100px;
height: 25px;
border-radius: 0;
border: solid 1px grey;
background: lightgrey;
text-indent: 0;
}
.carousel-indicators > li.active {
background: white;
}
#myCarousel {
width: 500px;
height: 500px;
}
Add this
$('#myCarousel').owlCarousel({
autoHeight:true
});
Remove Height on CSS
#myCarousel {
width: 400px;
/*height: 400px;*/ /*remove This*/
}
Updated Code
#myCarousel .img-responsive{
margin:0 auto;
max-height:400px;
}
https://jsfiddle.net/lalji1051/qnrzuhm2/
Updeted :- https://jsfiddle.net/lalji1051/xmy46z3L/1/
Pardon me if I am asking something silly, but I have a requirement to create a full page slider with solid color as background and some text on left side and an image on right. Something like Google's Gmail Page.
Currently the result I want is
I have used Bootstrap 4's Carousel
I have modified it slightly and made its background grey as its in Google's image. Now I want the text to be left aligned and have a responsive auto resizeable image on the right (Or even if I can have an image adjusted on the top of the text only) which is also responsive when viewed on mobile. Something like
.
I am using this fiddle and I have modified the code as
<div class="carousel-item" style="background-color: #eff0f1">
<div class="carousel-caption d-none d-md-block">
<h2 class="display-4">First Slide</h2>
<p class="lead">This is a description for the first slide.</p>
</div>
</div>
<style>
.carousel-item {
background-color: #eeeeee; /*Solid grey background*/
}
.carousel-caption {
color: black;
}
</style>
Remove d-none class from carousel-caption and try this way :
.carousel-item {
height: 100vh;
min-height: 350px;
background: no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.text_part{
display: none;
}
#media (max-width: 575px){
.text_part{
display: block;
}
.left_part{
display: none;
}
}
<section class="text_part">
<div class="text">
<h2 >your text</h2>
</div>
</section>
<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">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active" style="background-color: gray">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-color: pink">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-color: green">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</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>
I'm working with a Bootstrap 3 carousel. Here is what I have done far, I want it to look similar to this.
Why does the slide preview from column 2 anytime I click the arrows? Is there a way to hide the preview from showing up when clicking next/previous
Anytime I click past two slides, it errors out and doesn't go back to the first slide.
<style type="text/css">
/* #information, #video {
width: 50%; //CSS styling for table tags.
} */
.linebreak {
display: none;
}
.image {
float: left!important;
}
.carousel slide {
width: 400px;
}
.text {
width: 45%!important;
float: right!important;
right: 14px!important;
/* top: 10px!important; */
margin-right: 35px!important;
/* margin-top: 20px!important; */
}
.carousel-inner {
overflow: visible;
}
.carousel img {
border-radius: 0px;
width: 140px;
margin-right: 10px;
margin-left: 80px;
}
.carousel-control active {
position: fixed;
}
.carousel {
margin-top: 40px;
}
.firstcolumn {
width: 1000px;
}
/*.video-container {
/*position:relative;
padding-bottom:315px;
padding-top:10px; /* width: 100% ;* max-width: 500px; padding-right:0px;
/*max-height:530px; overflow: auto;
border: none;
}
.video-container img {
position:absolute;
top:0;
left:0;
width:100%;
max-width: 500px;
max-height:530px;
height:100%;
margin: 0px;*/
/*}*/
</style>
<div class="firstcolumn">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"> <!-- DIV 1 BEGIN -->
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img class="image" src="https://www.evantage-technology.com/wp-content/uploads/2015/04/product_office365.jpg" alt="Los Angeles">
<div class="text">Office 365 is the brand name Microsoft uses for a group of subscriptions that provide productivity software and related services.</div>
</div>
<div class="item">
<img class="image" src="http://office365.ecolearning.eu/img/office_icos/delve-logo.png" alt="Chicago">
<div class="text">Microsoft Office Delve is a data visualization and discovery tool that incorporates elements of social networking and machine learning with the search capability of the Microsoft Office 365 suite.</div>
</div>
<!-- <div class="item">
<img src="ny.jpg" alt="New York">
</div>
</div> -->
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev" style="margin-top: 50px">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next" style="margin-top: 50px">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div> <!-- DIV 1 END -->
<div class="secondcolumn">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<center><h3>WHAT DO YOU WANT TO DO?</h3></center>
<br/>
<div class="row">
<div class="col-sm-6" align="center">.col-sm-3</div>
<div class="col-sm-6" align="center">.col-sm-6</div>
</div>
<div class="row">
<div class="col-sm-6" align="center">.col-sm-3</div>
<div class="col-sm-6" align="center">.col-sm-6</div>
</div>
</div>
</div>
</div>
</div>
If you make use of the Bootstrap Grid inside your Carousel component you can avoid using any customized CSS. You just need to structure your HTML accordingly:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-md-6">
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-xs-4"><img class="img-responsive" src="https://www.evantage-technology.com/wp-content/uploads/2015/04/product_office365.jpg" alt="Los Angeles"></div>
<div class="col-xs-8">Office 365 is the brand name Microsoft uses for a group of subscriptions that provide productivity software and related services.</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-xs-2"><img class="img-responsive" src="http://office365.ecolearning.eu/img/office_icos/delve-logo.png" alt="Chicago"></div>
<div class="col-xs-10">Microsoft Office Delve is a data visualization and discovery tool that incorporates elements of social networking and machine learning with the search capability of the Microsoft Office 365 suite.</div>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span><span class="sr-only">Previous</span></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span><span class="sr-only">Next</span></a>
</div>
</div>
<div class="col-xs-12 col-md-6">
<h3 class="text-center">WHAT DO YOU WANT TO DO?</h3>
<div class="row">
<div class="col-sm-6 text-center">A</div>
<div class="col-sm-6 text-center">B</div>
</div>
<div class="row">
<div class="col-sm-6 text-center">C</div>
<div class="col-sm-6 text-center">D</div>
</div>
</div>
</div>
</div>
You may need to expand the snippet to view its responsive nature. I would also point out that you were using elements like <center> which were depreciated, or attributes like align="center" on your <div> elements. You should use CSS for this sort of positioning, which with respect to Bootstrap would involve applying the text-center class to the element whose contents you wish to be centered.
I want to have the img in the carousel responsive. The height should be 100vh but the width needs to be as wide as it goes, depending on how big the img is. The overflowing part should be hidden. Now, when the screen gets smaller, the img is resized not to scale. Here's some screen shots
This is fine at full width, desktop version
This is about the witdh of tablets, but there are white space at the bottom which i dont want.
This is the phone version, resized but not to scale. It should also takes up the whole window, but the overflowing width can be hidden.
This is what I have for css:
.carousel,
.carousel-inner {
height: 100vh;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100vw;
height: 100vh;
max-width: none;
}
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="photos/JO2_2978.JPG" alt="xmas_orchestra">
</div>
<div class="item">
<img src="photos/JO2_2875.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_1824.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2955.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_3913.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2957.JPG" alt="...">
</div>
</div> <!-- CAROUSEL-INNER -->
There is a better and a very simple way to do this.
Keep all your carousel code within the bootstrap column within a row(Grid system)
And give some class name like .carousel-column in my example and then do two things.
1.Set some height and width as per your wish in your custom css file.
2.And set img-responsive in your code in the mail HTML Page for carousel items.
It worked for me, hope it will work for all.
HTML CODE:
<!-- Carousel to highlight main services-->
<div class="row">
<div class="col-md-9 carousel-column">
<div id="myCarousel" class="carousel slide">
<!-- 1.Carousel Indicators-->
<ol class="carousel-indicators">
<li data-target="#myCarousel" class="active" data-
slideto="0</li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- 2.carousel Items (Picture plus data)-->
<div class="carousel-inner">
<div class="item active">
<img src="images/book2.jpg" class="img-responsive img-cus" >
<div class="container">
<div class="carousel-caption">
<h1>Web Development</h1>
<h3>Let's begin development.It really is about who you are and what you can do</h3>
<p><a class="btn btn-primary btn-large" href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
<div class="item">
<img src="images/book.jpg" class="img-responsive img-cus">
<div class="container">
<div class="carousel-caption">
<h1>Twitter Bootstrap</h1>
<h3>A HTML,CSS,Javascript library for responsive
mobile first web development</h3>
<p><a class="btn btn-primary btn-large"
href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
<div class="item">
<img src="images/coffee.jpg" class="img-responsive img-cus"
>
<div class="container">
<div class="carousel-caption">
<h1>Java Tutorials</h1>
<h3>A powerful secure server side object oriented
programming language</h3>
<p><a class="btn btn-primary btn-large"
href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
</div>
<!-- Now We will create the carousel controls-->
<a href="#myCarousel" class="left carousel-control" data-
slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#myCarousel" class="right carousel-control" data-
slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
Now do this in CSS file
CSS Styling:
.carousel-column{
height:500px;
width:900px;
margin:0 auto;
}
Try this:
Check Demo here
HTML:
<div class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active" style="background-image:url(http://dentistry.utah.edu/images/slider-banner/roy-hume.jpg); ">
</div>
<div class="item" style="background-image: url(http://dentistry.utah.edu/images/slider-banner/school-dentistry-students.jpg);">
</div>
</div>
<!-- CAROUSEL-INNER -->
</div>
CSS:
.carousel,
.carousel-inner {
height: 100vh;
}
.item {
border: 1px solid grey;
max-height: 100vh;
min-height: 100vh;
max-width: 100vw;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
if you are using img src="...", then use class="img-responsive" and in css width="100%".
it worked like that
<div class="carousel-item activo">
<a href="#" style="display: block; width: 100%; height: 100%;">
<img class="img-fluid d-block w-100" src="01.jpg" alt="Alternate Text" />
</a>
</div>
Need to change img css that please check
.carousel,
.carousel-inner {
height: 100vh;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: auto;
max-width: 100%;
}
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="photos/JO2_2978.JPG" alt="xmas_orchestra">
</div>
<div class="item">
<img src="photos/JO2_2875.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_1824.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2955.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_3913.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2957.JPG" alt="...">
</div>
</div> <!-- CAROUSEL-INNER -->
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100vw;
height: 100vh;
max-width: none;
object-fit:cover;
object-position:center;
}
Please replace you CSS code.
See my bootply
I have a Bootstrap-3 carousel with 3 x DIVs showing each time. You can click right and left for next 3 x DIVs to show. But my indicators are a whole area where you can click, the grey block. Is it possible to just have the > thingie clickable?
Also, how to get the > thingie to be outside my DIV, now its overlapping with my content? Gracias!
HTML:
<div class="carousel slide" data-ride="carousel" id=
"carousel-example- generic">
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target=
"#carousel-example-generic"></li>
<li data-slide-to="1" data-target="#carousel-example-generic"></li>
<li data-slide-to="2" data-target="#carousel-example-generic"></li>
</ol><!-- Slider Content (Wrapper for slides )-->
<div class="carousel-inner">
<div class="item active">
<div class="col-md-4 col-sm-6">
<p>
aaaaaaaaaaaaaaaaaaaa</p>
</div>
<div class="col-md-4 col-sm-6 hidden-xs">
<p>bbbbbbbbbbbbbb</p>
</div>
<div class="col-md-4 col-sm-6 hidden-sm hidden-xs">
<p>cccccccccccccc</p>
</div>
</div>
<div class="item">
<div class="col-md-4 col-sm-6">
<p>dddddddddddddd</p>
</div>
<div class="col-md-4 col-sm-6 hidden-xs">
<p>eeeeeeeeeeeeee</p>
</div>
<div class="col-md-4 col-sm-6 hidden-sm hidden-xs">
<p>ffffffffffffff</p>
</div>
</div>
</div>
</div><!-- Controls -->
<a class="left carousel-control" data-slide="prev" href=
"#carousel-example-generic"><span class=
"glyphicon glyphicon-chevron-left"></span></a> <a class=
"right carousel-control" data-slide="next" href=
"#carousel-example-generic"><span class=
"glyphicon glyphicon-chevron-right"></span></a>
CSS:
.carousel-indicators li { visibility: hidden; }
.carousel-inner .item {
font-size:10px;
color:#0404B4
}
.carousel-control {
z-index: 10;
top: 2%;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
I'have updated your css.
/* CSS used here will be applied after bootstrap.css */
.carousel-indicators li { visibility: hidden; }
.carousel-inner .item {
font-size:10px;
color:#0404B4
}
.carousel-control {
z-index: 10;
top: 2%;
width: 30px; // no more gray thing
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.carousel-control.left,
.carousel-control.right { background: none }
// change it according to your needs
.carousel-control.left { left: -10px; }
.carousel-control.right { right: -10px; }
Demo