Materialize parallax scrolling resize in mobile view? - html

I am having issues with my .parallax CSS class that is done default by the framework it's not resizing like my main image when it comes to mobile view. It works well with a desktop view. They move more to the left the last two images is there a possibility to move them more center? I tried to center them using position: no-repeat fixed center; in CSS or using frameworks default parameters.
https://i.imgur.com/itVR3No.jpg
The image goes off to the left and does not center.
$(document).ready(function() {
$('.parallax').parallax();
});
.ha-bg-parallax {
background: url(https://i.imgur.com/YqK1Oeu.jpg) no-repeat fixed center;
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
height: 100vh;
margin: 0 auto;
width: 100%;
display: table;
vertical-align: middle;
}
.parallax{
position: no-repeat fixed center;
max-width:100%;
}
.ha-bg-parallax .ha-parallax-body {
display: table-cell;
vertical-align: middle;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<div class="navbar-fixed">
<nav class="blue darken-1">
</nav>
</div>
<div class="ha-bg-parallax text-center block-marginb-none" data-speed="20" data-type="background">
<div class="ha-parallax-body">
<div class="section scrollspy row title" id="home">
</div>
</div>
</div>
<div class="section light-blue lighten-5">
<div class="row container">
<div class="section scrollspy" id="info">
</div>
</div>
</div>
<div class="parallax-container">
<div class="parallax"><img alt="header1" src="https://i.imgur.com/QFPutVs.jpg"></div>
</div>
<div class="section light-blue lighten-5">
<div class="section scrollspy" id="portfolio">
</div>
<!--row for parallax-->
</div>
<div class="parallax-container">
<div class="parallax"><img alt="header2" src="https://i.imgur.com/gyYRcBK.jpg"></div>
</div>
<!--Floating Action Button custumize-->
<footer class="page-footer blue darken-1">
<div class="col l4 offset-l2 s12 container center">
<div class="section scrollspy" id="links">
</div>
</div>

Related

Div not being centered when using margin: auto; (Bootstrap)

I have a working example website from the bootstrap template website and was analysing the code to understand how they created it. Namely how they centered the text on the first page located here. The code for that snipplet is,
<header class="masthead text-center text-white d-flex"> <!-- Background image set here -->
<div class="container m-auto">
<div class="row">
<div class="col-lg-10 mx-auto">
...
</div>
<div class="col-lg-8 mx-auto">
...
</div>
</div>
</div>
</header>
So then I noticed that the m-auto was doing the centering. However, when I attempt to create it from scratch for myself and create this basic code,
<style>
#frontpage {
height: 100vh;
width: 100vw;
}
</style>
<section id="frontpage">
<div class="container m-auto">
<div class="row">
<div class="col-8">
<h1> YOU CAN DO IT </h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
It doesn't center at all.
What am I forgetting here?
I would suspect that the container gets centered inside it's parent, which takes up the page.
you have copied the code but styles not included for them if guess correctly. anyway, I have corrected please try this one.
<style>
#frontpage {
height: 100vh;
width: 100%;
}
.center-me{
margin: auto;
width: 60%;
text-align: center;
}
</style>
<section id="frontpage">
<div class="center-me">
<div >
<h1> YOU CAN DO IT </h1>
</div>
<div >
<h1> I should be centered </h1>
</div>
</div>
</section>
Is this what you're after?
Version 1
https://codepen.io/panchroma/pen/YdEWZJ
HTML
<section id="frontpage">
<div class="container m-auto">
<div class="row">
<div class="col-8">
<h1> YOU CAN DO IT </h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
CSS
#frontpage{
background-color:pink;
height: 100vh;
width: 100vw;
}
.col-8{
border:1px solid grey;
margin-left:auto !important;
margin-right:auto !important;
text-align:center;
}
Version 2
This also centers the text vertically
https://codepen.io/panchroma/pen/KbygzX
HTML
<section id="frontpage">
<div class="container m-auto">
<div class="row vert-align">
<div class="col-8">
<h1>YOU CAN DO IT</h1>
</div>
<div class="col-8">
<h1> I should be centered </h1>
</div>
</div>
</div>
</section>
CSS
#frontpage{
background-color:pink;
height: 100vh;
width: 100vw;
}
.col-8{
margin-left:auto !important;
margin-right:auto !important;
text-align:center;
}
.row.vert-align{
position: absolute;
top: 50%;
left:50%;
-ms-transform: translateY(-50%);
transform: translate(-50%, -50%);
}

Jumbotron background image is not responsive

When I am viewing the page on desktop, it's working fine and the image is responsive. When I am viewing the page directly on an iPhone, the image is not correct.
Index.html
<header>
<div class="jumbotron">
<div class="container" id="maincontent" tabindex="-1">
<div class="row">
<div class="col-lg-12">
<div class="intro-text">
<h1 class="name">Headline</h1>
<hr class="star-light">
<span class="skills">Sub-header</span>
</div>
</div>
</div>
</div>
</div>
</header>
Style.css (freelance.css)
.jumbotron {
background: url("http://vlastapolach.cz/img/expecto.jpg") no-repeat fixed;
background-size: cover;
background-position: top center;
height: auto;
}
Full code is here: https://github.com/vlastapolach/portfolio
I have tried these, but it is not working correctly on desktop either.
background-size: contain;
background-size: auto;
background-size: 100% 100%;
The shorthand syntax holds background-size to fixed. I have remove the fixed.
.jumbotron {
background: url("http://vlastapolach.cz/img/expecto.jpg") no-repeat;
background-size: cover;
background-position: top center;
height: auto;
width:100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<header>
<div class="jumbotron">
<div class="container" id="maincontent" tabindex="-1">
<div class="row">
<div class="col-lg-12">
<div class="intro-text">
<h1 class="name">Headline</h1>
<hr class="star-light">
<span class="skills">Sub-header</span>
</div>
</div>
</div>
</div>
</div>
</header>

Boostrap Responsive Design Grid Issue

I am building the front end of my website in bootstrap 4. I'd like one of my pages to be split into four background images each of which fills a column so that the columns stack responsively on mobile. As of now, I have the design below where I use the background-image attribute to fill each column. The images do not fill the whole column though.
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<div class="img img-profile-1">
</div>
</div>
<div class="col-md-3">
<div class="img img-profile-2" >
</div>
</div>
<div class="col-md-3">
<div class="img img-profile-3" >
</div>
</div>
<div class="col-md-3 text-center">
<div class="img img-profile-4">
</div>
</div>
</div>
</div>
I added the css below to the div within each column and got the full image to show but there is a strange scrolling issue and white space when I make the viewport smaller.
.img-profile-1 {
background-image: url('../img/image.jpg') !important;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 100%;
height: 100%;
margin-left: -15px;
margin-right: -15px;
}
Any ideas how to get handle this responsive vs background image dilemma?
Thanks!
You don't have to add another <div> inside the .col-md-3 in order to give it a background, instead you can just give that same <div> the class of .img-profile-1 and so on.
Bootstrap 4 also adds a cool class to where it removes all white spaces between each .col, it is called .no-gutters. You can view that on the snip below.
.img-profile-1,
.img-profile-3 {
background-image: url('http://placehold.it/500/aaaaaa/000000');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 300px;
}
.img-profile-2,
.img-profile-4 {
background-image: url('http://placehold.it/500/000000/ffffff');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 300px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="container-fluid">
<div class="row no-gutters">
<div class="col-md-3 img img-profile-1">
</div>
<div class="col-md-3 img img-profile-2">
</div>
<div class="col-md-3 img img-profile-3">
</div>
<div class="col-md-3 text-center img img-profile-4">
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
</body>
Instead of setting the width and height in your css for the div, try adding class img-fluid to the image tag.
Here is the fix
If you add col-md-3 or any other column in bootstap it take right padding and left padding of 15px so that inner content will no cover full width. To cover full width we need to add another div with class row below the column so that inner content will be made to cover full width
Fixed code is given below
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<div class="row">
<div class="img img-profile-1">
</div>
</div>
</div>
<div class="col-md-3">
<div class="row">
<div class="img img-profile-2" >
</div>
</div>
</div>
<div class="col-md-3">
<div class="row">
<div class="img img-profile-3" >
</div>
</div>
</div>
<div class="col-md-3 text-center">
<div class="row">
<div class="img img-profile-4">
</div>
</div>
</div>
</div>
</div>

Image slider with stacked cells

I am writing a web application which has a design that requires an scrolling div with stacked images (see image)
I have written the following HTML
<div class="row">
<div class="col-md-12">
<div class="item-image-craousel-left"></div>
<div class="item-image-carousel">
<div style="background-image: url('http://img2.timeinc.net/people/i/2014/stylewatch/blog/140915/blake-lively-600x450.jpg')" class="main-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o1_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o2_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o3_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o4_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ncdgtvSlUc1rjtt9yo2_1280.jpg')" class="sub-image"></div>
</div>
<div class="item-image-craousel-right"></div>
</div>
</div>
And CSS:
.item-image-carousel {
width: 100%;
display: inline-block;
overflow-x: auto;
}
.item-image-craousel-left {
height: 399px;
width: 20px;
background-color: #40d1b0;
position: absolute;
text-align: center;
vertical-align: middle;
padding-top: 166px;
display: none;
}
And currently I am getting this which is not overflowing and when I increase the width the images stack inline rather than in blocks of two as in the image above
Can someone tell me how I can achieve the layout as in the first picture. I am using Bootstrap 3 for its grid.
From my comment I meant something like this...(not knowing the correct 'col-md-xx' to use)
<div class="row">
<div class="col-md-12">
<div class="item-image-craousel-left"></div>
<div class="item-image-carousel row">
<div class="col-md-8 main-image" style="background-image: url('http://img2.timeinc.net/people/i/2014/stylewatch/blog/140915/blake-lively-600x450.jpg')"></div>
<div class="col-md-4">
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o1_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o2_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o3_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ma7gmzwfAq1r780z3o4_250.jpg')" class="sub-image"></div>
<div style="background-image: url('assets/images/tumblr_ncdgtvSlUc1rjtt9yo2_1280.jpg')" class="sub-image"></div>
</div>
</div>
<div class="item-image-craousel-right"></div>
</div>
</div>

Extending background vertically in responsive sizes

I have a background working fine with 1024X768px but when the responsive position turns to 768X1024, my background did not extend up to the footer. In other sizes like 480x320 and vice versa my background repeats vertically. I want my background to extend when responsive position turns to 768X1024 and also in 480c320. Can you tell me the best solution for this?
I tried to use this but it's not working.
#media only screen and (max-width:768px){
.container .mybg {background-size:100%;}
}
*note: need to cut some contents.
Here's my code:
<body>
<div class="container">
<!--Background-->
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="mybg">
<div class="container">
<div class="row-fluid text-center">
<div class="col-sm-12">
<div class="img-thumbnail">
<img class="img-responsive center-block" src="images/winning
logo.png" alt="...">
<div class="container">
<div class="caption">
<h5>Logo Design</h5>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!--END OF MYBG-->
</div><!--END OF Background-->
</div>
<!--bacground pattern 2 underneath-->
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<img class="img-responsive center-block" src="images/BG-w-pattern_line_2.png">
</div><!--END OF bacground pattern 2 underneath-->
<div class="container">
<div class="footer">
<div class="container">
<p class="mytext-muted">Copyright © 2014. All rights
reserved. EGT Design.</p>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
CSS:
#media only screen and (max-width:768px){
.container .mybg {background-size:100%;}
}
.container .mybg{
background:url(../images/ContentBG.png);}
This should work
.container .mybg {
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}