How to align items in HTML using Flexbox - html

I want my items to be placed in a specific order, so that the title (The header with the copyright paragraph) to be centered in the middle of the page my About section to not fill up half of my page ... I've tried using flex-basis so that I can give every item a specific width but didn't seem to work, any ideas? Here is the code for the footer part, I have this problem for both navbar and footer, but I guess if it will work for one it will work in general
Also PM : I don't know why most of the html code dosen't show with snippet , here is an image of how it looks https://imgur.com/4xXP36C
HTML CODE :
.flex {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
height: 100%;
}
.container {
max-width: auto;
margin: 0 auto;
overflow: auto;
padding: 0 40px;
align-self: start;
}
.bg-dark,
.btn-dark {
background-color: var(--dark-color);
color: #fff;
}
.footer .box a{
margin: 0 5px;
}
.lead {
font-size: 20px;
}
.py-1 {
padding: 1rem 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<footer class="footer bg-dark ">
<div class="container flex lead py-1">
<div class="box">
<h1>About</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis voluptatum vel praesentium molestias consectetur ea consequuntur a quidem vitae iste?</p>
</div>
<div class="box">
<h1>CarolandHousing</h1>
<p>Copyright © 2021</p>
</div>
<div class="box">
<nav>
<ul>
<li>Home</li>
<li>Features</li>
<li>Docs</li>
<i class="fab fa-facebook fa-2x"></i>
<i class="fab fa-instagram fa-2x"></i>
</ul>
</nav>
</div>
</div>
</footer>
Working Domo

Please find below the updated code according to your requirements which are as follows:-
All three columns in flex take equal width (33%)
Optional: Links removing list style and right align for better UI
.flex {
color: white;
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
height: 100%;
}
.container {
max-width: auto;
margin: 0 auto;
overflow: auto;
padding: 0 40px;
align-self: start;
}
.flex-basis-3{
flex-basis: 33%
}
.text-center{
text-align: center
}
.text-right{
text-align: right
}
.no-list{
list-style: none;
}
.bg-dark,
.btn-dark {
background-color: var(--dark-color);
color: #000;
}
.footer .box a{
margin: 0;
}
.lead {
font-size: 20px;
}
.py-1 {
padding: 1rem 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<footer class="footer bg-dark ">
<div class="container-fluid flex lead py-1">
<div class="box flex-basis-3">
<h1>About</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis voluptatum vel praesentium molestias consectetur ea consequuntur a quidem vitae iste?</p>
</div>
<div class="box flex-basis-3 text-center">
<h1>CarolandHousing</h1>
<p>Copyright © 2021</p>
</div>
<div class="box flex-basis-3 text-right">
<div class="display: flex; justify-content: flex-end">
<span>Home</span>
<span>Features</span>
<span>Docs</span>
</div>
<div>
<i class="fab fa-facebook fa-2x"></i>
<i class="fab fa-instagram fa-2x"></i>
</div>
</div>
</div>
</footer>

Related

Why are my footer nav menus overlapping the legal text to the right of them and how do I prevent that?

I am not sure why my menu div is overlapping the legal ipsum when the page is made smaller? I've wrapped them in different coloured borders just to illustrate. Included is the HTML and CSS.
Right now I have it set to flexbox, space-between and the legal div has a fixed pixel width. I thought this was enough to have the flex children not overlap each other? What am I missing?
Any advice/help/guidance is very much appreciated. Thanks!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#import url('https://fonts.googleapis.com/css2?family=Raleway:wght#500;700&display=swap');
body {
font-family: 'Raleway', sans-serif;
}
html {
font-size: 62.5%;
}
a {
text-decoration: none;
}
ul {
list-style: none;
}
.container {
max-width: 1200px;
width: 85%;
margin: 0 auto;
}
footer {
background: #F6F8FA;
}
.footer-logo {
font-size: 2rem;
}
.footer-wrapper {
height: 350px;
}
.footer-nav {
display: flex;
justify-content: space-between;
align-items: baseline;
}
.footer-menus {
display: flex;
position: relative;
left: 125px;
text-transform: uppercase;
line-height: 40px;
margin-top: 25px;
border: 2px solid chartreuse;
}
.footer-menus a {
color: #333333;
font-size: 1.9rem;
font-weight: 700;
}
.footer-links {
margin-right: 25px;
}
.social-links {
margin-right: 25px;
}
.legal {
width: 275px;
line-height: 30px;
color: #777777;
border: 2px solid peachpuff;
}
.thin-line {
border-bottom: 1px solid #777777;
}
footer p {
font-weight: 500;
color: 777777;
}
</style>
</head>
<body>
<footer>
<div class="container">
<div class="footer-wrapper">
<nav class="footer-nav">
<div class="footer-logo">
<h3>travel</h3>
</div>
<div class="footer-menus">
<ul class="footer-links">
<li>home</li>
<li>about</li>
<li>blog</li>
<li>contact</li>
</ul>
<ul class="social-links">
<li>twitter</li>
<li>facebook</li>
<li>linkedin</li>
</ul>
</div>
<div class="legal">
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Expedita error temporibus quod
ipsam suscipit exercitationem possimus autem ad.</>
</div>
</nav>
<div class="thin-line"></div>
<p>Travel Agency</p>
</div>
</div>
</footer>
</body>
</html>
Here is a codepen: https://codepen.io/jmitchelreed/pen/MWeMBxd
It´s good practice to use comments to indicate where a closing tag for one of your elements are. This is mostly useful for when you have a lot of nested items, unorganized lists, divs, and anchor tags all in just one html, such as in your file. A HTML comment will not appear in your final design.
You can place them anywhere you like. Consider reading this
You have a problem with your closing nav element, its beyond the closing tag for your div element with the class of "legal".
</head>
<body>
<footer>
<div class="container">
<div class="footer-wrapper">
<nav class="footer-nav">
<div class="footer-logo">
<h3>travel</h3>
</div> <!-- Footer logo end -->
<div class="footer-menus">
<ul class="footer-links">
<li>home</li>
<li>about</li>
<li>blog</li>
<li>contact</li>
</ul>
<ul class="social-links">
<li>twitter</li>
<li>facebook</li>
<li>linkedin</li>
</ul>
</div> <!-- Footer menu end -->
</nav> <!-- Navbar end -->
<div class="legal">
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Expedita error temporibus quod
ipsam suscipit exercitationem possimus autem ad.</>
</div> <!--- Legal end -->
<div class="thin-line"></div> <!-- Unless this was intended, there is an extra closing div tag in here -->
<p>Travel Agency</p>
</div> <!-- Should this be the closing tag for the "Thin line" class? -->
</div> <!-- Container end -->
</footer> <!-- footer end -->
</body>
</html>

make the text take up as much space as the picture in grid with

i'm working on a school project where im supposed to do a portfolio. im trying to make a grid with pictuers and information next to that picture about stuff i have worked on. I'm trying to get the textbox to be as big as the picture. I have tried jusing flexbox and a lot of other stuff but can't get it to work. is there someone who can help me?
*{
box-sizing: border-box;
}
body{
background-color: #f4f4f4;
padding: 20px;
font-family: Arial;
}
.container {
max-width: 1600px;
margin: 0 auto;
}
.row {
margin:8px-16px;
}
.row,
.row > .column {
padding:2px 0px;
}
.column {
float:left;
width:50%;
}
.row:after {
content:"";
display:table;
clear:both;
}
.content {
background-color: white;
padding: 10px;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width:100%;
}
}
<div class="container">
<div class="row">
<div class="column">
<div class="content">
<h3>Hemsida 1</h3>
<p>Lorem ipsum.</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">´
</div>
</div>
<div class="column">
<div class="content">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">
</div>
</div>
</div>
</div>
You have complicated the layout very much. How do you like this layout option?
Each line is divided into two parts of 50%.
A small bonus: with small screens, due to the Flexbox property order, the description block is located above the picture.
P.S. Of course, this is not the final option. You can continue to improve it
Result
* {
box-sizing: border-box;
}
body {
background-color: #f4f4f4;
padding: 20px;
font-family: Arial;
}
.container {
max-width: 1600px;
margin: 0 auto;
padding: 0;
list-style: none;
}
.item {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
;
padding: 10px;
background-color: white;
}
.item__desc {
flex-basis: 50%;
}
.item__pic {
flex-basis: 50%;
}
.item_img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.item {
flex-direction: column;
width: 100%;
}
.item__desc {
order: -1;
}
}
<ul class="container">
<li class="item">
<div class="item__desc">
<h3>Hemsida 1</h3>
<p>Lorem ipsum.</p>
</div>
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354"></div>
</li>
<li class="item">
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354">
</div>
<div class="item__desc">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</li>
<li class="item">
<div class="item__desc">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354"></div>
</li>
</ul>
And same code on CodePen
will be enough for homework. Edit and improve codes
*{
margin: 0;
padding: 0;
box-sizing:border-box;
}
.box{
margin-bottom:20px;
background: #3498db;
height:500px;
}
.box-left{
width:50%;
float:left;
height:500px;
padding:50px;
}
.box-left h3{
margin-bottom: 15px;
}
.box-right{
width:50%;
float:right;
height:500px;
}
.box-right img{
width:100%;
height:100%;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="box">
<div class="box-left">
<h3>Head</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequuntur quas a velit. Aut nihil, modi nobis corporis eveniet ratione aperiam repellat maiores corrupti quidem ipsam animi officiis, fugit quasi rem!</p>
</div>
<div class="box-right">
<img src="https://i.ibb.co/S6PdtwP/69037904-2403297686584790-2753464427788369920-n.jpg" alt="">
</div>
</div>
<div class="box">
<div class="box-left">
<h3>Head</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequuntur quas a velit. Aut nihil, modi nobis corporis eveniet ratione aperiam repellat maiores corrupti quidem ipsam animi officiis, fugit quasi rem!</p>
</div>
<div class="box-right">
<img src="https://i.ibb.co/S6PdtwP/69037904-2403297686584790-2753464427788369920-n.jpg" alt="">
</div>
</div>
</body>
</html>
live demo
codepen live demo

Stretch div dependence of content

I want stretch box dependence of content, i'm using flexbox, but i can't to do. Below link my example
Parent div
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
Child div
order: 0;
flex: 0 1 auto;
align-self: auto;
.slick-track {
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
}
.slick-slide {
width: 150px;
margin: 10px;
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.sliderItem {
overflow: hidden;
background: #2F2F2F;
color: #fff;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
cursor: pointer;
}
.sliderItemTitle {
font-size: 25px;
font-weight: bold;
padding: 20px 20px 0;
min-height: 84px;
}
.sliderItemText {
display: flex;
padding-top: 10px;
padding: 0px 20px;
min-height: 58px;
align-items: center;
}
.sliderItemLinkBox {
margin-bottom: 20px;
padding: 0 20px;
}
.sliderItemLink {
color: yellow;
text-transform: uppercase;
}
<div class="slick-track">
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 1</strong>
</div>
<div class="sliderItemText">
lorema dadad addadadad adadadadadasd
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 2</strong>
</div>
<div class="sliderItemText">
Lorem
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 3</strong>
</div>
<div class="sliderItemText">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta dolore ipsa at minus molestias, neque rerum, aut minima voluptatum, dolorem odit nesciunt aliquid ullam officia reiciendis, recusandae natus maxime beatae.
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
</div>
https://jsfiddle.net/7qvo2tmk/5/
This can be accomplished using JS to loop through the elements and adjust the height based on the tallest element.
Working Example
let slides = document.querySelectorAll('.sliderItem')
function updateHeights() {
let tallestSlide = 0
for (i = 0; i < slides.length; i++) {
if (slides[i].clientHeight > tallestSlide) {
tallestSlide = slides[i].clientHeight
}
}
for (i = 0; i < slides.length; i++) {
slides[i].style.height = tallestSlide + 'px'
}
}
window.onresize = updateHeights
updateHeights()
You can try doing this.
What I did is that I remove the div that encloses the .sliderItem
and then add height to the .sliderItem of height:100%. so that it will occupy the height of its parent div .slick-slide.
.slick-track {
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
}
.slick-slide {
width: 150px;
margin: 10px;
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.sliderItem {
height: 100%;
overflow: hidden;
background: #2F2F2F;
color: #fff;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
cursor: pointer;
}
.sliderItemTitle {
font-size: 25px;
font-weight: bold;
padding: 20px 20px 0;
min-height: 84px;
}
.sliderItemText {
display: flex;
padding-top: 10px;
padding: 0px 20px;
min-height: 58px;
align-items: center;
}
.sliderItemLinkBox {
margin-bottom: 20px;
padding: 0 20px;
}
.sliderItemLink {
color: yellow;
text-transform: uppercase;
}
<div class="slick-track">
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 1</strong>
</div>
<div class="sliderItemText">
lorema dadad addadadad adadadadadasd
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 2</strong>
</div>
<div class="sliderItemText">
Lorem
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 3</strong>
</div>
<div class="sliderItemText">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta dolore ipsa at minus molestias, neque rerum, aut minima voluptatum, dolorem odit nesciunt aliquid ullam officia reiciendis, recusandae natus maxime beatae.
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
Hope this helps

Grid items are not wrapping properly using minmax() function

I am trying to create a responsive page where the "boxes" wrap to another row when browser window it made smaller. I used:
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
to accomplish this in the pen below.
See link for example of behavior desired.
https://codepen.io/DukeJellington/pen/BrMQga
html {
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
color: var(--dark)
}
body {
background: #ccc;
margin: 30px 50px;
line-height: 1.4;
}
.boxes {
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.box {
background: var(--primary);
text-align: center;
padding: 1.5rem 2rem;
box-shadow: var(--shadow);
}
<script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>
<!-- Boxes -->
<section class="boxes">
<div class="box">
<i class="fas fa-chart-pie fa-4x"></i>
<h3>Analytics</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-globe fa-4x"></i>
<h3>Marketing</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-cog fa-4x"></i>
<h3>Development</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-users fa-4x"></i>
<h3>Support</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
</section>
Notice how the icons/text will wrap to the lower row when window is made smaller, until there is one grid item is on top of another.
However, there is something prohibiting this behavior on the full page that was created in the link below; and I am unable to find what is prohibiting this behavior.
https://codepen.io/DukeJellington/pen/vRbyqb
/* CSS Variables */
:root {
--primary: #ddd;
--dark: #333;
--light: #fff;
--shadow: 0 1px 5px rgba(104, 104, 104, 0.8)
}
html {
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
color: var(--dark)
}
body {
background: #ccc;
margin: 30px 50px;
line-height: 1.4;
}
.btn {
background-color: var(--dark);
color: var(--light);
padding: 0.6rem 1.3rem;
text-decoration: none;
border: 0;
}
img {
max-width: 100%;
}
.wrapper {
display: grid;
grid-gap: 20px;
}
/* Navigation */
.main-nav ul {
display: grid;
grid-gap: 20px;
padding: 0;
list-style: none;
grid-template-columns: repeat(4, 1fr);
}
.main-nav a {
background: var(--primary);
display: block;
text-decoration: none;
padding: 0.8rem;
text-align: center;
color: var(--dark);
text-transform: uppercase;
font-size: 1.1rem;
box-shadow: var(--shadow);
}
.main-nav a:hover {
background: var(--dark);
color: var(--light);
}
/* Top Container */
.top-container {
display: grid;
grid-gap: 20px;
grid-template-areas: 'showcase showcase top-box-a' 'showcase showcase top-box-b'
}
.showcase {
grid-area: showcase;
min-height: 400px;
background: url(img/showcase.jpg);
background-size: cover;
background-position: center;
padding: 3rem;
display: flex;
flex-direction: column;
align-items: start;
justify-content: center;
box-shadow: var(--shadow);
}
.showcase h1 {
font-size: 4rem;
margin-bottom: 0;
color: var(--light);
}
.showcase p {
font-size: 1.3rem;
margin-top: 0;
color: var(--light);
}
/* Top Box */
.top-box {
background: var(--primary);
display: grid;
align-items: center;
justify-items: center;
box-shadow: var(--shadow);
padding: 1.5rem;
}
.top-box .price {
font-size: 2.5rem;
}
.top-box-a {
grid-area: top-box-a;
}
.top-box-b {
grid-area: top-box-b;
}
/* Boxes */
.boxes {
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.box {
background: var(--primary);
text-align: center;
padding: 1.5rem 2rem;
box-shadow: var(--shadow);
}
<script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>
<div class="wrapper">
<!-- Navigation -->
<nav class="main-nav">
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</nav>
<!-- Top Container -->
<section class="top-container">
<header class="showcase">
<h1>Your Web Presence</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos, omnis magnam? Tempore ut vero ex.</p>
Read More
</header>
<div class="top-box top-box-a">
<h4>Membership</h4>
<p class="price">$199/month</p>
Buy Now
</div>
<div class="top-box top-box-b">
<h4>Pro Membership</h4>
<p class="price">$299/month</p>
Buy Now
</div>
</section>
<!-- Boxes Section -->
<section class="boxes">
<div class="box">
<i class="fas fa-chart-pie fa-4x"></i>
<h3>Analytics</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-globe fa-4x"></i>
<h3>Marketing</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-cog fa-4x"></i>
<h3>Development</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
<div class="box">
<i class="fas fa-users fa-4x"></i>
<h3>Support</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda, sapiente.</p>
</div>
</section>
<!-- Information Section -->
<section class="info">
<img src="img/pic1.jpg" alt="">
<div>
<h2>Your Business on the Web</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eligendi, minima praesentium accusamus maxime repellat, amet non necessitatibus enim officia ipsam saepe nemo deleniti incidunt vero autem earum accusantium sed corporis.
Learn More
</p>
</div>
</section>
<!-- Portfolio Section -->
<section class="portfolio">
<img src="https://source.unsplash.com/random/200x200" alt="">
<img src="https://source.unsplash.com/random/200x201" alt="">
<img src="https://source.unsplash.com/random/200x202" alt="">
<img src="https://source.unsplash.com/random/200x203" alt="">
<img src="https://source.unsplash.com/random/200x204" alt="">
<img src="https://source.unsplash.com/random/200x205" alt="">
<img src="https://source.unsplash.com/random/200x206" alt="">
<img src="https://source.unsplash.com/random/200x207" alt="">
<img src="https://source.unsplash.com/random/200x208" alt="">
</section>
<!-- Footer -->
<footer>
<p>GridBiz © 2018</p>
</footer>
</div>
<!-- Wrapper Ends -->
In the link above, when the window is made smaller, the final div wraps below, but the other grid items remain on the same row when the window is minimized further.
I played with the code a bit and noticed that when I commented out the following styling for the wrapper class, the grid items behave as desired.
.wrapper {
display: grid;
grid-gap: 20px;
Can somebody tell me what about having the grid display for the wrapper class is prohibiting my grid items below from wrapping properly?
Your .boxes grid doesn't wrap further due to other wider sibling blocks in main .wrapper block.
By default when you add just display: grid for a block, it becomes a grid container. Your .wrapper grid container has only single column and minimum width of this column is defined by a child with the biggest minimum size. The top biggest child in your case is .main-nav ul because it has 4 columns which won't shrink regardless of resolution. The next big container is .top-container which also have big number of unshrinkable content.
So for resolving your issue just make .main-nav ul and .top-container blocks shrinkable in any way.
Also note that for 1D layout you can use Flexbox.

Why background image isn't well positioned in header with text?

I'm making some website and got a problem in CSS with header background image.
It doesn't scale to the window size, also problem is the text of the header which isn't in image.
I wanted background image to be full width and height to be in scale of image (in this case image is 16:9) and H3 text to be in the middle of background.
Screenshot of the page
Snippet:
* {
/* outline: 1px dotted salmon; */
margin: 0;
padding: 0;
box-sizing: inherit;
}
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
/*line-height: 1.428571429;*/
color: #333333;
height:100%;
/* width: 100%; */
box-sizing: border-box;
}
#navigacija ul {
width: 100%;
height: 40px;
color: #eceff1;
top: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
#navigacija ul li {
float:right;
}
#navigacija ul li a {
display: block;
text-align: center;
color: #000000;
padding: 16px;
font-size: 14pt;
text-decoration: none;
}
#header {
background-image: url(https://qyq2vq.bn1304.livefilestore.com/y4mO6k4nj7Bn1PdZK3MXxnxTfup6pcZ9CV1RVzElVbaZqHXGeIsWHoA8dYIGLtxGDelO5jpjDbW7viwUNjUp1ptfrIa6Gzl2mtV8gCCEqfiycIHxrC1R0nVr73m_KmhQ2pXgEjhsGtlnkGEpo928QsIRfnQSs-aM4CwxiwaEzJ-q262AQ1Cqau9q_7J1oA9OHSG_pQDOfyHhgSAUpcdz-BdCw/20170104_164033.jpg?psid=1);
background-size: contain;
background-repeat: no-repeat;
line-height: auto;
background-position: 100% 100%;
}
#header h3 {
text-align: center;
font-size: 16pt;
}
p.traka {
text-align: center;
font-size: 12pt;
background-color: #eceff1;
padding: 10px;
}
#zastomi {
width: 100%;
height: 25%;
background-color: #29434e;
}
<html>
<head>
<meta charset="utf-8">
<title>index.html</title>
<script src="https://use.fontawesome.com/e4a38023a1.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div class="container">-->
<div id="navigacija">
<!-- <a href="/" id="logo" title="ARKomp početna">
ARKomp
<img src="http://www.arkomp.tk/test/content/logo.png" />
</a>-->
<ul style="list-style-type:none">
<li class="klmeni"><span class="navigacija_text">Početna</span></li>
<li class="klmeni"><span class="navigacija_text">Usluge</span></li>
<li class="klmeni"><span class="navigacija_text">Cenovnik</span></li>
<li class="klmeni"><span class="navigacija_text">Kontakt</span></li>
<li class="klmeni"><span class="navigacija_text">O nama</span></li>
<li class="drustvene facebook"><i class="fa fa-facebook-official" aria-hidden="true"></i><span class="navigacija_text">Facebook</span></li>
<li class="drustvene instagram"><i class="fa fa-instagram" aria-hidden="true"></i><span class="navigacija_text">Instagram</span></li>
</ul>
</div>
<div id="sadrzaj">
<div id="header">
<h1>Početna</h1>
</div>
<p class="traka">Zašto mi?</p>
<div id="zastomi">
<div class="kvadrati">
<i class="fa fa-wrench" aria-hidden="true"></i>
<h3>Kvalitet</h3>
<p>Naš posao radimo predano i s ljubavlju. Pazimo na svaki detalj ne bi li udovoljili korisniku.</p>
</div>
<div class="kvadrati">
<i class="fa fa-car" aria-hidden="true"></i>
<h3>Mobilnost</h3>
<p>Trudimo se da vam olakšamo čitav proces nudeći besplatnu uslugu dolaska na kućnu adresu.</p>
</div>
<div class="kvadrati">
<i class="fa fa-money" aria-hidden="true"></i>
<h3>Cena</h3>
<p>U gradu nećete naći servis sa nižim cenama od naših. Pogledajte cenovnik ispod.</p>
</div>
<div class="kvadrati">
<i class="fa fa-arrow-down" aria-hidden="true"></i>
<h3>Akcije</h3>
<p>ARKomp svake nedelje nudi još povoljnije svoje usluge u okviru Top ponude!!!</p>
</div>
</div>
<p class="traka">Najnovije:</p>
<div id="najnovije">
<div class="boxovi">
<h4>Top ponuda</h4>
<p>Tokom ove nedelje na sniženju se nalazi usluga instalacije sistema. Nova cena je 1000 dinara.</p>
<div>
<i class="fa fa-hourglass-half fa-2x" aria-hidden="true"></i>
<p>14.08.2017 - 20.08.2017</p>
</div>
</div>
<div class="boxovi">
<h4>Lorem ipsum</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet tempus ex. Vivamus scelerisque. </p>
<div>
<!--<i class="fa fa-hourglass-half fa-2x" aria-hidden="true"></i>
<p>14.08.2017 - 20.08.2017</p>-->
</div>
</div>
<div class="boxovi">
<h4>Lorem ipsum</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet tempus ex. Vivamus scelerisque. </p>
<div>
<!--<i class="fa fa-hourglass-half fa-2x" aria-hidden="true"></i>
<p>14.08.2017 - 20.08.2017</p>-->
</div>
</div>
</div>
<div id="footer">
<p>©2017 ARKomp.</p>
<p>Sajt izrađen od ARKomp</p>
</div>
</div>
<!--</div>-->
</body>
</html>
use background-size: cover; to make it fill up the element. background-size: contain; will keep the image in its ratio, in your case the height is only say 60px and there for it will be 60px height and some width. If that makes sense?
#header {
background-image: url(https://qyq2vq.bn1304.livefilestore.com/y4mO6k4nj7Bn1PdZK3MXxnxTfup6pcZ9CV1RVzElVbaZqHXGeIsWHoA8dYIGLtxGDelO5jpjDbW7viwUNjUp1ptfrIa6Gzl2mtV8gCCEqfiycIHxrC1R0nVr73m_KmhQ2pXgEjhsGtlnkGEpo928QsIRfnQSs-aM4CwxiwaEzJ-q262AQ1Cqau9q_7J1oA9OHSG_pQDOfyHhgSAUpcdz-BdCw/20170104_164033.jpg?psid=1);
background-size: cover;
background-repeat: no-repeat;
line-height: auto;
background-position: 100% 100%;
}