Sections overlapping Bootstrap 4 - html

I have a problem with two sections of my website, up to a certain size they are separated
but in the smallest size they overlap
Here is part of my code:
.home-inner {
height: 100vh;
width: 100vw;
background-image: url('../img/bg.jpg');
background-position: center;
background-size: cover;
background-repeat: no-repeat;}
.caption {
width: 100%;
max-width: 100%;
position: absolute;
top: 38%;
z-index: 1;
text-transform: uppercase;}
<section id="inicio">
<div class="landing">
<div class="home-wrap">
<div class="home-inner">
</div>
</div>
</div>
<div class="caption text-center">
<h1>Title</h1>
<h3>Sub title</h3>
VER PRODUCTOS
</div>
</div>
</section>
<section class="qsomos">
<div id="bio" class="container-fluid">
<div class="row justify-content-center align-items-center">
<div class="col-lg-5 col-xs-3 mx-auto">
<h2>TÍTULO</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. <br>Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>..........
In the images you can see what I mean, I'm a beginner so I'm grateful that someone can help me with something this simple.

What you'll need to do is add media queries to your CSS. Media queries can alter your CSS based on the screen size/device so that when the screen size is smaller your HTML will adjust to the screen size.
Take a look at this for further reference:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Related

Blur background-image only and not the text infront [duplicate]

This question already has answers here:
How to apply a CSS filter to a background image
(22 answers)
Closed 3 years ago.
As the title says. How do I blur the background-image of my container without blurring the text in front of it?
.container a .body-container {
background-image: url("https://i2.wp.com/digital-photography-school.com/wp-content/uploads/2019/02/Landscapes-01-jeremy-flint.jpg");
filter: blur(1px);
}
<div class="card">
<div class="head">
<div class="title">
<span>Card Title</span>
</div>
</div>
<div class="body-container">
<div class="body">
<div class="content">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</div>
I made the JSBin here, https://jsbin.com/gizoyomuyi/1/edit?html,css,output
Update: Apologies, I updated the JSBin link because the one I posted earlier was outdated.
Note: The left card is the changes I made based on #Irin's answer, and the right card is as is.
To make background blur without affecting text, you will have to take two different div. one for the background image and another for the text.
You will have to use position: absolute for the div with content.
Please follow the code below using your image name :
<html>
<head>
<style>
.body-container {
background-image: url(https://images.pexels.com/photos/257360/pexels-photo-257360.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940);
filter: blur(5px);
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.body {
position: absolute;
top: 50%;
color: #fff;
margin: 0px auto;
width: 50%;
text-align: center;
right: 0%;
left: 0%;
font-size:25px;
}
</style>
</head>
<body>
<div class="card">
<div class="head">
<div class="title">
<span>Card Title</span>
</div>
</div>
<div class="body-container">
</div>
<div class="body">
<div class="content">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</body>
</html>
try out this
body,
html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
a,
a:hover {
color: black;
text-decoration: none;
}
.head {
border: 1px solid gray;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
padding: 20px;
}
.bg-image {
/* The image used */
background-image: url("https://i2.wp.com/digital-photography-school.com/wp-content/uploads/2019/02/Landscapes-01-jeremy-flint.jpg");
/* Add the blur effect */
filter: blur(5px);
-webkit-filter: blur(5px);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Position text in the middle of the page/image */
a {
color: white;
font-weight: bold;
position: absolute;
top: 74%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
<div class="head">
<div class="title">
<span>Card Title</span>
</div>
</div>
<div class="bg-image"></div>
<div>
<a href="#">
<div class="card body-container">
<div class="">
<div class="body">
<div class="content">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</div>
</a>
</div>

How to change layout of Horizontal Cards in Materialize CSS on mobile?

I'm trying to create a layout that's similar to this: the image and text should be side-by-side on desktop and tablet. On mobile, they should show up in one column with either the image or the text on top and the other below it. I'm using the Horizontal Cards from Materialize CSS to do this. However, on mobile, the cards still show up in a horizontal format. Is there any way to change this using Materialize CSS?
This is my current code:
<div class="col s12 m6 l6">
<div class="card horizontal">
<div class="card-image">
<img src="https://images.unsplash.com/photo-1454994834218-5ffbb76c0e74?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=dddc4ee524eee04e325dbc73367391d8">
</div>
<div class="card-stacked">
<div class="card-content valign-wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="card-action">
Sample Link
</div>
</div>
</div>
</div>
<style>
.card-content{
margin:0 30% 0 30px;
}
</style>
I've also tried the codes here, but the image gets cut off and the card layout is still horizontal even on mobile.
<div class="sample">
<div class="row">
<div class="col s12 m6 l6 left-image">
</div><!-- /col s12 m6 left-image -->
<div class="col s12 m6 l6 text-right">
<div class="test">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div><!-- /col s12 m6 icon-text -->
</div><!-- /col s12 m6 text-right -->
</div><!-- /row -->
</div>
<style>
.sample>.row{
display:flex;
}
.sample>.row>.col{
align-items: center;
display: flex;
flex: 1;
justify-content:center;
text-align: center;
}
.sample>.row>.col.left-image{
background:url("https://images.unsplash.com/photo-1454994834218-5ffbb76c0e74?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=dddc4ee524eee04e325dbc73367391d8");
background-size:cover;
height: auto;
}
</style>
Also, is there a way to keep the image and the text aligned or with nearly the same height on desktop and tablet, but without cutting off the image?
There is a pull request on GitHub that implements exactly what you want.
The Pull request is written in sass. This is what it compiles to:
#media only screen and (min-width: 601px) {
.card.responsive-horizontal {
display: flex;
}
.card.responsive-horizontal.small .card-image, .card.responsive-horizontal.medium .card-image, .card.responsive-horizontal.large .card-image {
height: 100%;
max-height: none;
overflow: visible;
}
.card.responsive-horizontal.small .card-image img, .card.responsive-horizontal.medium .card-image img, .card.responsive-horizontal.large .card-image img {
max-height: 100%;
width: auto;
}
.card.responsive-horizontal .card-image {
max-width: 50%;
}
.card.responsive-horizontal .card-image img {
border-radius: 2px 0 0 2px;
width: auto;
max-width: 100%;
}
.card.responsive-horizontal .card-stacked {
position: relative;
display: flex;
flex-direction: column;
flex: 1;
}
.card.responsive-horizontal .card-stacked .card-content {
flex-grow: 1;
}
}
If you are looking for the sass version of this or you want more information, have a look at the pull request on GitHub.

Position two images and make them look nice on mobile, the images does not have equal sizes

This is my fiddle Fiddle
I am trying to achieve the following:
Two images that are not the same size should stay side by side in a full-width container and should keep the same height. (it works on my computer resolution = 1388px width), but at different resolutions the images won't have the same height.
On smaller resolution (for example less than 991px) the images will go one under another one (like it can be seen in the fiddle, but the issue here is that there is a space between images and the writing will not fit the second image height.
The last thing is: the writing in the second image (on desktop resolutions for example greater than 991px) should end exactly where the writing of the above paragraph ends. (the paragraph is in a bootstrap container)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid nopadding">
<section id="about-us">
<div class="col-lg-5 col-md-12 nopadding">
<div class="background-image-left">
<img src="http://placehold.it/2400x1600" class="img-responsive" />
</div>
</div>
<div class="col-lg-7 col-md-12 nopadding">
<div class="background-image-right" style="background:url('http://placehold.it/1920x481;') center center no-repeat">
<div class="inner">
<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</section>
</div>
I need to keep these images at this size.
You can add both images as background images. Also both of your div's having the background image need to have fixed equal height.
<div class="row">
<div class="col-lg-5 col-md-12 nopadding">
<div class="background-image-left">
</div>
</div>
<div class="col-lg-7 col-md-12 nopadding">
<div class="background-image-right">
<div class="inner">
<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</div>
And the CSS
.background-image-left, .background-image-right {
height: 500px;
background-size: cover;
background-position: center center;
}
.background-image-left {
background: url('http://placehold.it/2400x1600');
}
.background-image-right {
background: url('http://placehold.it/1920x481');
}

Bootstrap - mixing container and container-fluid

I'm currently building a site which is one of those tall pages broken up in to horizontal panels for each different section.
Some of the horizontal panels are fixed-width centred in the middle (see 1,2,3,5 in diagram) and some are full-width (see 4 in diagram). For the fixed-width I'm using a ".container" class and that's easy enough and working fine. For the full-width panels I'm using ".container-fluid".
Now the problem I'm facing is as follows (see image for reference.)
So panel 4 is full width and consists of 2 columns. The textual content is between B & C, and C & D, however there is 2 background images that span A to C and C to E and I can't figure out how to do that.
I've tried to split it in to 2 columns and then have a fixed width section in the middle but can't get it working. This is where I'm currently at:
<div class="container-fluid">
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
</div>
Any advice greatly appreciated.
EDIT: Added two-column split for container-fluid.
From what I understood from the image shown on your question, I would recommend separating the containers and naming them with classes or ID's in order to remove stock margins or others that push it down or up.
<div class="container topContainer">
<p>Content here</p>
</div>
<div class="container-fluid midContainer">
<div class="row">
<div class="col-sm-6 leftPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
<div class="col-sm-6 rightPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
</div>
</div>
<div class="container botContainer">
<p>Content here</p>
</div>
And for setting the background, use the following CSS:
.leftPad {
background-image: url('example.jpg');
}
.rightPad {
background-image: url('example2.jpg');
}
This should wrap it up, and keep it clean without messing anything. To adjust margins and other placements, implement some CSS to those custom classes I've set up on the example.
As a tip I would say that do not use container inside a row or column. Wrap the whole page inside a column and separate the content itself with rows and cols to suite your needs.
Happy coding!
Found few solutions, but all used javascript. So here's my css-only solution. Cheers :)
/* just some styling for better view */
#mix {
background: black;
color: #fff;
}
.left {
background: url('https://static.pexels.com/photos/462254/pexels-photo-462254.jpeg') no-repeat center / cover;
}
.right {
background: url('https://static.pexels.com/photos/534020/pexels-photo-534020.jpeg') no-repeat center / cover;
}
.row {
border-top: 1px solid black;
}
.col-sm-6 {
padding-top: 15px;
padding-bottom: 15px;
}
/* and this below is basically what you need */
#media (min-width: 768px) {
.half-container {
padding-left: 15px;
padding-right: 15px;
max-width: 375px;
}
.left-half-container {
margin-right: -15px;
}
.right-half-container {
margin-left: -15px;
}
}
#media (min-width: 992px) {
.half-container {
max-width: 485px;
}
}
#media (min-width: 1200px) {
.half-container {
max-width: 585px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="mix">
<div class="container">
<div class="row">
<div class="left col-sm-6">
<div class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="right col-sm-6">
<div class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="left col-sm-6 clearfix">
<div class="half-container left-half-container pull-right text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="right col-sm-6 clearfix">
<div class="half-container right-half-container pull-left text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</div>
</div>
Below is the structure and use images as a background images of container-fluid div
<div class="container-fluid">
<div class="container">
<div class="col-sm-6"> </div>
<div class="col-sm-6"> </div>
</div>
</div>

Bootstrap divider displaced on smaller screens

I'm currently developing a website, one of my first bootstrap websites.
Facing a problem that I've been trying to solve for a few hours now.
I'm placing a divider or separator that I made in photoshop (png image) on the edge of a section.
It looks like this on desktop size:
https://www.dropbox.com/s/qxf7dheb0k79q2b/Screenshot%202014-09-30%2023.02.50.png?dl=0
But on smaller screens this happens:
https://www.dropbox.com/s/w4je7milallfrqn/Screenshot%202014-09-30%2023.10.50.png?dl=0
I'm sure it due to my bad CSS.
Here is my html and css:
<section class="hero-section text-center">
<img class="separator img-responsive"src="images/separator.png">
<div class="container">
<h1>Download Now</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<hr>
<button class="btn btncta">Download Now</button>
<p class="small">*Needed for developers</p>
</div>
</section>
CSS:
.separator{
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
top:318px;
}
Any way I could fix this?
Is it using a image for divider outdated (probably is)?
There's nothing wrong with using that separator image approach, but you're doing it wrong. Just replace your CSS like this:
.separator{
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
top:0px;
width:100%; height:1px;
}
and your HTML like this:
<section class="hero-section text-center">
<div class="container">
<h1>Download Now</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<hr>
<button class="btn btncta">Download Now</button>
<p class="small">*Needed for developers</p>
</div>
<img class="separator "src="images/separator.png">
</section>
I did a bootply so you can see (the background color is not needed, is just so you see the effect since I don't have your image)
Adding new method based in new information:
/* CSS used here will be applied after bootstrap.css */
body {
background:#f00;
}
.separator {
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
top:0px;
background:#f00;
width:100%;
height:1px;
}
.hero-section {
background:#fff url('http://www.customstairsandmouldings.com/images/circle.jpg') no-repeat center bottom; / we center the background and position it at the bottom of the div */
padding-bottom: 100px; /* padding-bottom has to be enough to give room to the image in the background, so if image height is 80px, padding bottom should be at least 80px, or better 100px to add spacing */
}
See new Bootply here