I am creating a portfolio page in which I am showing my 6 projects, 3 in a row using flexbox. The items inside are flowing out of the flexbox even though I have used flex-wrap. I am relatively new to this so I don't know what is happening.
The red border is my flexbox container and it contains six div elements. Inside each div element, there is one image and another div element which is like a caption. Each image is of a different size
HTML Code:
<section id="work">
<h1><u>These are some of my projects</u></h1>
<div id="work-container">
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tribute.jpg" alt="">
<div id="project-title">Tribute Page</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/random-quote-machine.png" alt="">
<div id="project-title">Random Quote Machine</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/calc.png" alt="">
<div id="project-title">JavaScript Calculator</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/map.jpg" alt="">
<div id="project-title">Map Data Across the Globe</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/wiki.png" alt="">
<div id="project-title">Wikipedia Viewer</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tic-tac-toe.png" alt="">
<div id="project-title">Tic Tac Toe Game</div>
</div>
</div>
<button id="view-more"></button>
</section>
CSS Used:
#work-container{
display: flex;
flex-direction: row;
justify-content: space-around;
flex-wrap: wrap;
width: 100%;
border: 5px solid red;
}
.work-block{
width: 28%;
margin: 20px;
}
#media (max-width: 1000px) {
.work-block{
width: 45%;
}
}
#work-container img{
height: calc(100% );
width:100%;
margin:0;
padding: 0;
object-fit: cover;
flex:none;
}
There is one particular line which is enabling equal height for all images height: calc(100% );. I don't know how it works, I took it from the internet. It was used to have the equal height for each image.
Also, the bottom and the top margin between blocks is not working.
I want some help in wrapping content inside container properly and understanding how height: calc(100% ); works.
Complete Code: https://codepen.io/tushar_432/pen/poyxmyZ
Don't make the image height:100%, this will make the image take all the space pushing the text outside thus the overflow. Use flexbox to make it fill all the space minuse the text space:
#work-container {
display: flex;
flex-direction: row;
justify-content: space-around;
flex-wrap: wrap;
width: 100%;
border: 5px solid red;
}
.work-block {
width: 28%;
margin: 20px;
}
#media (max-width: 1000px) {
.work-block {
width: 45%;
}
}
.work-block {
display:flex; /* here */
flex-direction:column; /* here */
}
.work-block img {
width: 100%;
margin: 0;
padding: 0;
object-fit: cover;
flex: 1; /* here */
}
<section id="work">
<h1><u>These are some of my projects</u></h1>
<div id="work-container">
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tribute.jpg" alt="">
<div id="project-title">Tribute Page</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/random-quote-machine.png" alt="">
<div id="project-title">Random Quote Machine</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/calc.png" alt="">
<div id="project-title">JavaScript Calculator</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/map.jpg" alt="">
<div id="project-title">Map Data Across the Globe</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/wiki.png" alt="">
<div id="project-title">Wikipedia Viewer</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tic-tac-toe.png" alt="">
<div id="project-title">Tic Tac Toe Game</div>
</div>
</div>
</section>
Your caption is overflowing, you can add
display: flex;
flex-direction: column;
to your .work-block
#import url('https://fonts.googleapis.com/css2?family=Alegreya+Sans:wght#400;700&family=Catamaran:wght#400;600&family=Raleway:ital#1&display=swap');
*,*::before,*::after{
margin: 0;
padding: 0;
box-sizing: border-box;
top:0;
}
body{
background-color: bisque;
font-family: 'Catamaran', sans-serif;
text-align: center;
}
#header{
position: sticky;
top:0px;
margin:0;
}
#navbar{
color:white;
width:100%;
display: flex;
background-color:#12343b;
flex-direction: row;
justify-content: flex-end;
padding:18px;
font-family: 'Catamaran', sans-serif;
font-size: x-large;
font-weight: 450;
border-bottom: 2px solid white;
}
.nav-block:hover{
color:#e1b382;
}
.nav-block{
padding:0 20px;
}
#about h1{
font-family: 'Alegreya Sans', sans-serif;
font-weight: 700;
font-size: 65px;
color: #fefefe;
}
#about h3{
font-size:24px;
font-family: 'Raleway', sans-serif;
color: #e1b382;
}
#about{
text-align: center;
padding:250px;
background-color:#2d545e;
color:white;
}
#work{
padding:50px 0;
background-color: #e1b382;
}
#work h1{
font-weight: 600;
font-size: 40px;
color: #12343b;
}
#work-container{
display: flex;
flex-direction: row;
justify-content: space-around;
flex-wrap: wrap;
width: 100%;
border: 5px solid red;
}
.work-block{
width: 28%;
margin: 20px;
display: flex;
flex-direction: column;
}
#media (max-width: 1000px) {
.work-block{
width: 45%;
}
}
#work-container img{
height: calc(100% );
width:100%;
margin:0;
padding: 0;
object-fit: cover;
flex:none;
}
#contact{
padding:150px;
background-color: #2d545e;
}
#contact-container{
display: flex;
}
#footer{
padding:40px;
background-color:#2d545e;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
<header id="header">
<nav id="navbar">
<div class="nav-block">About</div>
<div class="nav-block">Work</div>
<div class="nav-block">Contact</div>
</nav>
</header>
<section id="about">
<h1>Hey I am Tushar</h1><br>
<h3>a computers <br>and technology enthusiast</h3>
</section>
<section id="work">
<h1><u>These are some of my projects</u></h1>
<div id="work-container">
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tribute.jpg" alt="">
<div id="project-title">Tribute Page</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/random-quote-machine.png" alt="">
<div id="project-title">Random Quote Machine</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/calc.png" alt="">
<div id="project-title">JavaScript Calculator</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/map.jpg" alt="">
<div id="project-title">Map Data Across the Globe</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/wiki.png" alt="">
<div id="project-title">Wikipedia Viewer</div>
</div>
<div class="work-block">
<img src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tic-tac-toe.png" alt="">
<div id="project-title">Tic Tac Toe Game</div>
</div>
</div>
<button id="view-more"></button>
</section>
<section id="contact">
<h1>Let's Work Together</h1>
<p>How do you take your coffee?</p>
<div id="contact-container">
<div class="contact-block">
<i class="fab fa-facebook"></i><span>Facebook</span>
</div>
<div class="contact-block">
<i class="fab fa-github"></i><span>Github</span>
</div>
<div class="contact-block">
<i class="fas fa-hashtag"></i><span>Twitter</span>
</div>
<div class="contact-block">
<i class="fas fa-at"></i><span>Send a mail</span>
</div>
<div class="contact-block">
<i class="fas fa-mobile-alt"></i><span>Call me</span>
</div>
</div>
</section>
<footer id="footer">
<span>**This is just a fake portfolio. All the projects and contact details given are not real.</span>
<span>© Created for freeCodeCamp </span>
</footer>
Related
I am trying to get three href links in the class nav-link-wrapper and class logo which is also a logo image over the class mainImage here is my CSS code , all the links and logo is below the image instead of on it at the top of the image , links on the to top left and logo on the top right
.nav-wrapper {
display: flex;
justify-content: space-between;
padding: 30px;
}
.left-side {
display: flex;
}
.mainImage {
position: relative;
width: 100%;
height: 60%;
}
.logo {
position: absolute;
top: 10px;
right: 10px;
position: relative;
}
.container>.nav-wrapper>.left-side>.nav-link-wrapper {
margin-right: 20px;
font-size: 0.9em;
justify-content: space-around;
}
<div class="container">
<img class="mainImage" src="https://via.placeholder.com/800" alt="Auckland, New Zealand" style="width:100%;height:60%;">
<div class="nav-wrapper">
<div class="left-side">
<div class="nav-link-wrapper">
Hlavní Stránka
</div>
<div class="nav-link-wrapper">
Naše Projekty
</div>
<div class="nav-link-wrapper">
Náš Kontakt
</div>
</div>
<div class="right-side">
<div class="logo">
<img src="https://via.placeholder.com/150" alt="investice do zahraničí" style="width: 150px;height: 150px;">
</div>
</div>
</div>
</div>
.container {
position: relative;
}
.nav-wrapper {
position: absolute;
top: 0;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%
}
.left-side {
display: flex
}
.nav-link-wrapper {
padding: 10px
}
.right-side {
border: 1px solid black
}
<div class="container">
<img class="mainImage" src="https://via.placeholder.com/800" alt="Auckland, New Zealand" style="width:100%;height:60%;">
<div class="nav-wrapper">
<div class="left-side">
<div class="nav-link-wrapper">
Hlavní Stránka
</div>
<div class="nav-link-wrapper">
Naše Projekty
</div>
<div class="nav-link-wrapper">
Náš Kontakt
</div>
</div>
<div class="right-side">
<div class="logo">
<img src="https://via.placeholder.com/150" alt="investice do zahraničí" style="width: 150px;height: 150px;">
</div>
</div>
</div>
</div>
So iam a first time HTML and CSS user, and was making a website using a YouTube video, however i reached a stage where i want to show the backround image onto the screen however ive followed the video exactly and it only shows my logo image and not the background image.
This was the youtube video : https://youtu.be/5bMdjkfvONE
I got up to 1:00:0 into the video after that it no longer worked like in the video.
/* Master Styles */
body {
margin: 0px;
}
.container {
display: grid;
grid-template-columns: 1fr;
}
/* Nav Styles*/
.nav-wrapper{
display:flex;
justify-content: space-between;
padding: 40px;
}
.left-side{
display:flex;
}
.nav-wrapper > .left-side > div {
margin-right: 20px;
font-size: 0.9em;
text-transform:uppercase;
}
.nav-link-wrapper {
height: 22px;
border-bottom: 1px solid transparent;
transition: border-bottom 0.5s;
}
.nav-link-wrapper a {
color:blue;
text-decoration: none;
transition: color 0.5s;
}
.nav-link-wrapper:hover{
border-bottom: 1px solid black;
}
.nav-link-wrapper a:hover{
color: black;
}
/* Portfolio Styles */
.portfolio-items-wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.portfolio-item-wrapper {
position: relative;
}
.portfolio-img-background {
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
}
.img-text-wrapper {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
padding-left: 100px;
padding-right: 100px;
}
.logo-wrapper img {
width: 50%;
margin-bottom: 20px;
}
.subtitle {
font-weight: 600;
color: darkblue;
}
<!DOCTYPE html>
<html>
<head>
<title>Mathews Joy</title>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="nav-wrapper">
<div class="left-side">
<div class="nav-link-wrapper">
Personal LinkedIn Page
</div>
<div class="nav-link-wrapper">
Personal Instagram Page
</div>
</div>
<div class="right-side">
<div class="brand">
MATHEWS JOY
</div>
</div>
</div>
<div class="content-wrapper">
<div class="portfolio-items-wrapper">
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(images/portfolio1.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/network.jpg">
</div>
<div class="subtitle">
Technology Intership at the Bright Network (December 2020)
</div>
</div>
</div>
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(images/portfolio3.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/network.jpg">
</div>
<div class="subtitle">
Certications completed during time at university (2020 - 2023)
</div>
</div>
</div>
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(images/portfolio2.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="images/network.jpg">
</div>
<div class="subtitle">
Volunteering and Work Experiences
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
It's because there are no images at the URL's you are using. What's more, you need to apply a height to the elements that have the background images. I only did it for one of them below.
/* Master Styles */
body {
margin: 0px;
}
.container {
display: grid;
grid-template-columns: 1fr;
}
/* Nav Styles*/
.nav-wrapper{
display:flex;
justify-content: space-between;
padding: 40px;
}
.left-side{
display:flex;
}
.nav-wrapper > .left-side > div {
margin-right: 20px;
font-size: 0.9em;
text-transform:uppercase;
}
.nav-link-wrapper {
height: 22px;
border-bottom: 1px solid transparent;
transition: border-bottom 0.5s;
}
.nav-link-wrapper a {
color:blue;
text-decoration: none;
transition: color 0.5s;
}
.nav-link-wrapper:hover{
border-bottom: 1px solid black;
}
.nav-link-wrapper a:hover{
color: black;
}
/* Portfolio Styles */
.portfolio-items-wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.portfolio-item-wrapper {
position: relative;
}
.portfolio-img-background {
height: 350px;
width: 100%;
background-size: cover;
background-position: center;
}
.img-text-wrapper {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
text-align: center;
padding-left: 100px;
padding-right: 100px;
}
.logo-wrapper img {
width: 50%;
margin-bottom: 20px;
}
.subtitle {
font-weight: 600;
color: darkblue;
}
<!DOCTYPE html>
<html>
<head>
<title>Mathews Joy</title>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="nav-wrapper">
<div class="left-side">
<div class="nav-link-wrapper">
Personal LinkedIn Page
</div>
<div class="nav-link-wrapper">
Personal Instagram Page
</div>
</div>
<div class="right-side">
<div class="brand">
MATHEWS JOY
</div>
</div>
</div>
<div class="content-wrapper">
<div class="portfolio-items-wrapper">
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(images/portfolio1.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://via.placeholder.com/150
C/O https://placeholder.com/">
</div>
<div class="subtitle">
Technology Intership at the Bright Network (December 2020)
</div>
</div>
</div>
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(https://via.placeholder.com/150); height: 200px"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://via.placeholder.com/150
C/O https://placeholder.com/">
</div>
<div class="subtitle">
Certications completed during time at university (2020 - 2023)
</div>
</div>
</div>
<div class="portfolio-item-wrapper">
<div class="portfolio-img-backround" style="background-image:url(images/portfolio2.jpg)"></div>
<div class="img-text-wrapper">
<div class="logo-wrapper">
<img src="https://via.placeholder.com/150
C/O https://placeholder.com/">
</div>
<div class="subtitle">
Volunteering and Work Experiences
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
This question already has answers here:
Align child elements of different blocks
(3 answers)
Closed 2 years ago.
I'm developing a simple webpage with elements of flexbox. In one section I have logos of project with description to them. Unfortunately, all of the projects have logos in a different size. How can I receive the result as on picture?
My current code (HTML)
<div id="Projects">
<a href="http://www.project1.com">
<div id="ProjectL">
<img class="img-responsive" src="{% static 'images/logos/project1.png' %}" alt="project" style=" margin-left: auto; max-width: 200px; align-items: flex-start;">
<div id="desk" style="align-items: flex-end;"> Project ONE</div>
</div>
</a>
<a href="http://www.project2.com">
<div id="ProjectL">
<img class="img-responsive" src="{% static 'images/logos/project2.png' %}" alt="project" style=" margin-left: 35px; max-width: 200px; align-items: flex-start;">
<div id="desk" style="align-items: flex-end;">Project TWO</div>
</div>
</a>
<a href="http://www.project3.com">
<div id="ProjectL">
<img class="img-responsive" src="{% static 'images/logos/project3' %}" alt="project" style=" margin-left: 35px; max-width: 200px; align-items: flex-start;">
<div id="desk" style="align-items: flex-end;"> PROJECT THREE</div>
</div>
</a>
<a href="http://www.project4.com">
<div id="ProjectL">
<img class="img-responsive" src="{% static 'images/logos/project4' %}" alt="project" style=" margin-left: 35px; margin-right: auto; max-width: 200px; align-items: flex-start;">
<div id="desk" style="align-items: flex-end;"> Project FOUR</div>
</div>
</a>
</div>
CSS
#Projects {
display: flex;
flex-direction: row;
font-family: sans-serif;
padding-bottom: 40px;
}
#ProjectL {
display: flex;
flex-direction: column;
font-family: sans-serif;
padding-bottom: 40px;
}
I created a really quick Codepen with a solution that works if you know that your logos aren't going to have heights higher than the container I called projects__item-top. Maybe you could set a maximum size for the logos?
Here's the code:
HTML
<div class="projects">
<a class="projects__item" href="www.link.com" aria-label="Project 1">
<div class="projects__item-top">
<img src="https://source.unsplash.com/random/200x60" alt="" />
</div>
<div class="projects__item-description">
<h3>Description 1</h3>
<p>Lorem ipsum dolor sit amet</p>
</div>
</a>
<a class="projects__item" href="www.link.com" aria-label="Project 2">
<div class="projects__item-top">
<img src="https://source.unsplash.com/random/200x50" alt="" />
</div>
<div class="projects__item-description">
<h3>Description 2</h3>
</div>
</a>
<a class="projects__item" href="www.link.com" aria-label="Project 3">
<div class="projects__item-top">
<img src="https://source.unsplash.com/random/200x70" alt="" />
</div>
<div class="projects__item-description">
<h3>Description 3</h3>
</div>
</a>
</div>
CSS
html * {
box-sizing: border-box;
}
.projects {
display: flex;
flex-direction: row;
}
.projects__item {
display: flex;
flex-direction: column;
margin: 10px;
padding: 10px;
}
.projects__item-top {
display: flex;
height: 120px;
align-items: center;
}
I noticed you were using id where you should be using class. An id has to be unique but a class can be re-used.
I hope this helps! Let me know if you have any other issues with it.
I've made this layout add your content inside of it:
HTML
<div class="container">
<div class="project">
<div class="logo-wrapper1">
<div class="logo1">logo 1</div>
</div>
<div class="description-wrapper">
<div class="description">Description 1</div>
</div>
</div>
<div class="project">
<div class="logo-wrapper2">
<div class="logo2">logo 2</div>
</div>
<div class="description-wrapper">
<div class="description">Description 2</div>
</div>
</div>
<div class="project">
<div class="logo-wrapper3">
<div class="logo3">logo 3</div>
</div>
<div class="description-wrapper">
<div class="description">Description 3</div>
</div>
</div>
</div>
CSS
* {
box-sizing: border-box;
}
.container {
display: flex;
padding: 10px;
border: 1px solid red;
height: 300px;
}
.project {
display: flex;
flex-direction: column;
border: 1px solid red;
padding: 10px;
margin-right: 10px;
}
.logo-wrapper1, .logo-wrapper2, .logo-wrapper3 {
display: flex;
align-items: center;
padding: 10px;
height: 100px;
}
.logo1 {
display: flex;
align-items: center;
border: 1px solid black;
height: 100%;
width: 100%;
}
.logo2 {
display: flex;
align-items: center;
border: 1px solid black;
height: 50%;
width: 100%;
}
.logo3 {
display: flex;
align-items: center;
border: 1px solid black;
height: 80%;
width: 100%;
}
.description-wrapper {
margin-top: 10px;
padding: 10px;
height: 100px;
border: 1px solid black;
}
I am currently working on a project which is a mobile-first e-commerce responsive website. I am trying to create a sliding div of products detailing the top selling range.
The idea is to allow the user to click on either the left or right slide-arrows and the products range will slide accordingly - a feature Im sure you have probalby seen on on most e-commerce websites.
Right now I am on the design aspect of creating this section but for some reason I can not center the images which appear in the divs. Am i disributing the percentages correctly? I plan on showing one product image in the mobile version but 3 in the desktop version.
My code is shown below.
HTML:
/* TOP SELLING RANGE SECTION */
.mobile-topselling-slideshow {
display: flex;
align-items: center;
}
.top-selling-arrows {
width: 10%;
text-align: center;
color: green;
font-size: 2em;
}
#top-selling-slider {
position: relative;
width: 80%;
overflow: hidden;
}
#top-selling-productdetails {
z-index: 60000;
display: flex;
width: 600%;
}
.topseller-sliding-divs {
width: 13.3%
}
.topseller-sliding-divs img {
width: 100%;
display: inline-block;
margin: auto;
}
<div class="content-container">
<section class="special-offers">
<h1>THIS WEEK'S TOP SELLERS</h1>
<div class="mobile-topselling-slideshow">
<div id="left-scroll-topselling" class="top-selling-arrows">
<i class="fas fa-caret-left"></i>
</div>
<div class="topselling-products">
<div id="top-selling-slider">
<div id="top-selling-productdetails">
<div id="item1topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item2topseller" class="topseller-sliding-divs">
<img src="images/sports/1.jpg" />
</div>
<div id="item3topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item4topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item5topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item6topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
</div>
</div>
</div>
<div id="right-scroll-topselling" class="top-selling-arrows">
<i class="fas fa-caret-right"></i>
</div>
</div>
</section>
</div>
An image of the outcome is also shown below
Just try, replace these two classes with your code and check:
.topseller-sliding-divs {
width: 13.3%;
text-align: center;
}
.topseller-sliding-divs img {
margin: 0 auto;
max-width: 100%;
}
When you use display: flex; then for aligning its content to center, you have to use justify-content:center; not text-align: center;
Try this.
.special-offers h1{
text-align: center;
}
.mobile-topselling-slideshow {
display: flex;
justify-content: center;
}
.top-selling-arrows {
width: 10%;
text-align: center;
color: green;
font-size: 2em;
}
#top-selling-slider {
position: relative;
width: 80%;
overflow: hidden;
}
#top-selling-productdetails {
z-index: 60000;
display: flex;
width: 600%;
}
.topseller-sliding-divs {
width: 13.3%;
text-align:center;
}
.topseller-sliding-divs img {
margin: 0 auto;
max-width: 100%;
}
<div class="content-container">
<section class="special-offers">
<h1>THIS WEEK'S TOP SELLERS</h1>
<div class="mobile-topselling-slideshow">
<div id="left-scroll-topselling" class="top-selling-arrows">
<i class="fas fa-caret-left"></i>
</div>
<div class="topselling-products">
<div id="top-selling-slider">
<div id="top-selling-productdetails">
<div id="item1topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item2topseller" class="topseller-sliding-divs">
<img src="images/sports/1.jpg" />
</div>
<div id="item3topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item4topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item5topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
<div id="item6topseller" class="topseller-sliding-divs">
<img src="images/sports/5.png" />
</div>
</div>
</div>
</div>
<div id="right-scroll-topselling" class="top-selling-arrows">
<i class="fas fa-caret-right"></i>
</div>
</div>
</section>
</div>
I am very new to html and css. I do know that in my text editor (brackets) the text changes color for keywords, but the "space-between" is not being recognized despite it being one of the choices. The other ones work. (like "center")
Basically what i'm trying to do is spread out my 3 images horizontally across the page when the page is at least 768px. Here is a portion of my index:
<main class="main-area">
<section class="box">
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="images/single-blue.jpg">
<div class="box-text">
<h2 class="box-title">Blue Firework</h2>
<p class="box-blurb">Image subtext</p>
</div>
</figure></a>
</article>
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="images/single-purple.jpg">
<div class="box-text">
<h2 class="box-title">Purple Firework</h2>
<p class="box-blurb">Image subtext</p>
</div>
</figure></a>
</article>
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="images/single-orange.jpg">
<div class="box-text">
<h2 class="box-title">Orange Firework</h2>
<p class="box-blurb">Image subtext</p>
</div>
</figure></a>
</article>
</section>
</main>
<!-- Close the main section -->
I think normally people combine their stylesheets but my teacher wants me to do them separate. Here is a css file:
/*
primary style sheet
*/
#import url('CSS/accessibility.css');
#import url('CSS/reset.css');
#import url('CSS/typography.css');
#import url('CSS/navigation.css');
#import url('CSS/masthead.css');
#import url('CSS/banner.css');
#import url('CSS/boxes.css');
#import url('CSS/levels.css');
here is another css file:
/******** Boxes Stylesheet ********/
.box{
margin: 0 0 1em;
border-bottom: 1px solid #000;
}
.box img {
border: 2px solid #000;
}
.box-title {
font-family: 'Nunito', sans-serif;
font-weight: 300;
color: black;
padding: 0;
}
.box p {
font-family: 'Nunito', sans-serif;
color: black;
font-size: 1.2em;
}
.box a {
color: #000;
text-decoration: none;
display: block;
padding: .25em;
}
#media screen and (min-width: 768px){
.boxes {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.box {
width: calc(33.333333% - .5em);
}
}
The text is white (not recognized) after justify-content: and also after Flex-wrap:
Thank you for your time. (first post so tell me if I posted wrong)
Your selectors are inverted in the CSS media query.
Change:
#media screen and (min-width: 768px){
.boxes {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.box {
width: calc(33.333333% - .5em);
}
}
For:
#media screen and (min-width: 768px){
.box {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.boxes {
width: calc(33.333333% - .5em);
}
}
Code Snippet:
/******** Boxes Stylesheet ********/
.box {
margin: 0 0 1em;
border-bottom: 1px solid #000;
}
.box img {
border: 2px solid #000;
}
.box-title {
font-family: 'Nunito', sans-serif;
font-weight: 300;
color: black;
padding: 0;
}
.box p {
font-family: 'Nunito', sans-serif;
color: black;
font-size: 1.2em;
}
.box a {
color: #000;
text-decoration: none;
display: block;
padding: .25em;
}
#media screen and (min-width: 768px) {
.box {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.boxes {
width: calc(33.333333% - .5em);
}
}
<main class="main-area">
<section class="box">
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="http://placehold.it/100x100">
<div class="box-text">
<h2 class="box-title">
Blue Firework
</h2>
<p class="box-blurb">
Image subtext
</p>
</div>
</figure>
</a>
</article>
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="http://placehold.it/100x100">
<div class="box-text">
<h2 class="box-title">
Purple Firework
</h2>
<p class="box-blurb">
Image subtext
</p>
</div>
</figure>
</a>
</article>
<article class="boxes">
<a href="#">
<figure class="featured-image">
<img src="http://placehold.it/100x100">
<div class="box-text">
<h2 class="box-title">
Orange Firework
</h2>
<p class="box-blurb">
Image subtext
</p>
</div>
</figure>
</a>
</article>
</section>
</main>
<!-- Close the main section -->
Not every editor is updated with the latest keywords, don't worry space-between is a valid CSS value for justify-content property. You can check out the accepted values for justify-content here and here.