So i am currently working on a website and i have a problem aligning the flexbox items(logo and title) in the header. They always align underneath each other and i need them side by side.
I read through the similar problems of others in stackoverflow and i also have googled for min. 2 hours.
I have to say learned many things about positioning and flexbox but i can't solve it.
There are many more things that i havent really cared about yet on the website but they don't matter for now, just overlook them :'D
But if you have some Tip's i still would be very thankful cause im new into creating websites :)
#import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
#import url('https://fonts.googleapis.com/css?family=Sniglet');
#import url('https://fonts.googleapis.com/css?family=Dosis&display=swap');
#import url('https://fonts.googleapis.com/css?family=Dancing+Script');
/*all*/
html,
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
max-width: 100%;
box-sizing: border-box;
}
* {
box-sizing: inherit;
font-family: 'Dosis', sans-serif;
/*, cursive |zum kursiv*/
}
/*For PC's*/
#media screen and (min-width: 950px) {
.wrapper {
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto auto auto;
/*NOT sur about the auto*/
grid-template-areas: "header" "main" "footer";
background-color: #ffc5c9;
}
/*Nav Menu*/
.navigation_wrapper {
position: relative;
}
.navigation_button {
will-change: transform;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
position: fixed;
z-index: 1;
top: 40px;
left: 100px;
background: transparent;
cursor: pointer;
}
.navigation_button .fa {
border: 2px solid white;
border-radius: 3px;
padding: 10px;
color: white;
}
.navigation_menu ul li {
list-style: none;
font-weight: 250;
color: #79E2DD;
/*font-family: impact; könnte hier noch geändert werden*/
}
.navigation_menu {
content: '';
position: fixed;
top: 0;
right: 0;
width: 50%;
background: white;
height: 100%;
transform: skewX(0deg) translate(100%, 0);
transform-origin: top right;
transition: all .2s ease-in;
z-index: -1;
}
.navigation_menu ul {
transform: skewX(-8deg);
transform-origin: top left;
position: fixed;
left: 100px;
top: 100px;
width: 400px;
text-align: left;
}
.navigation_menu ul li {
position: relative;
z-index: 999;
font-size: 32px;
color: #F4E1A6;
line-height: 64px;
}
.navigation_menu ul li a {
border: none;
color: #FFC59;
text-decoration: none;
}
.navigation_menu.active {
transform: skewX(8deg) translate(0, 0);
}
.navigation_menu li {
opacity: 0;
transform: translate(0, 10px);
transition: all .0s ease-in .3s;
}
.navigation_menu.active li {
opacity: 1;
transform: translate(0, 0);
transition: all 0.2s ease-in 0s;
}
.navigation_menu.active li:nth-child(1) {
transition-delay: .3s;
}
.navigation_menu.active li:nth-child(2) {
transition-delay: .4s;
}
.navigation_menu.active li:nth-child(3) {
transition-delay: .5s;
}
.navigation_menu.active li:nth-child(4) {
transition-delay: .6s;
}
.navigation_menu.active li:nth-child(5) {
transition-delay: .7s;
}
.navigation_menu.active li:nth-child(6) {
transition-delay: .8s;
}
/*Scrollbar*/
/*Skeleton*/
.head_wrapper {
grid-area: header;
height: auto;
padding: 3rem 5rem 3rem;
background-image: url("../pictures/TP4.jpeg");
background-size: cover;
background-repeat: no-repeat;
border-radius: 0 0 50px 50px;
}
.main_wrapper {
grid-area: main;
margin: 2rem;
padding: 20px;
min-height: 100%;
background-color: #feeee6;
border-radius: 50px;
}
.foot_wrapper {
background-color: #f4e1a6;
grid-area: footer;
border-radius: 50px 50px 0 0;
}
/*for Sticky Footer*/
.foot_wrapper,
.push {
height: 15rem;
}
/*flex containers*/
.head_flex_container {
display: flex;
justify-content: space-between;
flex-direction: column;
flex-wrap: wrap;
}
/*flex items*/
.head_titel_container {
border: 5px solid blue;
max-height: 22rem;
min-width: 100%;
position: relative;
}
.flex_titel {
position: absolute;
right: 0;
width: 78%;
box-sizing: content-box;
border: 5px solid black;
}
.flex_logo {
width: 22%;
box-sizing: border-box;
border: 5px solid pink;
}
/*Titles*/
h1 {}
h2 {}
/*Texts*/
.index {}
/*classes*/
/*ID's*/
#logo {
height: auto;
min-width: 5rem;
max-width: 20rem;
border-radius: 100%;
box-sizing: border-box;
}
#pb1 {}
/*Decoration*/
hr {}
}
<div class="wrapper">
<div class="scroll_wrapper">
<div class="scrollbar" id="style-default">
<div class="force-overflow"></div>
</div>
<div class="navigation_wrapper">
<div class="navigation_button">
<i class="fa fa-bars"></i>
</div>
<div class="navigation_menu">
<ul>
<li>Home</li>
<li>Gallerie</li>
<li>
Kontakt</li>
<li>
<a class="active" href="hier link rein"></a>
</li>
<li>
<a class="active" href="hier link rein"></a>
</li>
</ul>
</div>
</div>
<header>
<div class="head_wrapper">
<div class="head_flex_container">
<div class="head_titel_container">
<div class="flex_logo"><img src="pictures/Logo.jpeg" alt="Logo" title="El Pastelazo" id="logo"></div>
<div class="flex_titel">
<h1>El Pastelazo</h1>
</div>
</div>
</div>
</div>
</header>
<main class="main">
<div class="main_wrapper">
<div class="home_picture"><img src="pictures/PI.jpg" alt="Picture" title="Loah" id="pb1"></div>
<div class="pagetitle">
<h2>Home</h2>
</div>
<p class="index">
<h3>Wilkommen!</h2>
<hr class="hr_01"> hier kann loah sich und ihre arbeit bzw was Sie auf dieser Website macht eintragen. Damit dieser Text hier möglichst lang ist werde ich einfach irgend ein Scheiss labern. Eigentlich will ich ihn auch nicht wirklich möglichst lang machen sondern
nur so lang, wie auch ungefähr eine Vorstellung bzw Beschreibung sein würde. Ich würde mal sagen, diese länge an Text sollte genügen.
</p>
<div class="push"></div>
</div>
</main>
<footer>
<div class="foot_wrapper">
<a class="foot_item" href="https://www.instagram.com/el_pastelazo_/?hl=de" title="#el_pastelazo_"><i class="fab fa-instagram"></i></a>
<a class="foot_item" href="https://github.com/" title="Probably Insta"><i class="fa fa-github"></i></a>
<a class="foot_item" href="https://www.pinterest.de/" title="Pinterest"><i class="fa fa-pinterest-p"></i></a>
<a class="foot_item" href="https://www.gmx.ch/" title="Mail"><i class="fa fa-envelope-o"></i></a>
</div>
</footer>
</div>
Adding display:flex style to an HTML element by default make its children appear side by side unless you explicitly add flex-direction: column;.
After Looking at your html carefully I see that you have added display:flex to head_flex_container which has only one child i.e head_titel_container.
You could add display:flex property to head_titel_container because it has two children that needs to appear side by side.
<div class="head_titel_container">
<div class="flex_logo"><img src="pictures/Logo.jpeg" alt="Logo" title="El Pastelazo" id="logo"></div>
<div class="flex_titel"><h1>El Pastelazo</h1></div>
</div>
.head_titel_container {
display: flex;
}
Adding display: flex style to .head_titel_container in your css file should make them appear side by side.
Let me know if you have any problems with this approach.
Did you want something like this?
/*flex items*/
.head_titel_container{
border: 5px solid blue;
max-height: 22rem;
width: 50%;
min-width: 50%;
position: relative;
display: inline-block;
}
.flex_titel{
position: absolute;
left:800px;
top:-10px;
width: 78%;
box-sizing: content-box;
border: 5px solid black;
display: inline-block;
}
By the way, there's this website called JSFiddle where you can post your code for a quick demo. Might be useful in the future.
Related
I have two big problems:
The first trouble I have encountered is that when I am testing the responsivity of my website in the contact section I always meet a reappearing problem: There is a white space (.2 rem - 1.2rem width) on the right side of the body when I try to display the whole page under 400px width device.
My second problem is that I have social media icons in the footer. They appear properly in all other sections (multipage website), but only here does something prevent them to be displayed properly. I tried resizing their main divs to 100% width and 100% max-width, but an element is probably still longer than the others, which should obviously cause this kind of problem.
So about the white blank area, I think it is important to know that I have a specially styled scrollbar, which might also cause this little mischief. I am unsure, so I have also tried removing it, but it did not help. In the beginning, I also encountered the same problem with the footer, but somehow I managed to get by and was able to solve it by correcting the width of the .footer-container. Since then the white space appeared and my second problem with social media icons not being displayed properly just arose.
Here is my code:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="contacts.css">
<title>Eckert Művek Galéria</title>
</head>
<body>
<div class="floating-btn show-btn" aria-label="up button" role="button">
<img src="assets/svg_files/chevron-up-solid.svg" alt="up img" />
</div>
<header>
<!--NAVBAR-->
<nav>
<ul class="menu" id="desktop-menu">
<li class="nav-item">Főoldal</li>
<li class="nav-item">Rólunk</li>
<li class="nav-item">Szolgáltatások</li>
<li class="nav-item">Miért mi?</li>
<li class="nav-item">Galéria</li>
<li class="nav-item">Kapcsolat</li>
</ul>
<!--HAMBURGER ICON-->
<div class="header-right-gap">
<button class="hamburger" aria-label="hamburger button">
<div class="line line-1"></div>
<div class="line line-2"></div>
<div class="line line-3"></div>
</button>
</div>
</nav>
<!--MOBILE MENU-->
<div class="mobile-menu">
<ul class="m-menu">
<li class="nav-item">Főoldal</li>
<li class="nav-item">Rólunk</li>
<li class="nav-item">Szolgáltatások</li>
<li class="nav-item">Miért mi?</li>
<li class="nav-item">Galéria</li>
<li class="nav-item">Kapcsolat</li>
</ul>
</div>
</header>
<main>
<!--CONTACT FORM-->
<div class="container">
<form>
<h1>Kapcsolat</h1>
<input type="text" id="firstName" placeholder="Családnév" required>
<input type="text" id="lastName" placeholder="Keresztnév" required>
<input type="email" id="email" placeholder="Email" required>
<input type="text" id="mobile" placeholder="Telefonszám" required>
<h4 class="contactus">Lépjen velünk kapcsolatba!</h4>
<textarea id="texti" required></textarea>
<input type="submit" value="Elküldés" id="button">
</form>
</div>
</main>
<footer>
<div class="footer-container">
<!--COMPANY INFORMATION, CONTATCTS-->
<div class="footer-top">
<div>
<article>
<h2>Elérhetőségeink</h2>
<div class="cellphone">
<img src="assets/png/telephone.png" alt="phone-icon">
<h3><span>Telefonszám:</span> +36709424298</h3>
</div>
<div class="internet">
<img src="assets/png/mail.png" alt="email-icon">
<h3><span>E-mail:</span> eckertmuvek#gmail.com</h3>
</div>
<div class="headquarter">
<img src="assets/png/location.png" alt="company-icon">
<h3><span>Telephely:</span> Budapest, 1182 Török Bálint u. 16/b</h3>
</div>
<div class="opening-hours">
<img src="assets/png/clock.png" alt="op-icon">
<h3><span>Nyitvatartási idő:</span> hétfő - péntek(7:00 - 17:30)</h3>
</div>
</article>
</div>
<!--TEXT-->
<div class="text-container">
<h4>Céginformációk</h4>
<p>
<ol>
<li>
<h5>Cégjegyzékszám: </h5>
<p> 01 09 996342</p>
</li>
<li>
<h5>Adószám: </h5>
<p>24222716243</p>
</li>
<li>
<h5>Számlaszám: </h5>
<p>112131423-43242142-432412421</p>
</li>
<li>
<h5>Cégnév: </h5>
<p>Eckert Művek Korlátolt Felelősségű Társaság</p>
</li>
</ol>
</p>
</div>
<!--
<div class="text-container">
<h4>Ttitle-1</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
Dicta modi laborum quibusdam quis natus debitis qui dolor
voluptatibus ab sit, cum saepe enim unde doloribus veniam
numquam perspiciatis optio impedit.</p>
</div>
-->
<!--POLICIES-->
<div class="policies">
Impresszum
GDPR Tájékoztató
Süti Tájékoztató
</div>
</div>
<!--MAP-->
<div class="map">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2699.366130757782!2d19.217992451587673!3d47.42430370844346!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4741c1f21fa88e89%3A0x44673b68b84b51c9!2zQnVkYXBlc3QsIFTDtnLDtmsgQsOhbGludCB1LiAxNmIsIDExODI!5e0!3m2!1shu!2shu!4v1672662477180!5m2!1shu!2shu"
height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
</div>
<!--SOCIAL MEDIA ICONS-->
<div class="social-media-icons">
<div class="sm-container" id="insta">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="github">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="facebook">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="linkedin">
<div class="sm-icon">
</div>
</div>
</div>
<div class="footer-bottom">
<p>© Eckert Művek Kft. Minden jog fenntartva.</p>
</div>
</div>
</footer>
<script src="contacts.js"></script>
</body>
</html>
And here is my CSS code:
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#100;200;300;400;500;600;700;800;900&display=swap');
:root {
--nav-height: 100px; /*80%*/
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
}
html {
scroll-behavior: smooth;
}
body {
min-height: 100vh;
width: 100%;
font-size: 12px;
font-family: sans-serif;
}
.floating-btn {
position: fixed;
bottom: 3.5vh;
right: 0;
width: 50px;
height: 50px;
z-index: 100;
background-color: yellow;
border-radius: 50%;
padding: 10px;
box-shadow: 0 0 5px hsla(0, 0%, 0%, hsla(0,0%,0%,0.5));
cursor: pointer;
margin-right: 1rem;
border: 1px solid #000;
}
.show-btn {
display: block;
}
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100px;
z-index: 100;
background-color: #000;
}
/*Srcollbar*/
::-webkit-scrollbar{
width: 15px;
background: #000;
}
::-webkit-scrollbar-thumb {
background: yellow;
border-radius: 10px;
border: 1px solid black;
}
::-webkit-scrollbar-thumb:active {
background: orangered;
}
nav {
display: flex;
width: min(90%, 1200px);
height: inherit;
align-items: center;
justify-content: flex-start;
margin-inline: unset;
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 20px;
left: 2.5rem;
gap: 1rem;
/*margin-top: -2.5rem;*/
}
nav a {
max-height: var(--nav-height);
align-items: center;
margin-inline: auto;
font-size: 20px;
position: relative;
height: 100%;
}
nav ul {
display: flex;
gap: 1rem;
width: 100%;
list-style: none;
margin-top: 3rem;
}
.nav-item a {
color: white;
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
font-size: 20px;
height: 100%;
margin: .5em .8em;
padding: 10px;
}
.nav-item a::before,
.nav-item a::after {
content: '';
height: 14px;
width: 14px;
position: absolute;
transition: all .35s ease;
opacity: 0;
}
nav a::before {
content: '';
right: 0;
top: 0;
border-top: 3px solid #ffed4b;
border-right: 3px solid #fdcd3b;
transform: translate(-100%, 50%); /*-100%, 50%*/
}
.nav-item a:after {
content: '';
left: 0;
bottom: 0;
border-bottom: 3px solid #fdcd3b;
border-left: 3px solid #ffed4b;
transform: translate(100%, -50%); /*100%, -50%*/
}
.nav-item a:hover:before,
.nav-item a:hover:after{
transform: translate(0,0);
opacity: 1;
}
.nav-item a:hover {
text-decoration: underline;
color:yellow;
}
.container{
min-height: 100vh;
width: 99.vw;
background: #08071d;
display: flex;
justify-content: center;
align-items: center;
background: url("assets/images/mainpage/106811484-1608045351058-gettyimages-1126750618-dsc_1540.jpeg") no-repeat center center/cover;
}
.container form{
width: 670px; /*670px*/
height: 450px;
display: flex;
justify-content: center;
box-shadow: 20px 20px 50px rgba(0,0,0,0.5);
border-radius: 15px;
background: rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
flex-wrap: wrap;
overflow-x: hidden;
}
.container form h1{
color: #fff;
font-weight: 500;
margin-top: 20px;
width: 500px;
text-align: center;
}
.container form input{
width: 290px;
height: 40px;
padding-left: 10px;
outline: none;
border: none;
font-size: 25px;
margin-bottom: 10px;
background: none;
border-bottom: 2px solid #fff;
}
.container form input::placeholder{
color: #ddd;
}
.container form #lastName,
.container form #mobile{
margin-left: 20px;
}
.container form h4{
color: #fff;
font-weight: 300;
width: 600px;
margin-top: 20px;
}
.container form textarea{
background: none;
border: none;
border-bottom: 2px solid #fff;
color: #fff;
font-weight: 200;
font-size: 25px;
padding: 10px;
outline: none;
min-width: 600px;
max-width: 600px;
min-height: 80px;
max-height: 80px;
}
.contactus {
font-size: 18px;
}
input[type="text"]:focus, input[type="email"]:focus, #texti:focus {
border-bottom: 3px solid #fdcd3b;
}
textarea::-webkit-scrollbar{
width: 1em;
}
textarea::-webkit-scrollbar-thumb{
background-color: rgba(194,194,194,0.713);
}
.container form #button{
border: 1px solid;
background: transparent;
border-radius: 50px;
margin-top: 20px;
font-weight: 600;
font-size: 20px;
color: #fff;
width: 100px;
padding: 0;
margin-right: 500px;
margin-bottom: 30px;
transition: 0.3s;
}
.container form #button:hover{
opacity: 0.9;
transform: scale(1.2);
background-color: black;
color: yellow;
}
/*FOOTER*/
footer {
width: 100%;
background-color: #000;
padding-block: 4rem;
color: white;
}
.footer-container {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-inline: auto;
width: min(90%, 1200px);
}
.footer-top {
width: 100%;
height: 100%;
color: #fff;
font-size: 10px;
display: flex;
justify-content: space-around;
}
.footer-top h2 {
text-align: center;
justify-content: center;
align-items: center;
}
.footer-top article div {
line-height: 2.5rem;
}
.footer-top article div:first-of-type {
margin-top: 1rem;
}
.footer-top img {
height: 64px;
}
.text-container p {
margin-top: 2rem;
}
.text-container ol li {
line-height: 1.5rem;
}
/*CONTACT ICONS*/
.cellphone img, .internet img, .headquarter img, .opening-hours img{
background-color: yellow;
border-radius: 50px;
transition: all 0.3s linear;
}
footer img:hover {
background-color: orangered;
border-radius: 40px;
transform: rotate(-360deg);
}
.footer-bottom {
text-align: center;
margin-top: 2rem;
}
span {
color: yellow;
}
.text-container {
justify-content: space-between;
width: 20vw;;
font-size: 0.8rem;
}
/*POLICIES LINKS*/
.policies {
display: flex;
flex-direction: column;
font-size: 14px;
text-transform: uppercase;
}
.policies a {
color: yellow;
font-size: 10px;
line-height: 2rem;
}
.policies a:hover {
color: orangered;
}
/*MAP*/
.map {
margin-inline: auto;
}
/*SOCIAL MEDIA ICONS*/
.social-media-icons {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.sm-container {
display: flex;
justify-content: center;
gap: 2rem;
padding:1rem;
border: 1px black;
width: 100%;
height: 100%;
}
.sm-container a:active {
color: yellow;
}
.fa {
border-radius: 50%;
width: 100%;
height: 100%;
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: 30px;
/**/
}
.fa-instagram {
background: #125688;
color: white;
padding: 1rem;
}
.fa-github {
background: white;
color: black;
padding: 1rem;
}
.fa-facebook {
background: #4267B2;
color: white;
padding: 1rem;
}
.fa-linkedin {
background: #3B5998;
color: white;
padding: 1rem;
}
.sm-icon {
transition: all 0.3s linear;
}
.sm-icon:hover {
transform: scale(1.2);
}
.fa:hover {
background-color: #fdcd3b;
}
/*MOBILE MENU*/
.mobile-menu {
display: none;
}
.mobile-menu {
display: flex;
width: 100%; /*.line a szülő tehát 40px a width*/
height: calc(100vh - 80px);
align-items: center;
justify-content: center;
position: absolute;
top: 80px;
left: 0;
background-color: black;
transform: translate(-100%);
transition: all 0.4s ease;
z-index: 100;
}
.mobile-menu-on {
display: flex; /**/
transform: translate(0);
}
.m-menu {
display: flex;
flex-direction: column;
gap: 2rem;
text-align: center;
font-size: 1.4rem;
}
/*hamburger icon*/
.header-right-gap {
width: 100px;
margin-left: 2rem;
}
.hamburger {
display: none;
position: fixed;
width: 50px;
height: 50px;
border: none;
background-color: transparent;
top: 0;
left: 1;
margin-top: 1.5rem;
}
.hamburger:hover {
border: 6px solid;
border-color: yellow;
width: 43px;
margin-left: 4px;
transform: scale(1.2);
}
.hamburger:hover .line.line-1 {
/*display: none;*/
transform: rotate(45deg) translateY(7.5px);
background-color: yellow;
}
.hamburger:hover .line.line-2 {
display: none;
}
.hamburger:hover .line.line-3 {
/*display: none;*/
transform: rotate(-45deg) translateY(-7.5px);
background-color: yellow;
}
.line {
transition: all .4s ease;
width: 40px;
height: 5px;
background-color: white;
margin-block: 5px;
border-radius: 10px;
}
/*Media query*/
#media (max-width: 1200px) {
.hamburger {
display: block;
}
#desktop-menu {
display: none;
}
}
#media (max-width: 900px) {
footer nav ul {
flex-direction: column;
}
footer nav ul li a {
font-size: 15px;
/*padding: 15px;*/
}
}
#media (max-width: 750px) {
.footer-container {
display: flex;
flex-wrap: wrap;
}
footer nav ul li a {
font-size: 10px;
padding: 15px;
}
.text-container p {
font-size: 10px;
}
}
#media (max-width: 600px) {
.container form {
width: 470px;
}
.container form input {
width: 160px;
}
.container form #button, .container form h4 {
margin-inline: auto;
}
.container form textarea {
min-width: 300px;
max-width: 300px;
}
}
#media (max-width: 400px) {
.container {
max-width: 100%;
height: 100%;
overflow: hidden;
}
.container form {
max-width: 100%;
padding-top: 40px;
padding-bottom: 10px;
}
.container form input, h4 {
text-align: center;
}
.container form input {
width: 160px;
}
.container form #button, .container form h4 {
margin-inline: auto;
}
.container form textarea {
align-items: center;
min-width: 300px;
max-width: 300px;
}
.text-container {
width: 70vw;
}
.container form #button {
display: flex;
flex-direction: column;
}
footer {
width: 400px;
}
.footer-top {
display: flex;
flex-direction: column;
align-items: center;
}
}
I once had a similar problem and it was due to margin of one element being bigger than it should be, and it just made that div bigger and pushed it out of viewport, so you could check your margins, I can see that you have quite a lot of margins, inline and to margin-right as well.
I am trying to realize a flipping card menu using only HTML & CSS. It is almost done except that the back side of the card takes time to display when receiving the first hover state. It's kind of doing the smooth transition move just for 90deg, then it goes instantly to display the final outcome (No more smooth transition done for the last 90deg).
After the first hover, everything goes fine.
Any suggestions?
EDIT: the snippet below has been edited to fit the correct answer.
#import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap');
.main{
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Open Sans', sans-serif;
background-color: #000;
}
.header{
color:white;
font-size: 2vh;
margin-bottom: 2vh;
}
.header a{
text-decoration: none;
color: white;
font-weight: bold;
}
.card{
background-color: transparent;
width: 30vh;
height: 50vh;
perspective: 1000px;
perspective-origin: center;
margin-right: 0.5vh;
}
.card > .card-container{
position: relative;
width: 100%;
height: 100%;
transition: 1s transform ease;
transform-style: preserve-3d;
background-color: transparent;
}
.card:hover > .card-container{
transform: rotateY(180deg);
}
.card-container > .front,.card-container > .back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.card-container > .front{
background-image: linear-gradient(to bottom right,red, yellow);
display: flex;
justify-content: center;
align-items: center;
border-radius: 0.5vh;
color: white;
font-size: 3vh;
cursor: pointer;
backface-visibility: hidden;
}
.card-container > .back{
background-color: transparent;
color: white;
font-size: 3vh;
transform: rotateY(180deg);
cursor: pointer;
}
.back > ul{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
perspective: 1000px;
perspective-origin: center ;
}
.back > ul > li{
text-align: center;
height: calc(100% - (0.2vh * 4) /5);
width: 100%;
transition: 1s transform ease;
transform-style: preserve-3d;
}
.back > ul > li:not(:last-child){
margin-bottom: 0.2vh;
}
.back > ul > li > .child-front, .back > ul > li > .child-back {
backface-visibility: hidden;
width: 100%;
height: 100%;
position: absolute;
top:0;
left: 0;
border-radius: 0.5vh;
}
.back > ul > li > .child-front{
background-image: linear-gradient(to bottom left,red, orange);
display: flex;
justify-content: center;
align-items: center;
}
.back > ul > li > .child-back{
background-color: orange;
transform: rotateX(180deg);
display: flex;
justify-content: center;
align-items: center;
}
.back > ul > li:hover{
transform: rotateX(180deg);
}
.child-back span, .child-front span{
color: white;
display: block;
}
.child-back span{
font-weight: bold;
}
<div class="main">
<div class="header">
Find me on Github
</div>
<div class="card">
<div class="card-container">
<div class="front">
<span>Hover here</span>
</div>
<div class="back">
<ul class="menu">
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM1</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM2</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM3</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM4</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM5</span></div>
</li>
</ul>
</div>
</div>
</div>
</div>
Delete backface-visibility: hidden;:
.card-container > .front,.card-container > .back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
It actually rotates 180deg but because of backface-visibility you don't see the whole transform. It shows you after the rotate finishes.
I have an issue in CSS while trying to fade in some elements in CSS.
I would like to show with a fade in effect some elements in my image right after the rotate transition but it doesn't work.
I did a jsfiddle and you can activate the effect with an hover on the image :
https://jsfiddle.net/egfjp36h/
Here's my HTML code :
<div class="flip-box">
<div class="fut-player-card card-display">
<div class="fut-front">
<div class="player-card-top player-card-top-color">
<div class="player-master-info">
<div class="player-rating">
<span>97</span>
</div>
<div class="player-position">
<span>RW</span>
</div>
<div class="player-nation">
<img src="https://selimdoyranli.com/cdn/fut_card/img/argentina.svg" alt="Argentina" draggable="false">
</div>
<div class="player-club">
<img src="https://selimdoyranli.com/cdn/fut_card/img/barcelona.svg" alt="Barcelona" draggable="false">
</div>
</div>
<div class="player-picture">
<img src="https://selimdoyranli.com/cdn/fut_card/img/messi.png" alt="Messi" draggable="false">
</div>
</div>
<div class="player-card-bottom">
<div class="player-info player-info-color">
<div class="player-name player-name-border"><span>MESSI</span></div>
<div class="player-features">
<div class="player-features-col player-features-col-border">
<span>
<div class="player-feature-value">97</div>
<div class="player-feature-title">RDV</div>
</span>
<span>
<div class="player-feature-value">95</div>
<div class="player-feature-title">CTR</div>
</span>
<span>
<div class="player-feature-value">94</div>
<div class="player-feature-title">TRANSF</div>
</span>
</div>
<div class="player-features-col player-features-col-border">
<span>
<div class="player-feature-value">99K€</div>
<div class="player-feature-title">CA</div>
</span>
<span>
<div class="player-feature-value">35</div>
<div class="player-feature-title">DEF</div>
</span>
<span>
<div class="player-feature-value">68</div>
<div class="player-feature-title">PHY</div>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
And my CSS :
.fut-player-card{
position: relative;
width:300px;
height:485px;
background-position: center center;
background-size:100% 100%;
background-repeat: no-repeat;
padding:5.9rem 0;
z-index: 2;
transition: 200ms ease-in;
margin-left: auto;
margin-right: auto;
}
.card-display{
background-image: url(https://selimdoyranli.com/cdn/fut_card/img/card_bg.png);
}
.card-display2{
background-image: url("img/fut/fut1.png");
}
.card-display3{
background-image: url("img/fut/fut2.png");
}
.card-display4{
background-image: url("img/fut/fut3.png");
}
.player-card-top{
position: relative;
display: flex;
padding: 0 3.5rem;
}
.player-master-info{
position: absolute;
line-height: 3.2rem;
font-weight: 300;
padding: 3rem 0;
text-transform: uppercase;
}
.player-rating{
font-size:3rem;
}
.player-position{
font-size: 2.2rem;
}
.player-nation{
display: block;
width:3rem;
height:25px;
margin: 0.5rem 0;
}
.player-nation img{
width:100%;
height: 100%;
object-fit: contain;
}
.player-club{
display: block;
width:3.1rem;
height:40px;
}
.player-club img{
width:100%;
height: 100%;
object-fit: contain;
}
.player-picture{
width:200px;
height:200px;
margin: 0 auto;
overflow: hidden;
}
.player-picture img{
width:100%;
height:100%;
object-fit: contain;
position: relative;
right: -1.5rem;
bottom: 0;
}
.player-extra{
position: absolute;
right:0;
bottom: -0.5rem;
overflow: hidden;
font-size:1rem;
font-weight: 700;
text-transform: uppercase;
width:100%;
height:2rem;
padding:0 1.5rem;
text-align: right;
background:none;
}
.player-extra span{
margin-left: 0.6rem;
text-shadow:2px 2px #333;
}
.player-card-bottom{
position: relative;
}
.player-info{
display: block;
padding:1rem 0;
width:90%;
margin:0 auto;
height: auto;
position: relative;
z-index: 2;
}
.player-info-color, .player-card-top-color{
color:#e9cc74;
}
.player-info-color2, .player-card-top-color2{
color:#130d40;
}
.player-name{
width:100%;
display: block;
text-align: center;
font-size:2.2rem;
text-transform: uppercase;
padding-bottom: 0.3rem;
overflow: hidden;
}
.player-name-border{
border-bottom: 2px solid;
border-color: rgba(233,204,116, 0.1);
}
.player-name-border2{
border-bottom: 2px solid;
border-color: rgba(13, 33, 74, 0.2);
}
.player-name span{
display: block;
text-shadow:2px 2px #111;
}
.player-name2 span{
display: block;
text-shadow:2px 2px #fff;
}
.player-features{
margin: 1rem auto;
display: flex;
justify-content: center;
}
.player-features-col{
border-right: 2px solid;
padding: 0 3rem;
}
.player-features-col-border{
border-color: rgba(233,204,116, 0.1);
}
.player-features-col-border2{
border-color: rgba(13,33,74, 0.2);
}
.player-features-col span{
display: flex;
font-size: 2rem;
text-transform: uppercase;
}
.player-feature-value{
margin-right: 1rem;
font-weight: 700;
}
.player-feature-title{
font-weight: 300;
}
.player-features-col:last-child{
border:0;
}
.flip-box {
perspective: 1000px;
display: inline-block;
}
.fut-player-card{
position: relative;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .fut-player-card{
transform: rotateY(180deg);
}
.flip-box:hover .fut-front{
filter: alpha(opacity=100);
opacity:1;
}
.fut-front{
position: absolute;
}
.fut-front{
transition: opacity 0.8s linear 1.2s;
filter: alpha(opacity=0);
opacity: 0;
}
I thought it was OK with those elements but the transition is effective when the mouse leave the image and not when the mouse comes over the image :
.flip-box:hover .fut-front{
filter: alpha(opacity=100);
opacity:1;
}
.fut-front{
transition: opacity 0.8s linear 1.2s;
filter: alpha(opacity=0);
opacity: 0;
}
EDIT : It works on Firefox but not on Chrome
You can select the element with javascript and add:
addEventListener("mouseenter", function( event ) {
//change opacity here
})
I want these images above to pop up when someone hovers over them, each image pops up and comes to the center when someone hovers a mouse over the image, also they should be arranged in that format. I want to do this in WordPress, I am designing a website and the client wants that effect. Is it possible friends? please someone assist me.
HTML code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<nav>
<img src="http://winn-brown.co.uk/wp-content/uploads/2016/06/Logo-new.png" id="logo">
</nav>
<div class="wrapper">
<div class="parent" onclick="">
<div class="child bg-one">
Los Angeles
</div>
</div>
<div class="parent right" onclick="">
<div class="child bg-two">
London
</div>
</div>
<div class="parent" onclick="">
<div class="child bg-three">
New York
</div>
</div>
<div class="parent right" onclick="">
<div class="child bg-four">
Hollywood
</div>
</div>
<div class="parent" onclick="">
<div class="child bg-five">
Dubai
</div>
</div>
<div class="parent right" onclick="">
<div class="child bg-six">
San Francisco
</div>
</div>
</div>
CSS Code
/* Global Styling */
html, body {margin:0px; padding: 0px;}
nav {
background-color: #34495e;
height: 80px;
position: fixed;
width: 100vw;
top: 0;
z-index: 999;
}
#logo {height: 80px; margin-left: 20px;}
.wrapper {
padding: 50px 50px;
max-width: 1200px;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 80px;
}
.right {float: right !important;}
/* Image zoom on hover + Overlay colour */
.parent {
width: 45%;
margin: 20px;
height: 300px;
border: 1px solid blue;
overflow: hidden;
position: relative;
float: left;
display: inline-block;
cursor: pointer;
}
.child {
height: 100%;
width: 100%;
background-size: cover;
background-repeat: no-repeat;
-webkit-transition: all .5s;
-moz-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
/* Several different images */
.bg-one {background-image: url(https://media.timeout.com/images/101602611/image.jpg);}
.bg-two {background-image: url(http://s1.it.atcdn.net/wp-content/uploads/2015/08/2-London.jpg);}
.bg-three {background-image: url(https://media.timeout.com/images/101484105/image.jpg);}
.bg-four {background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Hollywood_Sign.jpg/1280px-Hollywood_Sign.jpg);}
.bg-five {background-image: url(http://www.travelandleisure.com/sites/default/files/styles/tnl_redesign_article_landing_page/public/1453920892/DUBAI-554088081-ABOVE0116.jpg?itok=dcoZnCrc);}
.bg-six {background-image: url(http://blog.whitepages.com/wp-content/uploads/2015/04/san-franc.jpg);}
a {
display: none;
font-size: 35px;
color: #ffffff !important;
font-family: sans-serif;
text-align: center;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 50px;
cursor: pointer;
/*text-decoration: none;*/
}
.parent:hover .child, .parent:focus .child {
-ms-transform: scale(1.2);
-moz-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
}
.parent:hover .child:before, .parent:focus .child:before {
display: block;
}
.parent:hover a, .parent:focus a {
display: block;
}
.child:before {
content: "";
display: none;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(52,73,94,0.75);
}
/* Media Queries */
#media screen and (max-width: 960px) {
.parent {width: 100%; margin: 20px 0px}
.wrapper {padding: 20px 20px;}
}
.hello {display: none}
You will try this using that code when you hover the image then it will be zoom out the image. I think it will help you.
I'm trying to make css drop-down menu responsive according to the browser window.
I want the menu text to stay centered according to the browser window
Please see this video as examples of the intended behavior:
https://youtu.be/ZPWforRw_cc?t=34m23s
/* ------------------------------------------ */
/* BASIC SETUP */
/* ------------------------------------------ */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.page-wrap {
width: 1216px;
margin: 0 auto;
}
/* ------------------------------------------ */
/* PAGE CONTENT */
/* ------------------------------------------ */
.box1 {
height: 30px;
width: 300px;
background: #8242b1;
}
.box2 {
height: 30px;
width: 300px;
background: #b14242;
}
.box3 {
height: 30px;
width: 300px;
background: #424bb1;
}
.page-content {
display:flex;
justify-content: center;
transition: ease-in-out 0.3s;
position:relative;
top: -260px;
z-index: 0; }
.toggle {
transition: ease-in-out 0.3s;
text-decoration: none;
font-size: 30px;
color: #eaeaea;
position:relative;
top: -120px;
left: 20px;
z-index: 1; }
.toggle:hover {
color:#cccccc; }
.sidebar {
display:flex;
justify-content: center;
align-items: center;
transition: ease-in-out 0.3s;
position: relative;
top: -220px;
bottom: 0px;
left: 0px;
height: 220px;
width: auto;
padding: 30px;
background: #333;
z-index: 1; }
.sidebar li {
display:flex;
justify-content: center;
list-style: none;
color: rgba(255, 255, 255,0.8);
font-family: 'Lato', sans-serif;
font-size: 16px;
margin-bottom: 16px;
cursor: pointer; }
.sidebar li:hover {
color: rgba(255, 255, 255,1); }
#sidebartoggler {
display: none; }
#sidebartoggler:checked + .page-wrap .sidebar {
top: 0px; }
#sidebartoggler:checked + .page-wrap .toggle {
top: 100px; }
#sidebartoggler:checked + .page-wrap .page-content {
padding-top: 220px; }
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="resources/css/style.css">
<link href='https://fonts.googleapis.com/css?family=Lato:400,900' rel='stylesheet' type='text/css'>
</head>
<body>
<input type="checkbox" id="sidebartoggler" name="" value="">
<div class="page-wrap">
<div class="sidebar">
<ul>
<li>Home</li>
<li>Projects</li>
<li>Clients</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
<label for="sidebartoggler" class="toggle">☰</label>
<div class="page-content">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
</div>
</body>
</html>
this will work,
.page-wrap{
width:1216px;
}
+ use Media Queries as follows:
#media only screen and (max-width: 1216px) {
.page-wrap{
width: 100%;}
}