Responsive text positioning? - html

I use Bootstrap carousel slider with text (carousel-caption). It is responsive on all device, but the text is always centered and on the bottom of screen. I know how to position the text wherever I want.
But if I change the position, it isn't properly displayed on other devices. I just want to position the text to the left and in the middle of the screen and I want it to stay there when I resize the viewport.
.carousel-caption {
top: 35%;
width:500px;
left: 220px;
bottom: auto;
}
.red {
color:red;
}
.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;
}
.lnr {
display: inline-block;
fill: currentColor;
width: 1em;
height: 1em;
vertical-align: -0.05em;
stroke-width: 1;
}
.services-icon {
margin-bottom: 20px;
font-size: 30px;
}
bgc2, .vLine, .hLine {
background-color: #0F52BA;
}
.quote-icon {
font-size: 40px;
margin-bottom: 20px;
}
.services-icon {
font-size: 60px;
margin-left: 2rem;
}
.slide1-title {
font-size: 40px;
}
.slide1-content{
font-size:18px;
}
.btn-style-one {
position: relative;
padding: 14px 30px;
line-height: 1em;
background: #221f1f;
margin-top: 20px;
color: #ffffff !important;
font-size: 13px;
font-weight: 800;
text-transform: uppercase;
display: inline-block;
border: 2px solid transparent !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/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>
</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-image: url('https://images.wallpaperscraft.com/image/windows_7_black_glass_reflection_26309_1920x1080.jpg')">
<div class="carousel-caption d-lg-block slide1-bg">
<h2 class="display-4 slide1-title" style="text-transform: uppercase; font-weight: bold;"></h2><br>
<p class="lead slide1 slide1-content"><i>TEXT for position</i><br>
BUTTON
</div>
</div>
</div>
</div>
</div>
<div class="carousel-arrow">
<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>
</div>

For minimal change; replace your '.carousel-caption' style block with the below:
.carousel-caption {
top: 0 !important;
left: 0 !important;
width: 100%;
max-width: 100vw;
padding: 0 15%;
}
And add for that "I just want to put text left in the middle of the screen":
.carousel-caption .lead {
text-align: left;
position: absolute;
top: 45vh;
}
Fiddle: https://jsfiddle.net/c3h0zt9b/

.carousel-item .carousel-caption {
top: 35%;
width:500px;
left: 220px;
bottom: auto;
right: auto;
text-align: left;
}
.red {
color:red;
}
.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;
}
.lnr {
display: inline-block;
fill: currentColor;
width: 1em;
height: 1em;
vertical-align: -0.05em;
stroke-width: 1;
}
.services-icon {
margin-bottom: 20px;
font-size: 30px;
}
bgc2, .vLine, .hLine {
background-color: #0F52BA;
}
.quote-icon {
font-size: 40px;
margin-bottom: 20px;
}
.services-icon {
font-size: 60px;
margin-left: 2rem;
}
.slide1-title {
font-size: 40px;
}
.slide1-content{
font-size:18px;
}
.btn-style-one {
position: relative;
padding: 14px 30px;
line-height: 1em;
background: #221f1f;
margin-top: 20px;
color: #ffffff !important;
font-size: 13px;
font-weight: 800;
text-transform: uppercase;
display: inline-block;
border: 2px solid transparent !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/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>
</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-image: url('https://images.wallpaperscraft.com/image/windows_7_black_glass_reflection_26309_1920x1080.jpg')">
<div class="carousel-caption d-lg-block slide1-bg">
<h2 class="display-4 slide1-title" style="text-transform: uppercase; font-weight: bold;"></h2><br>
<p class="lead slide1 slide1-content"><i>TEXT for position</i><br>
BUTTON
</div>
</div>
</div>
</div>
</div>
<div class="carousel-arrow">
<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>
</div>

I am not sure if you want to center the text horizontally or vertically. So both answers:
Horizontally
The element you want to center .carousel-caption has a px width and margins in percentage.
You can either use percentage values only:
.carousel-caption {
width: 70%;
left: 15%;
}
or just make it full width, as all the contained text is centered:
.carousel-caption {
width: 100%;
left: 0px;
right:0px;
}
Vertically
.carousel-caption {
top: 50%;
bottom: auto;
transform: translateY(-50%);
}

Related

One html division being stacked over top of other

I am making a small webpage which is shown below . There is a footer at the end over which "Made with love by Vipul Tyagi" is written. The problem is that it is coming over the previous division(feedback form). No matter how much top property I apply to the footer, it is not moving down even a bit.
Please have a look at my code and help me to find the problem. You will find it at the very end in html just above </body> tag.
Thanks in advance!
$(document).ready(function() {
$("#notif-list li").click(function(e) {
var num = parseInt($("#notif-number").text());
$(this).remove();
$("#notif-number").html("" + num - 1 + "");
});
});
.container1 {
position: relative;
color: white;
}
.centered {
position: absolute;
top: 70%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
}
.fa-input {
font-family: FontAwesome, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.top-left {
position: absolute;
top: 30%;
left: 55%;
transform: translate(-50%, -50%);
}
.heading {
font-family: 'Orbitron', serif;
}
#headmain {
font-size: 50px;
position: relative;
left: -55px;
color: white;
}
#headsecondary {
position: relative;
right: 5%;
color: white;
}
#top-content {
position: relative;
top: 40px;
width: 100%;
background-color: #bbb;
padding: 10px;
}
a {
color: white;
}
.number {
position: absolute;
top: -5px;
right: -2px;
padding: 5px 10px;
border-radius: 30%;
background: green;
color: white;
}
.borderimg {
border-radius: 30%;
}
.carosel {
width: 670px;
}
.service-list {
font-family: 'Lobster', cursive;
font-size: 50px;
}
.labels {
font-size: 15px;
}
.login-box {
width: 320px;
height: 520px;
top: 290px;
background: rgba(0, 0, 0, 0.5);
color: #fff;
box-sizing: border-box;
padding: 70px 30px;
}
.login-box p {
margin: 0;
padding: 0;
font-weight: bold;
}
.login-box input {
width: 100%;
margin-bottom: 20px;
}
.login-box input[type="text"],
input[type="password"] {
border: none;
border-bottom: 1px solid #fff;
background: transparent;
outline: none;
height: 40px;
color: #fff;
font-size: 16px;
}
.login-box input[type="submit"] {
border: none;
outline: none;
height: 40px;
background: #1c8adb;
color: #fff;
font-size: 18px;
border-radius: 20px;
}
.login-box input[type="submit"]:hover {
cursor: pointer;
background: #39dc79;
color: #000;
}
.login-box a {
text-decoration: none;
font-size: 14px;
color: #fff;
}
.login-box a:hover {
color: #39dc79;
}
#media screen and (max-width: 450px) {
.carosel {
width: 300px;
}
.top-left {
position: absolute;
top: 35%;
left: 55%;
transform: translate(-50%, -50%);
}
#headmain {
font-size: 30px;
position: relative;
left: -20px;
color: white;
}
#headsecondary {
font-size: 20px;
position: relative;
right: 5%;
color: white;
}
#service-list {
font-family: 'Lobster', cursive;
font-size: 30px;
}
.login-box {
width: 300px;
height: 500px;
position: relative;
top: 50px;
background: rgba(0, 0, 0, 0.5);
color: #fff;
box-sizing: border-box;
padding: 70px 30px;
}
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet">
<style type="text/css">
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div>
<nav class="navbar navbar-inverse navbar-fixed-top" style="opacity: 0.9;top: 10px;">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="sankalpsoft.png" style="height: 30px; width: 30px;bottom : 10px;" /></a>
<a class="navbar-brand" href="#" style="color: white;" onMouseOver="this.style.color='yellow';" onMouseOut="this.style.color='white';">SankalpSoft</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">
About Us
</li>
<li>Why We?</li>
<li>Products</li>
<li>Services</li>
<li>Blogs</li>
<li>Contact Us</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: white;" onMouseOver="this.style.color='yellow';" onMouseOut="this.style.color='white';">Notification<span class="number" id="notif-number">4</span></a>
<ul class="dropdown-menu" id="notif-list">
<li style="padding: 10px 5px;">Notification 1</li>
<li style="padding: 10px 5px;">Notification 2</li>
<li style="padding: 10px 5px;">Notification 3</li>
<li style="padding: 10px 5px;">Notification 4</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container" style="width: 100%;padding-left: 0;padding-right: 0;">
<img src="https://i.postimg.cc/PpNsdrDS/back-img.jpg" alt="Snow" style="width: 100%;height: 350px;filter: grayscale(10%) brightness(60%) contrast(1);box-shadow: 5px 15px 8px #888888;">
<div class="top-left">
<h1 class="heading" id="headmain">SankalpSoft Solutions</h1>
<h3 class="heading" id="headsecondary">We Provide intelligent business support</h3>
</div>
</div>
</div>
<div class="container carosel" style="height: 340px;top: 40px;">
<h2 style="text-align: center;" class="service-list">Services We provide</h2>
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="3000" style="box-shadow: 20px 10px 8px #888888;border-radius: 10%;">
<!-- 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>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active borderimg">
<img src="https://i.postimg.cc/kVQDWsY0/business.jpg" alt="business" style="width:100%;">
</div>
<div class="item borderimg">
<img src="https://i.postimg.cc/XGnqL5Tp/outsourcing.jpg" alt="outsourcing" style="width:100%;">
</div>
<div class="item borderimg">
<img src="ttps://i.postimg.cc/dDLwYnmJ/webdevelopment.jpg" alt="webdevelopment" style="width:100%;">
</div>
<div class="item borderimg">
<img src="https://i.postimg.cc/K1T6YHRy/applicationdevelopment.png" alt="applicationdevelopment" style="width:100%;">
</div>
<div class="item borderimg">
<img src="https://i.postimg.cc/gn105QC9/customersupport.jpg" alt="customersupport" style="width:100%;">
</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="container login-box" style="position: relative;border-radius: 10%;">
<h1 class="login service-list" style="text-align: center;">Feedback here</h1>
<p class="login service-list labels">Name</p>
<input type="text" name="Name" placeholder="" id="usernm" required>
<p class="login service-list labels">Contact No</p>
<input type="password" name="password" placeholder="" id="contact" required>
<p class="login service-list labels">Message</p>
<input type="text" name="message" placeholder="" id="msg" required>
<input class="service-list" type="submit" name="submit" value="Submit" id="signupbut" class="login"></input>
</div>
<div class="container footer" style="position: relative;background-color: black;width: 100%;margin: 0;padding: 10px;">
<p style="color: white; font-size: 20px;text-align: center;">Made with <span>❤</span> by Vipul Tyagi</p>
</div>
</body>
</html>
EDIT
Although I have found the solution, but I still don't understand what was the issue? I have never seen such behaviour with top prperty!
Wrap your footer around a footer tag and use that tag to adjust the position on your page. The inline css i used is
margin-top: 50%;
I've added a js fiddle for you as well. Take a look at this link:https://jsfiddle.net/zfhassaan/5syxnme1/1/
In the style of class="container footer" , you have used position as relative. So, you can add top: some pixels (for eg: top: 200px) to your style, to keep the footer where ever you want.
For reference: https://www.w3schools.com/css/css_positioning.asp

Gaps/Spaces on left and right of nav and carousel in mobile

I'm using bootstrap 3.3.7. I've adapted the navbar template provided from the bootstrap documentation and a carousel from W3. My footer's width extends all the way to the side edges but my carousel and nav do not (in fact my carousel does not even extend to the same width as my nav). How do I fix this?
Image of problem:
#charset "UTF-8";
* {
margin: 0;
}
html body {
height: 100%;
}
.nopadding {
padding: 0;
}
.navbar {
background-color: #ff8300;
border-radius: 0 0 10px 10px;
border: 0;
height: 100px;
width: 100%;
max-width: 980px;
margin: 0 auto;
}
.navspace {
right: 50px;
margin-top: 25px;
position: relative;
font-size: 18px;
color: #fff;
}
.navbar-brand {
padding: 0;
position: relative;
left: 40px;
top: 10px;
}
.thumbnails {
position: relative;
margin-top: 150px;
}
#myCarousel {
width: 980px;
max-width: 100%;
height: 654px;
bottom: 25px;
border-radius: 0 0 10px 10px;
}
.carousel-control {
height: 600px;
opacity: 0;
border-radius: 0 0 10px 10px;
}
.banner {
background: url(../images/banner1.jpg) no-repeat top center;
background-size: cover;
width: 980px;
height: 654px;
background-size: 100% auto;
}
.banner2 {
background: url(../images/banner2.jpg) no-repeat top center;
background-size: cover;
width: 980px;
height: 654px;
background-size: 100% auto;
}
.banner3 {
background: url(../images/banner3.jpg) no-repeat top center;
background-size: cover;
width: 980px;
height: 654px;
background-size: 100% auto;
}
.banner p {
position: relative;
font-size: 25px;
color: #fff;
top: 440px;
left: 20px;
}
.banner h1 {
position: relative;
font-size: 50px;
color: #fff;
left: 20px;
top: 420px;
}
.bodyimg {
max-width: 100%;
}
.bodytext1 {
color: #ff8300;
}
.bodytext2 {
color: #ff8300;
width: 160px;
margin-top: 37px;
}
.bodytext3 {
color: #ff8300;
margin-top: 60px
}
.bodytext4 {
color: #ff8300;
margin-top: 60px
}
.socialpadding {
padding: 0px 10px 0px 10px;
position: relative;
}
.centersocial {
margin: 0 auto;
text-align: center;
position: absolute;
}
.contactinfo {
color: #ff8300;
margin: 200px 0px 0px auto;
}
/* Add a background color and some padding around the form */
.formarea {
background-color: #ff8300;
border-radius: 10px;
width: 400px;
height: 484px;
margin: 50px auto 0px auto;
padding: 15px;
}
.formlabel {
color: #fff;
}
#inputMessage {
height: 200px;
}
.btn {
background-color: #fcb972;
border-color: #ff9300;
margin-top: 20px;
}
.btn:hover {
background-color: #fff;
border-color: #ff9300;
color: #ff8300;
}
.btn:onclick {
background-color: #fff;
border-color: #ff9300;
color: #ff8300;
}
.messageform {
height: 50px;
}
.google-maps {
position: relative;
padding-bottom: 75%;
height: 0;
overflow: hidden;
margin-top: 50px;
}
.google-maps iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.formarea2 {
background-color: #fff;
border-radius: 10px;
width: 400px;
height: 50px;
margin: 50px auto 0px auto;
padding: 15px;
display: inline;
text-align: center;
}
#inputPostal {
display: inline-block;
width: 30%;
margin-left:3%;
}
.formpostal {
color: #ff8300;
font-size: 30px;
display: inline-block;
}
.menubg {
background-color: #ff8300;
height: 100%;
width: 100%;
max-width: 980px;
border-radius: 10px;
margin: 125px;
}
.col-centered {
float: none;
margin-right: auto;
margin-left: auto;
}
.cartbtn {
margin-top: 20px;
position: relative;
left: 96%;
}
h2 {
font-size: 24px;
color: #fff;
text-align: center;
margin-top: 30px;
}
.menubox {
background-color: #fff;
border-radius: 10px;
width: 321px;
height: 320px;
margin-top: 30px;
position: relative;
}
.menubox a {
text-decoration: none;
}
.item1 {
background: url(../images/menu1.jpg) no-repeat center;
border-radius: 10px 10px 0px 0px;
}
.menubox img {
border-radius: 10px 10px 0px 0px;
opacity: 0;
transition: .5s ease;
backface-visibility: hidden;
}
.menubox:hover .item1 {
opacity: 0.7;
transition: .5s ease;
}
.menubox:hover img {
opacity: 1;
transition: .5s ease;
}
h3 {
font-size: 16;
color: #ff8300;
}
.foot {
background-image: none;
background-color: #ff8300;
border-radius: 10px 10px 0 0;
height: 50px;
margin: 150px auto 0 auto;
position: absolute;
width: 100%;
max-width: 980px;
left: 50%;
transform: translate(-50%, -50%);
overflow: hidden;
}
footer {
position: relative;
color: #fff;
text-align: right;
margin-top: 30px;
font-size: 10px;
width: 100%;
max-width: 980px;
}
#media only screen and (max-width: 992px) {
.navbar {
background-image: none;
background-color: #ff8300;
width: 100%;
border-radius: 0px;
margin: 0;
}
.navspace {
padding: 0px 20px 0px 0px;
left: 120px;
top: 30px;
}
.navbar-collapse {
background: rgba(255, 255, 255, 0.75);
height: 300px;
}
.foot {
background-image: none;
background-color: #ff8300;
border-radius: 0;
overflow: hidden;
}
footer {
position: relative;
color: #fff;
display: block;
text-align: right;
font-size: 10px;
}
.contactinfo {
margin: 40px auto 0px auto;
text-align: center;
}
}
#media only screen and (max-width: 767px) {
#myCarousel.carousel {
max-width: 100%;
width: 100%;
max-height: 100%;
overflow: hidden;
border-radius: 0 0 10px 10px;
}
.carousel-control {
height: 600px;
opacity: 0;
}
.findus {
margin: 0 auto;
}
.centersocial {
position: relative;
}
.bodytext4 {
text-align: center;
width: 250px;
margin: 100px auto 5px auto;
}
.bodytext3 {
text-align: center;
width: 250px;
margin: 60px auto 5px auto;
}
}
#media only screen and (max-width: 576px) {
.formarea {
background-color: #ff8300;
border-radius: 10px;
width: 350px;
height: 484px;
margin: 50px auto 0px auto;
padding: 15px;
}
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
/* additional */
.row, #myCarousel, .container {
max-width: 100%;
margin: 0 auto;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Peperoni Pizzeria</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/styles.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<nav class="navbar navbar-default navbar-static-top rounded-bottom">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><img src="images/logo.png" alt=""></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a class="navspace" href="index.html">Home</a></li>
<li><a class="navspace" href="menu.html">Menu</a></li>
<li><a class="navspace" href="location.html">Locations</a></li>
<li><a class="navspace" href="contactus.html">Contact Us</a></li>
<!-- Put here your menu items -->
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>
<div class="row">
<div class="col-sm-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- 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>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active banner">
<p>10% off all pizzas
<br>this weekend only</p>
<h1>LIMITED TIME<br>ONLY</h1>
</div>
<div class="item banner2">
</div>
<div class="item banner3">
</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="row thumbnails">
<div class="col-sm-offset-1 col-sm-3">
<img class="img-responsive center-block img-rounded" src="images/bodyimg.jpg" alt="">
</div>
<div class="col-md-offset-1 col-md-3 hidden-sm hidden-xs">
<p class="bodytext1">
Year 2004.<br><br> The warmth and comfort of wood-fired pizzas and traditional pastas over chilled drinks with friends and families became an everyday affair that started with the first Peperoni, located in Greenwood Singapore. Charming, vivacious
and full of life, Peperoni Greenwood brings together food lovers from all walks of life. Including many well known and young artists whose work adorn its walls with their expressions of love and creativity. Peperoni Greenwood inspired its owners,
the highly acclaimed Les Amis group, to spread the love and energy of Peperoni with the opening of new outlets across the sunny island of Singapore.
</p>
</div>
<div class="col-md-offset-1 col-md-3 hidden-xs">
<p class="bodytext2">
Peperoni has since evolved into a much-loved destination with its ‘Appetite for Life’ philosophy. This philosophy makes Peperoni more than just a restaurant, as it is a place with a mission - to bring people together, to bind relationships, and to savour
life in all its delightful flavours.<br><br> Share moments of fun, energy and inspiration over hot pizzas and cool conversations!
</p>
</div>
</div>
<div class="row">
<div class="col-sm-offset-1 col-sm-3">
<p class="bodytext3">
Check us out on our social media accounts or subscribe to our newsletter for the latest updates!
</p>
<div class="centersocial">
<a href="#"><img class="socialpadding" src="images/email.png" alt="">
</a>
<a href="https://www.instagram.com/peperonipizzeria/"><img class="socialpadding" src="images/insta.png" alt="">
</a>
<a href="https://www.facebook.com/peperonipizzeria/"><img class="socialpadding" src="images/fb.png" alt="">
</a>
</div>
</div>
<div class="col-sm-offset-1 col-sm-3">
<p class="bodytext4">
Feel free to come explore our outlets
</p>
<a href="locations.html"><img class="findus img-responsive" src="images/findus.png" alt="">
</a>
</div>
</div>
<div class="row">
<div class="col-sm-12 foot img-responsive">
<footer class"navbar-fixed-bottom">
Copyright © 2017 Peperoni Pizzeria. All Rights Reserved.
</footer>
</div>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

Media query to shrink Bootstrap carousel

I am using Bootstrap version 4.0.0-beta and I am using the carousel function. I have configured it perfectly as to how I need it when I view it on my monitor. (1920 x 1200) but would like to change it's height depending on the users monitor, for example 1920 x 1080. I have given my Carousel a height of 32rem but would like to decrease that size if a user is on a smaller screen like I said. I believe a media query is what I need but I have tried and can't figure it out. Can anyone shine some light on this please?
Thanks.
Managed to solve it on my own. Just used this.
#media screen and (max-height: 1000px) {
.carousel-item {
height: 24rem;
}}
Please try the sample below and let me know if its worked.
.img-responsive,
.thumbnail>img,
.thumbnail a>img,
.carousel-inner>.item>img,
.carousel-inner>.item>a>img {
display: block;
width: 100%;
height: auto;
}
.carousel-inner {
border-radius: 15px;
}
.carousel-caption {
background-color: rgba(0, 0, 0, .5);
position: absolute;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
padding: 0 0 10px 25px;
color: #fff;
text-align: left;
}
.carousel-indicators {
position: absolute;
bottom: 0;
right: 0;
left: 0;
width: 100%;
z-index: 15;
margin: 0;
padding: 0 25px 25px 0;
text-align: right;
}
.carousel-control.left,
.carousel-control.right {
background-image: none;
}
.carousel-containers {
padding: 10px 0;
}
.carousel-containers {
background-color: #fff;
color: #555;
}
#media screen and (min-width: 768px) {
.carousel-containers {
padding: 1.5em 0;
}
}
#media screen and (min-width: 992px) {
.container {
max-width: 930px;
}
}
<div class="carousel-containers">
<div class="container">
<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="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</div>
<div class="item">
<img src="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</div>
<div class="item">
<img src="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</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>
</div>
</div>

How to assign fixed background-image with respect to a div?

I have used fixed background images in my carousel of website made with bootstrap. The background images are fixed to show the parallaxing effect. But the problem is the when new slides of carouslel move to left the image already present there remains fixed. What I want is that the background image on a div move when the div moves with css transition effects.
I want this type of carousel http://www.w3schools.com/bootstrap/bootstrap_carousel.asp In other words I want the next item to push the background image of active item to the left. At present when the next item slides to the left it opaques the current item's background image.
The code is as following:
var mq = window.matchMedia("(max-width: 320px)");
var mylogo = document.getElementById("mylogo");
if (mq.matches) {
mylogo.innerHTML = "SSR";
}
function changelogo() {
return function() {
if (mq.matches) {
mylogo.innerHTML = "SSR";
} else {
mylogo.innerHTML = "Syco Scientist Records"
}
}
}
window.onresize = changelogo();
if (window.matchMedia("(max-height: 420px)").matches) {
for (var n = 0; n < 5; n++) {
document.getElementsByClassName("item")[n].style.backgroundSize = "100% calc(100% - 140px)";
}
}
.navbar {
min-height: 60px;
border-color: #333;
background-color: #d6d5d5;
margin-bottom: 0;
}
.navbar .navbar-header .navbar-brand {
height: 60px;
padding: 20px 15px;
color: #333;
font-family: Raleway;
font-weight: bold;
font-style: italic;
}
.navbar .navbar-header .navbar-toggle {
margin-top: 14px;
border-color: #d5d5d5;
}
.navbar .navbar-header .navbar-toggle > .icon-bar {
background-color: #333;
}
.navbar ul.navbar-nav {
margin-bottom: 0;
}
.navbar ul.nav > li > a {
height: 60px;
font-size: 14px;
line-height: 20px;
padding: 20px 15px;
color: #333;
text-align: center;
}
.navbar ul.nav > li > a:hover {
color: #333;
background-color: #e7e7e7;
}
.navbar ul.nav > li.active > a,
.navbar ul.nav > li.active:hover > a {
background-color: #333;
color: #d6d5d5;
}
#home {
background-color: #333;
z-index: 6;
}
.carousel {
width: 100%;
height: 100vh;
min-height: 420px;
}
.mobile-carousel {
padding-top: 100px;
height: 100%;
padding-bottom: 40px;
}
.carousel-inner {
height: 100%;
}
.carousel-inner .item {
height: 100%;
-webkit-transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
}
.carousel-inner .item img {
display: block;
width: 100%;
height: 568px;
height: 100%;
}
.carousel-inner .first {
width: 100%;
margin: auto;
background: url(http://2.bp.blogspot.com/_OdCx7pACI9M/TQhDqhnKXgI/AAAAAAAAAH8/kPDpkHpFOnw/s1600/daffy+duck+cartoons+pictures+1.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .second {
width: 100%;
margin: auto;
background: url(http://www.allgraphics123.com/graphics/cartoons/cartoons123.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .third {
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/211/WDF_2483525.png) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .fourth {
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/109/WDF_1525343.jpg) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-control span {
left: 50%;
position: absolute;
top: 50%;
}
.carousel-control span img {
position: absolute;
top: -36px;
left: -9px;
}
.carousel-indicators {
bottom: 0px;
margin-bottom: 0;
}
.carousel-indicators li {
background-color: #777;
border: 0;
}
.carousel-indicators li.active {
background-color: #dcdbdb;
margin: 1px;
width: 10px;
height: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Syco Scientist Records</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#" id="mylogo"> Syco Sientist Records </a>
<button class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home
</li>
<li>Artists
</li>
<li>Songs
</li>
<li>Beats
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
<section id="home">
<div id="mycarousel" class="carousel slide">
<div class="container-fluid mobile-carousel">
<div class="carousel-inner">
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
</ol>
<div class="item active first"></div>
<div class="item second"></div>
<div class="item third"></div>
<div class="item fourth"></div>
<a href="#mycarousel" class="left carousel-control" data-slide="prev">
<span aria-hidden="true"><img src="images/left_Arrow.png"></span>
<span class="sr-only">Previous</span>
</a>
<a href="#mycarousel" class="right carousel-control" data-slide="next">
<span aria-hidden="true"><img src="images/right_arrow.png"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
How do I acheive this?
Edit: It seems like the problem is only in firefox browser. Please explain why it works in chrome browser and not in firefox browser.
I tried like this . carousel next item will appear on previous item after that the background image of active item to the left
var mq = window.matchMedia("(max-width: 320px)");
var mylogo = document.getElementById("mylogo");
if (mq.matches) {
mylogo.innerHTML = "SSR";
}
function changelogo() {
return function() {
if (mq.matches) {
mylogo.innerHTML = "SSR";
} else {
mylogo.innerHTML = "Syco Scientist Records"
}
}
}
window.onresize = changelogo();
if (window.matchMedia("(max-height: 420px)").matches) {
for (var n = 0; n < 5; n++) {
document.getElementsByClassName("item")[n].style.backgroundSize = "100% calc(100% - 140px)";
}
}
.navbar {
min-height: 60px;
border-color: #333;
background-color: #d6d5d5;
margin-bottom: 0;
}
.navbar .navbar-header .navbar-brand {
height: 60px;
padding: 20px 15px;
color: #333;
font-family: Raleway;
font-weight: bold;
font-style: italic;
}
.navbar .navbar-header .navbar-toggle {
margin-top: 14px;
border-color: #d5d5d5;
}
.navbar .navbar-header .navbar-toggle > .icon-bar {
background-color: #333;
}
.navbar ul.navbar-nav {
margin-bottom: 0;
}
.navbar ul.nav > li > a {
height: 60px;
font-size: 14px;
line-height: 20px;
padding: 20px 15px;
color: #333;
text-align: center;
}
.navbar ul.nav > li > a:hover {
color: #333;
background-color: #e7e7e7;
}
.navbar ul.nav > li.active > a,
.navbar ul.nav > li.active:hover > a {
background-color: #333;
color: #d6d5d5;
}
#home {
background-color: #333;
z-index: 6;
}
.carousel {
width: 100%;
height: 100vh;
min-height: 420px;
}
.mobile-carousel {
padding-top: 100px;
height: 100%;
padding-bottom: 40px;
}
.carousel-inner {
height: 100%;
}
.carousel-inner .item {
height: 100%;
-webkit-transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
}
.carousel-inner .item img {
display: block;
width: 100%;
height: 568px;
height: 100%;
}
.carousel-inner .first {
width: 100%;
margin: auto;
background: url(http://2.bp.blogspot.com/_OdCx7pACI9M/TQhDqhnKXgI/AAAAAAAAAH8/kPDpkHpFOnw/s1600/daffy+duck+cartoons+pictures+1.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
backface-visibility: visible !important;
-webkit-backface-visibility: visible !important;
transform: none !important;
-webkit-transform: none !important;
}
.carousel-inner .second {
width: 100%;
margin: auto;
background: url(http://www.allgraphics123.com/graphics/cartoons/cartoons123.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
backface-visibility: visible !important;
-webkit-backface-visibility: visible !important;
transform: none !important;
-webkit-transform: none !important;
}
.carousel-inner .third {
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/211/WDF_2483525.png) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
backface-visibility: visible !important;
-webkit-backface-visibility: visible !important;
transform: none !important;
-webkit-transform: none !important;
}
.carousel-inner .fourth {
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/109/WDF_1525343.jpg) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
backface-visibility: visible !important;
-webkit-backface-visibility: visible !important;
transform: none !important;
-webkit-transform: none !important;
}
.carousel-control span {
left: 50%;
position: absolute;
top: 50%;
}
.carousel-control span img {
position: absolute;
top: -36px;
left: -9px;
}
.carousel-indicators {
bottom: 0px;
margin-bottom: 0;
}
.carousel-indicators li {
background-color: #777;
border: 0;
}
.carousel-indicators li.active {
background-color: #dcdbdb;
margin: 1px;
width: 10px;
height: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Syco Scientist Records</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#" id="mylogo"> Syco Sientist Records </a>
<button class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home
</li>
<li>Artists
</li>
<li>Songs
</li>
<li>Beats
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
<section id="home">
<div id="mycarousel" class="carousel slide">
<div class="container-fluid mobile-carousel">
<div class="carousel-inner">
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
</ol>
<div class="item active first"></div>
<div class="item second"></div>
<div class="item third"></div>
<div class="item fourth"></div>
<a href="#mycarousel" class="left carousel-control" data-slide="prev">
<span aria-hidden="true"><img src="images/left_Arrow.png"></span>
<span class="sr-only">Previous</span>
</a>
<a href="#mycarousel" class="right carousel-control" data-slide="next">
<span aria-hidden="true"><img src="images/right_arrow.png"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
You can just add this css :
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Syco Scientist Records</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
div#mycarousel .carousel-inner .item{
padding:0 10%;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#" id="mylogo"> Syco Sientist Records </a>
<button class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home
</li>
<li>Artists
</li>
<li>Songs
</li>
<li>Beats
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
<section id="home">
<div id="mycarousel" class="carousel slide">
<div class="container-fluid mobile-carousel">
<div class="carousel-inner">
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
</ol>
<div class="item active first"><img src="http://blog.allisonjoyce.com/wp-content/uploads/2014/02/ablog186.jpg"></div>
<div class="item second"><img src="https://i.ytimg.com/vi/MLqHuAXasTY/maxresdefault.jpg"></div>
<div class="item third"><img src="http://blog.allisonjoyce.com/wp-content/uploads/2014/02/ablog186.jpg"></div>
<div class="item fourth"><img src=""><img src="http://www.monopolycity.com/acimages/ac_beach_21_560.gif"></div>
<a href="#mycarousel" class="left carousel-control" data-slide="prev">
<span aria-hidden="true"><i class="glyphicon glyphicon-chevron-left"></i></span>
</a>
<a href="#mycarousel" class="right carousel-control" data-slide="next">
<span aria-hidden="true"><i class="glyphicon glyphicon-chevron-right"></i></span>
</a>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
But the problem is the when new slides of
carouslel move to left the image already present there remains fixed.
What I want is that the background image on a div move when the div
moves with css transition effects.
In Chrome - Your provided demo is already working as you want.
But in FireFox the issue is seen. The issue is because you are using fixed on the images which will keep it fixed, Removing this worked as required in Firefox too.
background: url(..) no-repeat fixed; // remove fixed
Edit 1: As you said removing fixed will break parallax effect you can do this way.
Add another div inside the .item div and add image to this div. So now we have a inner div with fixed image, But outer div is free to move.
Below is a working sample
var mq = window.matchMedia("(max-width: 320px)");
var mylogo = document.getElementById("mylogo");
if (mq.matches) {
mylogo.innerHTML = "SSR";
}
function changelogo() {
return function() {
if (mq.matches) {
mylogo.innerHTML = "SSR";
} else {
mylogo.innerHTML = "Syco Scientist Records"
}
}
}
window.onresize = changelogo();
if (window.matchMedia("(max-height: 420px)").matches) {
for (var n = 0; n < 5; n++) {
document.getElementsByClassName("item")[n].style.backgroundSize = "100% calc(100% - 140px)";
}
}
.navbar {
min-height: 60px;
border-color: #333;
background-color: #d6d5d5;
margin-bottom: 0;
}
.navbar .navbar-header .navbar-brand {
height: 60px;
padding: 20px 15px;
color: #333;
font-family: Raleway;
font-weight: bold;
font-style: italic;
}
.navbar .navbar-header .navbar-toggle {
margin-top: 14px;
border-color: #d5d5d5;
}
.navbar .navbar-header .navbar-toggle > .icon-bar {
background-color: #333;
}
.navbar ul.navbar-nav {
margin-bottom: 0;
}
.navbar ul.nav > li > a {
height: 60px;
font-size: 14px;
line-height: 20px;
padding: 20px 15px;
color: #333;
text-align: center;
}
.navbar ul.nav > li > a:hover {
color: #333;
background-color: #e7e7e7;
}
.navbar ul.nav > li.active > a,
.navbar ul.nav > li.active:hover > a {
background-color: #333;
color: #d6d5d5;
}
#home {
background-color: #333;
z-index: 6;
}
.carousel {
width: 100%;
height: 100vh;
min-height: 420px;
}
.mobile-carousel {
padding-top: 100px;
height: 100%;
padding-bottom: 40px;
}
.carousel-inner {
height: 100%;
}
.carousel-inner .item, .carousel-inner .item > div {
height: 100%;
-webkit-transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
transition-timing-function: cubic-bezier(.71, -0.06, .36, 1.35);
}
.carousel-inner .item img {
display: block;
width: 100%;
height: 568px;
height: 100%;
}
.carousel-inner .first > div {
width: 100%;
margin: auto;
background: url(http://2.bp.blogspot.com/_OdCx7pACI9M/TQhDqhnKXgI/AAAAAAAAAH8/kPDpkHpFOnw/s1600/daffy+duck+cartoons+pictures+1.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .second > div{
width: 100%;
margin: auto;
background: url(http://www.allgraphics123.com/graphics/cartoons/cartoons123.gif) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .third > div{
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/211/WDF_2483525.png) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-inner .fourth > div{
width: 100%;
margin: auto;
background: url(http://pic.1fotonin.com/data/wallpapers/109/WDF_1525343.jpg) no-repeat fixed;
background-position: center 100px;
background-size: 100% calc(100% - 140px);
background-clip: content-box;
}
.carousel-control span {
left: 50%;
position: absolute;
top: 50%;
}
.carousel-control span img {
position: absolute;
top: -36px;
left: -9px;
}
.carousel-indicators {
bottom: 0px;
margin-bottom: 0;
}
.carousel-indicators li {
background-color: #777;
border: 0;
}
.carousel-indicators li.active {
background-color: #dcdbdb;
margin: 1px;
width: 10px;
height: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Syco Scientist Records</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#" id="mylogo"> Syco Sientist Records </a>
<button class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home
</li>
<li>Artists
</li>
<li>Songs
</li>
<li>Beats
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
<section id="home">
<div id="mycarousel" class="carousel slide">
<div class="container-fluid mobile-carousel">
<div class="carousel-inner">
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
</ol>
<div class="item active first"><div></div></div>
<div class="item second"><div></div></div>
<div class="item third"><div></div></div>
<div class="item fourth"><div></div></div>
<a href="#mycarousel" class="left carousel-control" data-slide="prev">
<span aria-hidden="true"><img src="images/left_Arrow.png"></span>
<span class="sr-only">Previous</span>
</a>
<a href="#mycarousel" class="right carousel-control" data-slide="next">
<span aria-hidden="true"><img src="images/right_arrow.png"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
background: url(../img/fav.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
height: 500px;
Set the height to your image like heigth:500px; or you can use padding:50px 0; else it will not display your image on the background until you write anything on that particular div.

Positioning elements inside bootstrap carousel

I'm trying to put a down chevron to my carousel but the chevron appears outside of the carousel container. I want to have something like this :
http://www.yummygum.com
my HTML code:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-rounded" src="images/biz%20bznner.png" alt="First slide">
<div class="container ccontainers">
<div class="carousel-caption">
<h1 class="animated rubberBand 1">You have a project? Let Us Do it for you</h1>
<h3 class="animated bounceInLeft">We will do your projects with the best prices</h3>
<p><a class="btn btn-lg btn-primary animated shake 1" href="#" role="button">Sign up today</a></p>
</div>
</div>
</div>
</div>
<a class="chevron-down" href="#myCarousel" role="button">
<span class="glyphicon glyphicon-chevron-down" aria-hidden"true"></span>
</a>
</div>
my CSS:
.carousel-control.right, .carousel-control.left {
background-image: none;
}
.carousel .item {
height: 100vh;
margin-bottom: 60px;
}
.carousel {
height: 100vh;
width:100%;
}
.carousel-caption {
z-index: 10;
margin-top: 0%;
margin-bottom: 5%;
}
.carousel-caption h3 {
padding: 0.5em;
animation-delay: 0.5s;
}
.chevron-down{
**margin-bottom:100px** //THIS DOES NOT WORK
margin-left: 50%;
font-size: 30px;
}
.carousel-caption a{
background-color: orangered;
border-color: darkred;
margin-top: 1em;
animation-delay: 2s;
}
.carousel-caption h1 {
text-align: center;
margin-bottom: 30px;
font-size: 30px;
font-weight: bold;
animation-delay: 0s;
}
.carousel-inner > .item > img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: 100vh;
}
so in the .chevron-down class margin left works but when I try to vertically move the chevron it does not do anything.. what is the correct way of doing this?
You can do something like this:
.chevron-down {
font-size: 30px;
position: relative;
bottom: 100px;
}
CODEPEN