i've maked a portfolio website but i have the problem that i can't center the cards(like in the picture). When i try to put the "cards" in the from the navbar i can't center it on the site, but when i don't do this it is under the navbar.
And can someone explain me how i create a responsive webdesign?
i hope anyone can help me.
const list = document.querySelectorAll('.list');
function activeLink(){
list.forEach((item) =>
item.classList.remove('active'));
this.classList.add('active');
}
list.forEach((item) =>
item.addEventListener('click',activeLink));
.container {
position: relative;
font-family: 'Roboto', monospace;
display: flex;
justify-content: center;
align-items: center;
max-width: 1850px;
flex-wrap: wrap;
}
.container .card {
position: relative;
width: 280px;
height: 400px;
margin: 30px;
box-shadow: 20px 20px 50px rgba(0, 0, 0, 0.5);
border-radius: 15px;
background: rgba(255, 255, 255, 0.1);
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
border-top: 1px solid rgba(255, 255, 255, 0.5);
border-left: 1px solid rgba(255, 255, 255, 0.5);
backdrop-filter: blur(5px);
}
.container .card .content {
font-family: 'Roboto', monospace;
padding: 20px;
text-align: center;
transform: translateY(100px);
opacity: 0;
transition: 0.5s;
}
.container .card:hover .content {
transform: translateY(0px);
opacity: 1;
}
.container .card .content h2 {
position: absolute;
top: -80px;
right: 30px;
font-size: 8em;
color:rgba(255, 255, 255, 0.05);
pointer-events: none;
}
.container .card .content h3 {
font-size: 1.8em;
color: #fff;
z-index: 1;
}
.container .card .content p {
font-size: 1em;
color: #fff;
font-weight: 300;
transform-style: preserve-3d;
}
.container .card .content a {
position: relative;
display: inline-block;
padding: 8px 20px;
margin-top: 15px;
background: #fff;
color: #000;
border-radius: 20px;
text-decoration: none;
font-weight: 500;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
<div class="centernav">
<div class="navbar">
<ul>
<li class="list active">
<a href="#">
<span class="icon"><ion-icon name="home-outline"></ion-icon></span>
<span class="title">Home</span>
</a>
</li>
<li class="list">
<a href="2profil.html">
<span class="icon"><ion-icon name="person-outline"></ion-icon></span>
<span class="title">Profil</span>
</a>
</li>
<li class="list">
<a href="4settings.html">
<span class="icon"><ion-icon name="settings-outline"></ion-icon></span>
<span class="title">Setting</span>
</a>
</li>
<li class="list">
<a href="5Galerie.html">
<span class="icon"><ion-icon name="images-outline"></ion-icon></span>
<span class="title">Galerie</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="8contact.php">
<span class="icon"><ion-icon name="mail-outline"></ion-icon></span>
<span class="title">Kontakt</span>
</a>
</li>
</ul>
</div>
<!--Den Container genau neben der Navbar ohne den Container in die Div
der Navbar rein zu packen
-->
<!--========== Inhalt Profil ==========-->
</div>
<div class="container">
<div class="card">
<div class="content">
<h2>01</h2>
<h3>Profil</h3>
<p> Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod temopr incididunt
ut labore et dolor magna aliqua </p>
<a href="profil_readmore.html">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>02</h2>
<h3>Main Skills</h3>
<p>Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod temopr incididunt
ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>03</h2>
<h3>Tools</h3>
<p>Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod temopr incididunt
ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
</div>
</div>
<!--========== Java Script ==========-->
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
You can use flex to align them. I have edited two other things : spelling mistakes and a little more decoration.
Note : This navbar is not responsive. the cards are responsive.
So here is your final code :
const list = document.querySelectorAll('.list');
function activeLink() {
list.forEach((item) =>
item.classList.remove('active'));
this.classList.add('active');
}
list.forEach((item) =>
item.addEventListener('click', activeLink));
.container {
position: relative;
font-family: 'Roboto', monospace;
display: flex;
justify-content: center;
align-items: center;
max-width: 1850px;
flex-wrap: wrap;
}
.container .card {
position: relative;
width: 280px;
height: 400px;
margin: 30px;
box-shadow: 20px 20px 50px rgba(0, 0, 0, 0.5);
border-radius: 15px;
background: rgba(255, 255, 255, 0.1);
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
border-top: 1px solid rgba(255, 255, 255, 0.5);
border-left: 1px solid rgba(255, 255, 255, 0.5);
backdrop-filter: blur(5px);
}
.container .card .content {
font-family: 'Roboto', monospace;
padding: 20px;
text-align: center;
transform: translateY(100px);
opacity: 0;
transition: 0.5s;
}
.container .card:hover .content {
transform: translateY(0px);
opacity: 1;
}
.container .card .content h2 {
position: absolute;
top: -80px;
right: 30px;
font-size: 8em;
color: rgba(255, 255, 255, 0.05);
pointer-events: none;
}
.container .card .content h3 {
font-size: 1.8em;
color: #fff;
z-index: 1;
}
.container .card .content p {
font-size: 1em;
color: #fff;
font-weight: 300;
transform-style: preserve-3d;
}
.container .card .content a {
position: relative;
display: inline-block;
padding: 8px 20px;
margin-top: 15px;
background: #fff;
color: #000;
border-radius: 20px;
text-decoration: none;
font-weight: 500;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.someclass {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.someclass .list {
margin: 10px;
list-style: none;
}
.someclass .list a {
text-decoration: none;
}
<div class="centernav">
<div class="navbar">
<ul class="someclass">
<li class="list active">
<a href="#">
<span class="icon"><ion-icon name="home-outline"></ion-icon></span>
<span class="title">Home</span>
</a>
</li>
<li class="list">
<a href="2profil.html">
<span class="icon"><ion-icon name="person-outline"></ion-icon></span>
<span class="title">Profile</span>
</a>
</li>
<li class="list">
<a href="4settings.html">
<span class="icon"><ion-icon name="settings-outline"></ion-icon></span>
<span class="title">Settings</span>
</a>
</li>
<li class="list">
<a href="5Galerie.html">
<span class="icon"><ion-icon name="images-outline"></ion-icon></span>
<span class="title">Galery</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="8contact.php">
<span class="icon"><ion-icon name="mail-outline"></ion-icon></span>
<span class="title">Contact</span>
</a>
</li>
</ul>
</div>
<!--Den Container genau neben der Navbar ohne den Container in die Div
der Navbar rein zu packen
-->
<!--========== Inhalt Profil ==========-->
</div>
<div class="container">
<div class="card">
<div class="content">
<h2>01</h2>
<h3>Profile</h3>
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua </p>
<a href="profil_readmore.html">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>02</h2>
<h3>Main Skills</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>03</h2>
<h3>Tools</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
</div>
<!--========== Java Script ==========-->
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
I hope this helps you :)
CodePudding user response:
This is the full css Code
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto Mono:ital,wght@0,500;0,600;0,700;1,500;1,600;1,700&display=swap');
* {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
box-sizing: border-box;
}
.background {
background: #232c33;
}
.centernav {
position: relative;
display: inline-flex;
align-items: center;
min-height: 100vh;
}
.navbar {
position: relative;
height: 500px;
width: 70px;
background: #2b343b;
box-shadow: 10px 0 0 #4187f6;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-left: 10px solid #2b343b;
overflow-x: hidden;
transition: width 0.5s;
}
.navbar:hover {
width: 280px;
}
.navbar ul {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding-left: 5px;
padding-top: 40px;
}
.navbar ul li {
position: relative;
list-style: none;
width: 100%;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
}
.navbar ul li.active {
background: #4187f6;
}
.navbar ul li a {
position: relative;
display: inline-block;
width: 100%;
display: flex;
text-decoration: none;
color: #fff;
}
.navbar ul li.active a::before {
content: '';
position: absolute;
top: -30px;
right: 0;
width: 30px;
height: 30px;
background: #2b343b;
border-radius: 60%;
box-shadow: 15px 15px 0 #4187f6;
}
.navbar ul li.active a::after {
content: '';
position: absolute;
bottom: -30px;
right: 0;
width: 30px;
height: 30px;
background: #2b343b;
border-radius: 60%;
box-shadow: 15px -15px 0 #4187f6;
}
.navbar ul li a .icon {
position: relative;
display: inline-block;
min-width: 60px;
height: 60px;
line-height: 70px;
text-align: center;
}
.navbar ul li a .icon ion-icon {
position: relative;
font-size: 1.5em;
z-index: 1;
}
.navbar ul li a .title {
position: relative;
display: inline-block;
padding-left: 10px;
height: 60px;
line-height: 60px;
white-space: nowrap;
}
/*Profil*/
.container {
position: relative;
font-family: 'Roboto', monospace;
display: flex;
justify-content: center;
align-items: center;
max-width: 1850px;
flex-wrap: wrap;
}
.container .card {
position: relative;
width: 280px;
height: 400px;
margin: 30px;
box-shadow: 20px 20px 50px rgba(0, 0, 0, 0.5);
border-radius: 15px;
background: rgba(255, 255, 255, 0.1);
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
border-top: 1px solid rgba(255, 255, 255, 0.5);
border-left: 1px solid rgba(255, 255, 255, 0.5);
backdrop-filter: blur(5px);
}
.container .card .content {
font-family: 'Roboto', monospace;
padding: 20px;
text-align: center;
transform: translateY(100px);
opacity: 0;
transition: 0.5s;
}
.container .card:hover .content {
transform: translateY(0px);
opacity: 1;
}
.container .card .content h2 {
position: absolute;
top: -80px;
right: 30px;
font-size: 8em;
color: rgba(255, 255, 255, 0.05);
pointer-events: none;
}
.container .card .content h3 {
font-size: 1.8em;
color: #fff;
z-index: 1;
}
.container .card .content p {
font-size: 1em;
color: #fff;
font-weight: 300;
transform-style: preserve-3d;
}
.container .card .content a {
position: relative;
display: flex;
text-align: center;
padding: 8px 20px;
margin-top: 15px;
background: #fff;
color: #000;
border-radius: 20px;
text-decoration: none;
font-weight: 500;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
/*Galerie*/
.Frame {
position: relative;
display: flex;
justify-content: center;
align-items: center;
border-radius: 30px;
border: 3px solid black;
margin: 0 710px 10px 710px;
}
.Frame img {
border-radius: 25px;
width: 500px;
height: 600px;
overflow-x: hidden;
opacity: 0%;
transition: 0.5s;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.Frame img:hover {
opacity: 100%;
}
and this the full html code
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title> Portfolio </title>
<link rel="stylesheet" href="style/style.css">
</head>
<body class="background">
<div class="centernav">
<div class="navbar">
<li class="list active">
<a href="#">
<span class="icon"><ion-icon name="home-outline"></ion-icon></span>
<span class="title">Home</span>
</a>
</li>
<li class="list">
<a href="2profil.html">
<span class="icon"><ion-icon name="person-outline"></ion-icon></span>
<span class="title">Profile</span>
</a>
</li>
<li class="list">
<a href="4settings.html">
<span class="icon"><ion-icon name="settings-outline"></ion-icon></span>
<span class="title">Settings</span>
</a>
</li>
<li class="list">
<a href="5Galerie.html">
<span class="icon"><ion-icon name="images-outline"></ion-icon></span>
<span class="title">Galery</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="#">
<span class="icon"><ion-icon name="hourglass-outline"></ion-icon></span>
<span class="title">Cooming Soon</span>
</a>
</li>
<li class="list">
<a href="8contact.php">
<span class="icon"><ion-icon name="mail-outline"></ion-icon></span>
<span class="title">Contact</span>
</a>
</li>
</ul>
</div>
<!--Den Container genau neben der Navbar ohne den Container in die Div
der Navbar rein zu packen
-->
<!--========== Inhalt Profil ==========-->
</div>
<div class="container">
<div class="card">
<div class="content">
<h2>01</h2>
<h3>Profile</h3>
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua </p>
<a href="profil_readmore.html">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>02</h2>
<h3>Main Skills</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
<div class="card">
<div class="content">
<h2>03</h2>
<h3>Tools</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod temopr incididunt ut labore et dolor magna aliqua. </p>
<a href="#">Read More</a>
</div>
</div>
</div>
<!--========== Java Script ==========-->
<script>
const list = document.querySelectorAll('.list');
function activeLink(){
list.forEach((item) =>
item.classList.remove('active'));
this.classList.add('active');
}
list.forEach((item) =>
item.addEventListener('click',activeLink));
</script>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>