I'm trying to create a slider on my website using media queries to adjust the image size. Here's my CSS code:
#myCarousel .item {
height:400px;
}
#slide1{
background:url("bdpics/CoxBazar/new folder/coxE_4_md.jpg") top center no-repeat;
}
#slide2{
background:url("bdpics/CoxBazar/new folder/cox_3_md.jpg") top center no-repeat;
}
#slide3{
background:url("bdpics/CoxBazar/new folder/coxE_4-avrg.jpg") top center no-repeat;
}
/* -------------------Media queries--------------------------------*/
/* ----- portrait and landscape phone------------------------------------*/
@media(max-width: 480px){
#myCarousel .item {
height:270px;
width:100%;
}
#slide1{
background:url("../bdpics/CoxBazar/new folder/cox_3_sm.jpg") top center no-repeat;
background-size:100% 100%;
min-width: 100%;
height: 675px;
}
#slide2{
background:url("../bdpics/CoxBazar/new folder/coxE_4_sm.jpg") top center no-repeat;
background-size:100%;
}
#slide3{
background:url("../bdpics/CoxBazar/new folder/cox_24_sm.jpg") top center no-repeat;
background-size:100%;
}
}
/* ----- landscape phone and portrait tablet----------------------------*/
@media(max-width: 768px){
#myCarousel .item {
height:420px;
width:100%;
}
#slide1{
background:url("../bdpics/CoxBazar/new folder/cox_3_md.jpg") top center no-repeat;
min-width: 100%;
height:420px;
}
#slide2{
background:url("../bdpics/CoxBazar/new folder/coxE_4_md.jpg") top center no-repeat;
min-width: 100%;
height:480px;
background-size:100% 100%;
}
#slide3{
background:url("../bdpics/CoxBazar/new folder/cox_24_md.jpg") top center no-repeat;
min-width: 100%;
height:480px;
background-size:100% 100%;
}
}
@media(max-width: 1200px){
#myCarousel .item {
height:580px;
width:100%;
}
#slide1{
background:url("../bdpics/CoxBazar/new folder/cox_3_lg.jpg") top center no-repeat;
min-width: 100%;
height:580px;
background-size:100% 100%;
}
#slide2{
background:url("../bdpics/CoxBazar/new folder/coxE_4_lg.jpg") top center no-repeat;
min-width: 100%;
height: 580px;
background-size:100% 100%;
}
#slide3{
background:url("../bdpics/CoxBazar/new folder/cox_24_lg.jpg") top center no-repeat;
min-width: 100%;
height: 580px;
background-size:100% 100%;
}
Everything is working fine for @media(max-width: 1200px)
, but when the screen width is less than 768px, it loads the large image instead of the medium or small ones. I need help finding where I went wrong.