Bootstrap - Assistance with layout needed - html

I'm new to coding and figured best way to learn is to get a gig, which I did. I've got some basic (like very basic) HTML & CSS knowledge, but bootstraps layout seemed to fit for what I'm trying to accomplish. Please keep in mind this is my very first project ever(!) when it comes to coding.
So here's the design I'm trying to replicate:
montere.it
I'm interested just in the main page, the actual tiles below the main image to be exact. I can't seem to find the best solution to position 2 tiles with background image, side by side(no gaps), with some h1 text and a small <p> above the background image in the tile, positioned centrally. There will be two more tiles below the initial two.
I SPENT A WEEK looking for similar solutions, but I'm exhausted and confused over all information digested. Can some one just point me in the right direction as to which features to use?
It seems even if I get to position both images, there are always gaps (right or left), there's no way to position the text exactly above the image centrally so it stays in one place when the display is resized and I don't want to cry about the rest.
I have a feeling it's a dumb question to ask, since none of the info I've found provide an exact solution to this question, so probably must be really easy to do and I just can't seem to grasp it.
I do apologize for taking up your time, but I just have no one else to ask.
Cheers!

Please check this out:
<div class="row">
<div class="col-sm-6 col-xs 12 col-img" style="background-color: red">
<h1>Image 1</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: orange">
<h1>Image 2</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: green">
<h1>Image 3</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: yellow">
<h1>Image 4</h1>
</div>
</div>
And add this to your CSS file:
.col-img h1 {
margin-bottom: 0;
margin-top: 0;
text-align: center;
}

In case any one else runs into this problem, here's the fully working solution. I'm just not sure if it will disappear under gjfonte's link, so I want to be safe here:
Here's what was provided by #gjfonte:
<div class="row">
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-1">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-2">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-3">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-4">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
</div>
.content {
padding-top: 90px;
color: #fff
}
.content h1 {
margin-bottom: 0;
margin-top: 0;
text-align: center;
}
.col-img .bg-img {
text-align: center;
margin: 0 -15px;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 250px;
}
.bg-img.img-1 {
background-image: url("http://www.montere.it/assets/img/bg-qualitycycle-wrapper.jpg");
}
.bg-img.img-2 {
background-image: url("http://www.montere.it/assets/img/bg-qualitymap-wrapper.jpg");
}
.bg-img.img-3 {
background-image: url("http://www.montere.it/assets/img/bg-recipes-wrapper.jpg");
}
.bg-img.img-4 {
background-image: url("http://www.montere.it/assets/img/bg-journal-wrapper.jpg");
}

Related

Why do I have a column dependent on another using Bootstrap 4?

I have a problem with my web application.
Explanation:
The longer the text displayed on the left (so another column), the larger the image.
So how can I get one column completely independent from another?
<section class="section">
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-4 col-xs-4 p-4">
<h1>nosfera.app</h1>
<p>Oops, I think you got lost in the humble abode of Nosfera.
<p>But don't worry ! We will take care of you, you will be treated like a king, and soon everyone will
notice you, but for that, you have to join the dark side by clicking one of the two little buttons
below.
<div class=fields>
<div class=item>Log in</button></div>
<div class=item>Register</button></div>
</div>
</div>
<div class="col-md-6 col-xs-4 col-sm-4">
<div class="block"></div>
</div>
</div>
</div>
</section>
.section {
display: grid;
height: 90vh;
align-content: center;
}
.section p {
font-weight: 400;
font-size: 1.2rem;
}
.block {
background:url(../img/block.png);
background-size:contain;
background-repeat:no-repeat;
background-position:center;
width:100%;
height:100%
}
Demo
You are applying height:100% on the .block element CSS. It will grows with the text. Just set an fixed size (100px for instance), or limit the max-height and it will stop growing

How to add space between jumbotron when in mobile device size

So im building this website which looks like this in pc web size:
and when i resize the window to make it into mobile-sized window (phone), the jumbotrons turn into like this:
My question is that is there a way where i can add a space between the jumbotrons when it is in mobile-size? i do not want the jumbotrons to stick together just like in the picture i attached above.
my code so fo far, html:
<div class="container col-12">
<div class="row">
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" id="bg-card-1">
<h1>Cardholder #1</h1>
<p>Unique. Outstanding.</p>
</div>
</div>
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" id="bg-card-2">
<h1>Cardholder #2</h1>
<p>Stunning. Modern.</p>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" id="bg-card-3">
<h1>Product</h1>
<p>Description</p>
</div>
</div>
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" id="bg-card-4">
<h1>Product</h1>
<p>Description</p>
</div>
</div>
</div>
</div>
and css file:
#bg-card-1 {
background: url("https://i.postimg.cc/0y2F6Gpp/3.jpg") no-repeat center center;
background-size: cover;
color:white;
text-align: center;
height: 100%;
}
#bg-card-2 {
background: url("https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg") no-repeat center;
background-size: cover;
color:white;
text-align: center;
height: 100%;
}
#bg-card-3 {
background: url("https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg") no-repeat center;
background-size: cover;
color:white;
text-align: center;
height: 100%;
}
#bg-card-4 {
background: url("https://i.postimg.cc/0y2F6Gpp/3.jpg") no-repeat center;
background-size: cover;
color:white;
text-align: center;
height: 100%;
}
In Bootstrap 4 you can set margin and padding based on break points (xs sm md lg xl).
To set a different margin based on screen-size, you can give the element margin classes with different break points and different margin values. Like this:
<div class="jumbotron jumbotron-fluid my-3 my-lg-0" id="bg-card-3">
<h1>Product</h1>
<p>Description</p>
</div>
In this example the jumbotron would have a y axis margin (top and bottom) of 3 on xs sm md sized screens, but no y axis margin on screens that are lg or xl.
Note that to specify the xs breakpoint in Bootstrap, you simply do not add any break point at all in the class.
You can read more about spacing and break points in bootstrap at the links below.
https://getbootstrap.com/docs/4.0/utilities/spacing/
https://getbootstrap.com/docs/4.0/layout/overview/

Bootstrap CSS: div with image is overlapping div with text

I have the following four inner div container (small picture - text - small picture - text):
<div class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
</div>
</div>
</div>
The CSS for components-circle and inner-component:
.components-circle {
display: block;
margin: 0 auto;
background-repeat: no-repeat;
height: 115px;
width: 115px;
border-radius: 100%;
border: 2px solid #e0e0eb;
}
.inner-component {
background: url(http://...) no-repeat;
background-position: 20px 15px;
}
The problem is, that components-circle and inner-component are overlapping the text which is on the right side of them when I resize the browser, that means the template is not responsive.
How could I insert a line break when the browser is resized or make components-circle and inner-component responsive, so that they do not overlap the corrsponding text on the right side?
Is the content of the "col-sm-12" div overlapping the content of the page, or the text next to the image that is overlapping?
Anyway, you can fix both of these issues in this way, using a "container" or "row" div and adding a css for page resizing.
.components-circle {
display: block;
margin: 0 auto;
background-repeat: no-repeat;
height: 115px;
width: 115px;
border-radius: 100%;
border: 2px solid #e0e0eb;
}
.inner-component {
background: url(http://...) no-repeat;
background-position: 20px 15px;
}
.center-text{
text-align: left;
}
#media (max-width: 765px) {
.center-text{
text-align: center;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4 center-text">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4 center-text">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
</div>
</div>
</div>
You are already using row class so just setting the width of components-circle to 100% (rather than making it static) will work (as bootstrap will handle rest of the responsive stuff).
To keep the aspect ratio of height-width you have to remove height from components-circle and use padding-top. Have a look here to see how it works. (padding-top: 100% gives 1:1 aspect ratio)
Open the below snippet in full-page view and resize to see the effect :)
Though there can be other methods to achieve the same, IMO this one is quite simple and understandable.
.components-circle {
display: block;
margin: 0 auto;
background-repeat: no-repeat;
padding-top: 100%;
width: 100%;
border-radius: 100%;
border: 2px solid #e0e0eb;
}
.inner-component {
background: url(https://i.ebayimg.com/images/g/eiMAAOSwH3haAlKl/s-l300.png) no-repeat;
background-size: contain;
}
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
</head>
<body>
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
<div class="col-sm-2">
<div class="components-circle inner-component"></div>
</div>
<div class="col-sm-4">
<h3>Title</h3>
<p class="description">
Some ... long ... text
</p>
</div>
</div>
</div>
</body>
</html>
Update: To keep the inner image at the centre during resize, you have to set it's position to 0px 0px (which is default) and add background-size: contain to the inner-component. This will scale the image to fit the parent. See the updated snippet above!
To make a breakpoint that is hidden on larger viewports, you can use these CSS classes with the line break:
.d-md-none To make it invisible on anything larger than md sized screens.
.d-sm-none To hide it on anything larger than sm sized screens.
You may also need to put the row inside a container.
This is what it would look like: <br class="d-md-none">
If you want a line break without using a <br> element, check out this guide.

Columns on top of a background-image

I am making a small eastern project. The website is here: My Website.
I need to make some boxes that contain a png picture on top of the background-picture like this:
I set the picture on the col, but I guess I need to make it as a background in CSS, since I cannot build something on top of an img tag:
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<center><img src="https://mimsi.dk/images/logo.jpg" class="img-fluid" alt="Eastern"></center>
</div>
</div>
<div class="row">
<div class="col-md-12">
<img src="https://mimsi.dk/images/eeg.jpg" alt="Eastern game" class="background">
</div>
</div class="row">
<div class="col-md-12" style="border: 1px solid red;">
<h1 style="text-align: center;">FOOTER</h1>
</div>
</div>
</div>
Instead of using the img src tag, I set this in my HTML and CSS:
<div class="col-md-12 bg">
.bg {
background-image: url("https://mimsi.dk/images/eeg.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
But nothing has worked out yet. How can I set the background-image, so it is not going to the header logo or footer, so I can build my 8 boxes on top?
First there is a mistake in your HTML in this line </div class="row"> i think you got that you can't put class in closing div
Solution
I created a fiddle

Responsive scaling section not scaling with bootstrap jumbotron

Kind of difficult to explain so I will post a live link to my site where the code is hosted: link
Basically the issue is in the about section if the window is scaled smaller the section won't compensate for the jumbotron thats overflowing like it does for the other sections that don't make use of bootstrap divs. Hopefully that makes sense?
Here's the relevant code:
<section id="about" class="about-section" style="background-repeat:no-repeat; background-size:contain; background-position:center; background-color: #630000;">
<div class="col-xs-10 col-xs-offset-1 col-md-8 col-md-offset-2">
<br>
<div class="jumbotron" style="background-color: #4c0000; padding-top: 10px; padding-bottom: 10px;">
<div class="container text-center" style="color: white;">
<h1>A Little About Me</h1>
<p style="font-size: 16px;">wordsgohere</p>
<p><h3><b>TLDR:</b></h3></p>
<p style="font-size: 16px">wordsgohere</p>
<img src="imgs/ryanyup.png" class="img-responsive" style="align-content: left">
</div>
</div>
</div>
</section>
And CSS:
.about-section {
min-height: 100%;
text-align: center;
background: #000080;
}
The entire code is also available on my git: here
Thank you.
Add <div class="clearfix"></div> right before closing the section. The reason you need this is because the div inside the section floats and thus is not a real block.
your content is just overflowing. add overflow: auto; to your section.
<section id="about" class="about-section" style="background-repeat:no-repeat; background-size:contain; background-position:center; background-color: #630000;overflow: auto;">