I have a little tab coming out of a box, and for some reason applying a hover on that tab is very buggy and the actual hovering area is way above it. What is causing that and how can i fix it?
JSFiddle: https://jsfiddle.net/nmr4wu2z/
body {
background-color: #F5F5F5;
font-family: 'Open Sans Condensed', sans-serif;
width: 90%;
margin: 0 auto;
}
.logo {
height: 250px;
width: 250px;
background-color: #FF7148;
margin-top: 5%;
margin-left: 5%;
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 300;
z-index: -1;
box-shadow: 1px 1px 1px black;
}
.contact {
height: 70px;
width: 280px;
position: relative;
background-color: #FF7148;
box-shadow: 1px 1px 1px black;
top: -150%;
z-index: -2;
transition: all 0.5s ease;
}
.contact:hover {
margin-left: 80%;
}
.contactText {
margin-right: -15.5em;
text-align: center;
transform: rotate(90deg);
font-family: 'Open Sans Condensed', sans-serif;
color: white;
padding-top: 40px;
}
.contactEmail {
color: white;
margin-top: -3.4em;
text-align: center;
padding-left: 5px;
}
.logoText {
color: #F5F5F5;
text-align: right;
padding: 170px 10px;
}
<!-- use <header>, <nav>, <article>, <section>, <aside>, and <footer> -->
<header>
<div class="logo">
<h3 class="logoText"> Name <br>     A Blog </h3>
<div class="contact">
<h3 class="contactText"> Contact </h3>
<h3 class="contactEmail"> Example#blabla.com </h3>
</div>
</div>
You have to make some changes
body {
background-color: #f5f5f5;
font-family: "Open Sans Condensed",sans-serif;
margin: 0 auto;
width: 90%;
}
.logo {
background-color: #ff7148;
box-shadow: 1px 1px 1px black;
font-family: "Open Sans Condensed",sans-serif;
font-weight: 300;
height: 250px;
margin-left: 5%;
margin-top: 5%;
position: relative;
width: 250px;
}
.contact {
background-color: #ff7148;
box-shadow: 1px 1px 1px black;
height: 105px;
position: absolute;
top: 30px;
transition: all 0.5s ease 0s;
width: 280px;
cursor: pointer;
}
.contact:hover {
margin-left: 85%;
}
.contactText {
color: white;
font-family: "Open Sans Condensed",sans-serif;
/* margin-right: -15.5em; */
/* padding-top: 40px; */
text-align: center;
transform: rotate(90deg);
transform-origin: 192px 85px 0;
}
.contactEmail {
color: white;
margin-top: -1.1em;
padding-left: 5px;
text-align: center;
}
.logoText {
background: #ff7148 none repeat scroll 0 0;
color: #f5f5f5;
padding: 170px 10px 35px;
position: relative;
text-align: right;
z-index: 1;
}
<header>
<div class="logo">
<h3 class="logoText"> Name <br>     A Blog </h3>
<div class="contact">
<h3 class="contactText"> Contact </h3>
<h3 class="contactEmail"> Example#blabla.com </h3>
</div>
</div>
in with your style like I do in below snippet -
While the answer above triggers the hover for .contact, it's still buggy when you hover above the square.
In this jsfiddle I changed the approach a bit. Take .contact out of .logo (as it doesn't make logical sense) and apply float: left to both. Instead of overlaying them and adjusting the margin to make .contact move left, I start with a lower width and overflow: hidden; on contact, and increase the width on hover.
Related
I've trying to make a website just for a home project but having some trouble with the css for mobile.
There seems to be a lot of whitespace surrounding the elements to the right and bottom of the site. I'm newer to the world of CSS so any help would be appreciated.
Screenshot of what chrome shows in developer mode.
#media screen and (max-width:450px) {
body {
margin: 0 0 0 0;
padding: 0 0 0 0;
max-width: 100vw;
overflow-x: hidden;
}
html{scroll-behavior:smooth}
.navbar {
background-color: #008B8B;
position: fixed;
top: 0;
z-index: 100;
width: 100vw;
}
.navbar a {
text-decoration: none;
display: inline-block;
float: center;
padding-bottom: 20px;
}
.logo{
display: none;
}
.loginLogo{
width = 1px;
height = 1px;
visibility: hidden;
}
.navbar-name{
color: #f2f2f2;
font-size:25px;
padding-left: 25%;
font-family: 'Lobster', cursive;
}
.navbar-home{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-products{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-about{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-contact{
font-size: 17px;
padding-top: 5px;
padding-right: 17.5%;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-login{
font-size: 1px;
padding-top: 1px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
visibility: hidden;
}
/* Change the color of links on hover */
.navbar-home:hover {
color: black;
}
.navbar-products:hover {
color: black;
}
.navbar-about:hover {
color: black;
}
.navbar-contact:hover {
color: black;
}
.navbar-login:hover {
color: black;
}
/* Add a color to the active/current link */
.navbar a.active {
background-color: #4CAF50;
color: white;
}
/*--------HOME PAGE------------*/
.homePage{
margin: 0 0 0 0;
padding: 0;
width: 100vw;
height: 820px;
background-image: url(multiGrain.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.homePageH1{
position: absolute;
text-align: center;
overflow: hidden;
white-space: nowrap;
top: 26%;
left:50%;
transform: translateX(-50%) translateY(-50%);
font-size: 40px;
color: white;
}
.homePageH2{
position: absolute;
text-align: center;
display: inline;
top: 28%;
left: 50%;
text-align: center;
transform: translateX(-50%) translateY(-50%);
font-size: 20px;
color: white;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
display: inline-block;
}
.aboutUsButton{
position: absolute ;
text-align: center;
top: 31%;
left:30%;
padding: 10px;
padding-right: 20px;
padding-left: 20px;
transform: translateX(-50%) translateY(-50%);
background-color: rgb(0, 159, 159);
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
text-decoration: none;
}
.ourProductsButton{
position: absolute ;
text-align: center;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
display: inline-block;
top: 31%;
left:70%;
padding: 10px;
padding-right: 18px;
padding-left: 18px;
transform: translateX(-50%) translateY(-50%);
background-color: rgb(0, 159, 159);
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
text-decoration: none;
}
/*-------ABOUT US PAGE----------*/
.aboutUsPage{
margin: 0 0 0 0;
padding: 0px;
background-color: white;
height: auto;
width: 100%;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.aboutUsH1{
position: relative;
padding-top: 20px;
padding-left: 20px;
margin: 0px;
text-align: left;
display: block;
width: 90%;
top: 20%;
font-size: 20px;
font-family: 'Lobster', cursive;
color: black;
background-color: rgb(255,255,255);
}
.aboutUsP{
position: relative;
padding-top: 20px;
padding-left: 20px;
padding-bottom: 30px;
margin: 0px;
text-align: left;
float: bottom;
display: block;
width: 90%;
top: 5%;
font-size: 15px;
font-family: 'Lobster', cursive;
color: black;
background-color: rgb(255,255,255);
}
.mixerImage{
position: relative;
object-fit: cover;
width: 100%;
height: 150px;
}
/*--------PRODUCTS PAGE------------*/
.productsPage{
position: relative;
margin: 0px;
padding: 0px;
background-color: white;
height: 300px;
width: auto;
}
.productsH1{
position: relative;
text-align: left;
top: 5%;
left: 4%;
font-size: 25px;
font-family: 'Titillium Web', sans-serif;
color: black;
}
.productsP{
position: relative;
padding: 10px;
padding-top: 15px;
text-align: left;
float: inherit;
width: 45%;
left: 2%;
font-size: 15px;
font-family: 'Titillium Web', sans-serif;
color: black;
background-color: white;
}
.productListButton{
position: absolute ;
text-align: center;
left: 2%;
padding: 10px;
padding-right: 20px;
padding-left: 20px;
background-color: black;
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
letter-spacing: 5px;
color: white;
text-decoration: none;
}
.slideshowImage1{
position: absolute;
width: auto;
left: 55%;
top: 15%;
height: 100px;
float: right;
margin: 10px;
padding: 10px;
box-shadow: 0 0 20px rgba(0,0,0,0.4);
}
.slideshowImage2{
width = 0px;
height = 0px;
visibility: hidden;
}
/*-------CONTACT US PAGE---------*/
.contactPage{
margin: 0 0 0 0;
padding: 0px;
background-image: url(rollingPin2.JPG);
height: 700px;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-size: 200% 100%;
}
.contactH1{
position: relative;
text-align: center;
overflow: hidden;
white-space: nowrap;
top: 10%;
left:0%;
font-size: 70px;
letter-spacing: 3px;
color: white;
font-family: 'Dancing Script', cursive;
}
.contactP1{
position: relative;
text-align: center;
top: 10%;
left:0%;
font-size: 18px;
color: white;
font-family: 'Slabo 27px', serif;
}
.contactP2{
position: relative;
text-align: center;
top: 10%;
left:0%;
font-size: 18px;
color: white;
font-family: 'Slabo 27px', serif;
}
.contact-form{
position: relative;
top: 15%;
width: 80%;
left: 47.5%;
transform: translateX(-50%);
}
input[type=text], select, textarea {
width: 100%; /* Full width */
padding: 12px; /* Some padding */
border: 1px solid #ccc; /* Gray border */
font-family: 'Titillium Web', sans-serif;
border-radius: 4px; /* Rounded borders */
margin-top: 6px; /* Add a top margin */
margin-bottom: 16px; /* Bottom margin */
resize: none; /* Allow the user to vertically resize the textarea (not horizontally) */
}
/* Style the submit button with a specific background color etc */
input[type=submit] {
width: 105%;
background-color: #008B8B;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
/* When moving the mouse over the submit button, add a darker green color */
input[type=submit]:hover {
background-color: black;
}
.nameInput{
position: relative;
top: 0px;
color: white;
}
.emailInput{
position: relative;
top: 5px;
color: white;
}
.messageInput{
position: relative;
top: 5px;
color: white;
}
.submitButton{
position: relative;
top: 5px;
}
/*--------FOOTER---------*/
.facebookLogo{
width: 0%;
height: 0%;
visibility: hidden;
}
.footer {
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp1{
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp2{
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp3{
width: 0px;
height: 0px;
visibility: hidden;
}
}
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=yes">
<link href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght#600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Slabo+27px&display=swap" rel="stylesheet">
<title>Doughboys Bakery</title>
<link href="StyleSheet.css" rel="stylesheet">
</head>
<body>
<header class="site-header">
<nav class="navbar">
<img class = "logo" src="Doughboys Logo - Website Version.png" alt="Logo" width="80"height="45.109">
<a class="navbar-name" href="">Doughboy's Bakery.</a>
<a class="navbar-login" href="">Log In</a>
<img class = "loginLogo" src="loginLogo2.png" onmouseover="this.src='loginLogo2Black.png';" onmouseout="this.src='loginLogo2.png';" width="50"height="28.889"/>
<a class="navbar-contact" href="#contactPage">Contact</a>
<a class="navbar-products" href="#productsPage">Products</a>
<a class="navbar-about" href="#aboutUsPage">About</a>
<a class="navbar-home" href="#homePage">Home</a>
</nav>
</header>
<div class = "homePage" id="homePage">
<h1 class="homePageH1">Quality or Quantity</h1>
<h2 class="homePageH2">We're here to give you both</h2>
<div class = "homePageButtons">
<a class="aboutUsButton" href="#aboutUsPage">About Us</a>
<a class="ourProductsButton" href="#productsPage">Our Products</a>
</div>
</div>
<div class = "aboutUsPage" id="aboutUsPage">
<div class = "aboutUsText">
<h1 class="aboutUsH1">Who we are.</h1>
<p class="aboutUsP">Doughboys Bakery is a locally owned and operated wholesale bakery located near the city centre of Palmerston North. We produce traditional bakery goods like the classic Mince and Cheese Pies and Custard Squares. <br/><br/>We deliver actively in the Manawatu-Whanganui, Horowhenua & Wairarapa regions. (T's & C's Apply)<br/><br/>Use the contact section below to see how we can help suit your baking needs.</p>
</div>
</div>
<div class = "productsPage" id="productsPage">
<h1 class="productsH1">What we make.</h1>
<p class="productsP">At Doughboys' we supply traditionally sold bakery goods all the way from the classic Mince and Cheese Pie to the humble Scone.</p>
<button class="productListButton" type="submit" onclick="window.open('ProductList.doc')">Full Product List</button>
<div id="slideshow">
<div>
<img class="slideshowImage1" src="fruitPies.jpeg">
</div>
<div>
<img class="slideshowImage2" src="pies.jpg">
</div>
</div>
</div>
<div class="contactPage" id="contactPage">
<h1 class="contactH1">Contact Us.</h1>
<p class="contactP1">ADDRESS: 15 Johnston St </p>
<p class="contactP2">TEL: (06) 123 1234 | doughboys#gmail.net.nz</p>
<div class = "contact-form">
<form id = "contact-form" method="post" action="contactForm.php">
<input class= "nameInput" type="text" id="name" name="name" placeholder="Your name...">
<input class= "emailInput" type="text" id="email" name="email" placeholder="Your email...">
<textarea class= "messageInput" id="message" name="message" placeholder="Write something..." style="height:100px"></textarea>
<input class= "submitButton" type="submit" value="Submit">
</form>
</div>
</div>
<div class="footer">
<a href="https://www.facebook.com/Doughboys-Bakery-Ltd-216199385212667">
<img class = "facebookLogo" src="facebookLogo.png" >
</a>
<p class="footerp1">(06) 123 1234</p>
<p class="footerp2">doughboys#gmail.net.nz</p>
<p class="footerp3">15 Johnston St</p>
</div>
</body>
</html>
* {
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
margin: 0px;
}
.we-adopt {
background-color: #8a8484;
color: #ffffff;
padding: 88px 0px;
height: 100px;
}
.we-adopt-list span {
display: inline-block;
vertical-align: top;
padding: 16px 60px 16px 24px;
background-color: #222222;
color: #ffffff;
width: 100%;
}
.we-adopt-list li {
color: #FFFFFF;
font-size: 32px;
font-weight: 500;
letter-spacing: 1.6px;
line-height: 24px;
margin-bottom: 70px;
text-transform: uppercase;
}
.we-adopt-list ul {
display: inline-block;
transform: rotate(-90deg) translateY(-50%);
position: relative;
left: 50%;
}
.we-adopt-list {
position: relative;
}
.we-adopt-list li:last-child {
margin-bottom: 0px;
}
<section class="we-adopt" style="height: 100px;">
</section>
<section class="we-adopt-wrap">
<div class="container">
<div class="we-adopt-list">
<ul>
<li><span>Mental agility</span></li>
<li><span>Emotional agility</span></li>
<li><span>Trust</span></li>
</ul>
</div>
</div>
</section>
Whenever i apply transform- rotate property to my list section its overlap or some time its take space from above content.
Case 1
Case 2
After apply transform- rotate, I want to start list section just from above grey section with no spacing like below image.
Expecting Result
Is there any other way to create this kind of design?
Consider transform-origin and update the transform like below:
* {
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
margin: 0px;
}
.we-adopt {
background-color: #8a8484;
color: #ffffff;
padding: 88px 0px;
height: 100px;
}
.we-adopt-list span {
display: inline-block;
vertical-align: top;
padding: 16px 60px 16px 24px;
background-color: #222222;
color: #ffffff;
width: 100%;
}
.we-adopt-list li {
color: #FFFFFF;
font-size: 32px;
font-weight: 500;
letter-spacing: 1.6px;
line-height: 24px;
margin-bottom: 70px;
text-transform: uppercase;
}
.we-adopt-list ul {
display: inline-block;
transform-origin: top left;
transform: rotate(-90deg) translateX(-100%) translateY(-50%);
position: relative;
margin: 0;
left: 50%;
}
.we-adopt-list {
position: relative;
}
.we-adopt-list li:last-child {
margin-bottom: 0px;
}
<section class="we-adopt" style="height: 100px;">
</section>
<section class="we-adopt-wrap">
<div class="container">
<div class="we-adopt-list">
<ul>
<li><span>Mental agility</span></li>
<li><span>Emotional agility</span></li>
<li><span>Trust</span></li>
</ul>
</div>
</div>
</section>
transform: rotate is a purely visual effect. It doesn't alter the flow of the page. To position it how you want you'd have to use transform: translate or margin or something else.
I have this website with a showcase div, within the div I have a "Get Started" button. I am able to vertically align the button with the margin attribute. However I do not want to horizontally align the button with margin as this will lead to some trouble for me in the future, I've tried align: center; and align="center" but the button sticks to the left side of the showcase. How can I unstick this button and horizontally align it without having to use a margin attribute?
html,
body,
header {
position: absolute;
left: 0;
top: 0;
width: 100%;
margin: 0;
margin-top: 0;
margin: auto;
padding: 0;
}
h1 {
display: inline-block;
font-family: Trebuchet MS;
font-size: 75px;
letter-spacing: 3px;
margin: 10px 0px 0px 20px;
}
h2 {
display: inline-block;
flex-direction: row;
margin: 0px 0px 0px 50px;
font-family: Georgia;
}
.highlight {
color: #45d845;
}
.heading {
background-color: #d84545;
border-bottom: 5px solid black;
padding-top: 20px;
padding-bottom: 20px;
}
#comet {
font-size: 65px;
margin-left: 20px;
}
.showcase {
background: url('background1.jpeg');
border-bottom: 5px solid black;
height: 1000px;
width: 100%;
background-size: 100% 100%;
background-repeat: no-repeat;
color: #cccccc;
}
.showcase h2 {
color: #fff;
margin-top: 170px;
font-size: 60px;
font-family: Verdana;
text-align: center;
text-shadow: 1px 3px #000;
}
#start {
align: center;
margin-top: 130px;
background-color: transparent;
color: #fff;
padding: 20px 30px 20px 30px;
text-align: center;
font-family: Helvetica;
font-weight: bold;
border-radius: 10px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
}
#start:hover {
cursor: pointer;
background-color: #fff;
color: #000;
}
<header>
<div class="heading">
<h1>ThumbTac <span id="comet">☄</span> </h1>
</div>
</header>
<div class="showcase">
<h2>He moonlight difficult engrossed an it sportsmen. Interested has all devonshire difficulty jay assistance joy. Unaffected at ye </h2>
<button id="start" align="center">Get Started</button>
</div>
You can wrap your button in a div with the style text-align: center; to horizontally center your button. Example:
html, body, header{
position:absolute;
left:0;
top:0;
width: 100%;
margin: 0;
margin-top: 0;
margin: auto;
padding: 0;
}
/*Heading*/
h1{
display: inline-block;
font-family: Trebuchet MS;
font-size: 75px;
letter-spacing: 3px;
margin: 10px 0px 0px 20px;
}
h2{
display: inline-block;
flex-direction: row;
margin: 0px 0px 0px 50px;
font-family: Georgia;
}
.highlight{
color: #45d845;
}
.heading{
background-color: #d84545;
border-bottom: 5px solid black;
padding-top: 20px;
padding-bottom: 20px;
}
#comet{
font-size: 65px;
margin-left: 20px;
}
/*Showcase*/
.showcase{
background: url('background1.jpeg');
border-bottom: 5px solid black;
height: 1000px;
width: 100%;
background-size: 100% 100%;
background-repeat: no-repeat;
color: #cccccc;
}
.showcase h2{
color: #fff;
margin-top: 170px;
font-size: 60px;
font-family: Verndana;
text-align: center;
text-shadow: 1px 3px #000;
}
#start{
align: center;
margin-top: 130px;
background-color: transparent;
color: #fff;
padding: 20px 30px 20px 30px;
text-align: center;
font-family: Helvetica;
font-weight: bold;
border-radius: 10px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
#start:hover{
cursor: pointer;
background-color: #fff;
color: #000;
}
<header>
<div class="heading">
<h1>ThumbTac <span id="comet">☄</span> </h1>
</div>
</header>
<div class="showcase">
<h2>He moonlight difficult engrossed an it sportsmen.
Interested has all devonshire difficulty jay
assistance joy. Unaffected at ye </h2>
<div style="text-align: center;">
<button id="start">Get Started</button>
</div>
</div>
You can consider using a flexbox. Documentation in the CSS source.
/* Global Sets */
html,
body,
header {
position: absolute;
left: 0;
top: 0;
width: 100%;
margin: 0;
margin-top: 0;
margin: auto;
padding: 0;
}
/*Heading*/
h1 {
display: inline-block;
font-family: Trebuchet MS;
font-size: 75px;
letter-spacing: 3px;
margin: 10px 0px 0px 20px;
}
h2 {
display: inline-block;
flex-direction: row;
margin: 0px 0px 0px 50px;
font-family: Georgia;
}
.highlight {
color: #45d845;
}
.heading {
background-color: #d84545;
border-bottom: 5px solid black;
padding-top: 20px;
padding-bottom: 20px;
}
#comet {
font-size: 65px;
margin-left: 20px;
}
/*Showcase*/
.showcase {
background: url('background1.jpeg');
border-bottom: 5px solid black;
height: 1000px;
width: 100%;
background-size: 100% 100%;
background-repeat: no-repeat;
color: #cccccc;
display: flex; /* Added */
flex-direction: column; /* Added */
align-items: center; /* Added, horizonal alignment */
}
.showcase h2 {
color: #fff;
margin-top: 170px;
font-size: 60px;
font-family: Verndana;
text-shadow: 1px 3px #000;
text-align: center;
}
#start {
/* align: center; Not valid CSS */
margin-top: 130px;
background-color: transparent;
color: #fff;
padding: 20px 30px 20px 30px;
/* text-align: center; No longer required */
font-family: Helvetica;
font-weight: bold;
border-radius: 10px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
}
#start:hover {
cursor: pointer;
background-color: #fff;
color: #000;
}
<header>
<div class="heading">
<h1>ThumbTac <span id="comet">☄</span> </h1>
</div>
</header>
<div class="showcase">
<h2>He moonlight difficult engrossed an it sportsmen. Interested has all devonshire difficulty jay assistance joy. Unaffected at ye </h2>
<button id="start" align="center">Get Started</button>
</div>
So I set up my header to fade with scroll, but appear with hover. It works over all the images, but the cat pictures in the Portfolio section. I adjusted the z-indexes and have tried everything. The header will not appear over the h4 or anything under the The problem file is the portfolio.html. The header appears over the other pictures. It's been driving me crazy.
https://github.com/alil0rphan/Basic-Portfolio
/* Eastablish body parameters */
body {
background-image: url("../images/circlesbg.png");
background-color: #D7CFC3;
color: #777777;
margin: 0px auto;
font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
}
/* Create Heading block */
h1 {
background-color: #4AAAA5;
display: inline-block;
padding: 25px 20px 0px 20px;
height: 55px;
margin: 0px auto;
font-family: "Georgia", Times, "Times New Roman", serif;
color: #FFFFFF;
font-size: 36px;
}
h1,
h2,
h3 {
font-weight: bold;
}
section {
background-color: #ffffff;
}
/*Establishes header on top */
header {
background-color: #FFFFFF;
border-bottom: solid 2px #cccccc;
margin: 0px auto;
width: 100%;
height: 80px;
top: 0px;
position: fixed;
z-index: 99;
}
/* establishes tranparency on scroll */
body.scrolled #main-menu {
opacity: 0.2;
transition: opacity .2s;
z-index: 98;
}
body.scrolled #main-menu:hover {
opacity: 1.0;
transition: opacity .2s;
z-index: 97;
}
/* Makes sure heading and contents line up */
.banner {
width: 960px;
margin: 0px auto;
height: 60px;
position: relative;
}
/* Navigational link parameters established */
.link-box {
padding: 30px 0px 0px 20px;
height: 55px;
right: 0px;
display: inline;
position: absolute;
}
/* Establishes main content parameters (container and connect blocks) */
.content {
width: 960px;
margin: 0px auto;
}
/* Establish main unique block on each page */
.container {
width: 590px;
border: solid 2px #dddddd;
float: left;
margin: 115px 0px 200px 0px;
padding: 30px;
}
/* Link attributes including hover */
a {
color: #777777;
text-decoration: none;
font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
word-spacing: 10px;
}
a:hover {
color: #4AAAA5;
}
/* Establishing heading fonts for container and connect box*/
h2 {
color: #4AAAA5;
font-family: "Georgia", Times, "Times New Roman", serif;
border-bottom: solid 3px #dddddd;
padding-bottom: 20px;
margin-bottom: 10px;
font-size: 32px;
}
h3 {
color: #4AAAA5;
font-family: "Georgia", Times, "Times New Roman", serif;
border-bottom: solid 1px #dddddd;
padding-bottom: 20px;
margin-bottom: 10px;
font-size: 24px;
}
/* adjusts line height and paragraphs for the about me section */
p {
line-height: 2.5;
font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
margin-top: 0px;
color: #777777;
}
/* My picture on the index file */
#face {
float: left;
display: inline;
margin-top: 10px;
margin-right: 15px;
width: 250px;
}
/* Connections box parameters with icons */
.connect {
width: 210px;
border: solid 2px #dddddd;
float: right;
margin-top: 115px;
padding: 30px;
}
/* Establish icon aesthetics and behaviors with hover features */
.icons {
display: inline-block;
margin: 0px 5px 30px 0px;
width: 60px;
height: 60px;
}
.icons:hover {
box-shadow: 4px 4px 2px #4AAAA5;
}
/* cat pictures and parameters established with hover features*/
.cats {
display: inline-block;
margin: 10px 40px 40px 0px;
width: 230px;
}
.cats:hover {
box-shadow: 4px 4px 2px #4AAAA5;
}
.image {
position: relative;
display: inline-block;
}
/* establishes parameters for banners over the cat images */
h4 {
position: absolute;
width: 230px;
background-color: #4AAAA5;
color: #FFFFFF;
font-family: "Georgia", Times, "Times New Roman", serif;
text-align: center;
padding: 10px 0px 10px 0px;
margin: auto;
left: 0px;
bottom: 50px;
}
/* Establishes sticky footer */
footer {
background-color: #666666;
opacity: 0.85;
text-align: center;
border-top: solid 6px #4AAAA5;
position: fixed;
width: 100%;
bottom: 0px;
padding-top: 30px;
padding-bottom: 30px;
color: #BFBEBC;
font-size: 10px;
font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
}
.clearfix::after {
content: "";
display: block;
clear: both;
}
/* Establishes input attributes for the contact/ message form. */
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 2px solid #DDDDDD;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 16px;
resize: vertical
}
input[type=submit] {
background-color: #4AAAA5;
color: #FFFFFF;
padding: 12px 20px;
border: none;
cursor: pointer;
}
/* Makes the Submit button change color when mouse hovers over */
input[type=submit]:hover {
background-color: #666666;
}
::-webkit-input-placeholder { /* WebKit browsers */
color: #666666;
opacity: 0.5 !important;
}
label {
color: #8F7E7F;
}
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Portfolio</title>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
</head>
<div id="main-menu">
<header>
<div class="banner">
<h1>John Bendfeldt</h1>
<!-- Navigational links. -->
<div class="link-box">
About |
Porfolio |
Contact
</div>
</div>
</header>
</div>
<body>
<div class="content">
<!-- Big content box in middle -->
<section class="container">
<h2>Portfolio</h2>
<br>
<!-- Images for the main content block -->
<div class="image">
<img src="assets/images/cat1.jpg" class="cats" alt="kitten">
<h4>Building Websites</h4>
</div>
<div class="image">
<img src="assets/images/cat2.jpg" class="cats" alt="kitten">
<h4>RPG</h4>
</div>
<div class="image">
<img src="assets/images/cat3.jpg" class="cats" alt="kitten">
<h4>Trivia Game</h4>
</div>
<div class="image">
<img src="assets/images/cat4.jpg" class="cats" alt="kitten">
<h4>Rock Paper Scissors</h4>
</div>
<div class="image">
<img src="assets/images/cat5.jpg" class="cats" alt="kitten">
<h4>American Freedom</h4>
</div>
</section>
<!-- connect with me box -->
<section class="connect">
<h3>Connect with Me</h3>
<br>
<img src="assets/images/Github-icon.png" class="icons" alt="Github-icon" title="GitHub">
<img src="assets/images/linkedin-icon.png" class="icons" alt="linkedin-icon" title="LinkedIn">
<img src="assets/images/stackoverflow-icon.png" class="icons" alt="stackoverflow-icon" title="Stackoverflow">
</section>
</div>
</body>
<footer>
© Copywrite 2017 John Bendfeldt
</footer>
<!-- makes the header transparent on scroll -->
<script type="text/javascript">
window.addEventListener('scroll', function () {
document.body.classList[
window.scrollY > 20 ? 'add': 'remove'
]('scrolled');
});
</script>
</html>
`
try to add a position: absolute; in body.scrolled #main-menu selector. It will look like this:
body.scrolled #main-menu {
opacity: 0.2;
transition: opacity .2s;
z-index: 98;
position: absolute;
}
Short story: my footer doesn't react to margin-top, i've tried many various way (well it actualy works on very big numbers, which shows that margin is led from previous element, the image container).Here's the code:
HTML (i've removed content obiviously, and didn't attach head section, which is before content):
<div id="content">
<h1 id="top">header</h1>
<div id="billboard">
<div id="buttony">
buttons
</div>
</div>
<div class="pasek">
</div>
<h2 class="naglowek">Najnowsze prace:</h2>
<div class="photo"><div class="heading"><span>text</span></div><img src="img/thumb1.jpg" alt="smu"/><div class="caption"><span>text</span></div></div>
<div class="photo"><div class="heading"><span>text</span></div><img src="img/thumb2.jpg" alt="smu"/><div class="caption"><span>text</span></div></div>
<div class="photo"><div class="heading"><span>text</span></div><img src="img/thumb3.jpg" alt="smu"/><div class="caption"><span>text</span></div></div>
</div>
<div id="footer">
<div id="footerwrap">
<div class="footerblock"><h3 id="nav">header</h3>
<ol>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ol>
</div>
<div class="footerblock"><h3 id="info">header</h3><p>some content </p>
</div>
<div class="footerblock"><h3 id="plus">header</h3>
<p class="links"><a target="_blank" href="http://www.smashingmagazine.com">Smashing Magazine</a></p>
<p class="links"><a target="_blank" href="http://www.w3schools.com">W3 Schools</a></p>
<p class="links"><a target="_blank" href="http://www.w3.org">W3 Consortium</a></p>
</div>
</div>
</div>
Here's the CSS part:
div#content{
width: 960px;
margin: 0 auto;
}
div#content h1#top{
font-family: Arial, Helvetica, sans-serif;
font-weight: 900;
font-size: 56px;
text-align: center;
color: #333333;
padding: 0 0 10px;
margin: 20px auto;
border-bottom: 4px #d4d4d4 dashed;
}
div#content h1#top span{
color: #c24b4b;
}
div#content div.pasek{
width: 960px;
height: 30px;
background-image: url('img/pasek.jpg');
margin: 10px 0;
}
div#content div#billboard{
width: 960px;
height: 500px;
background-color: #ffffff;
background-image: url('img/bb.jpg');
background-repeat: no-repeat;
}
div#content div#billboard img{
max-width: 100%;
max-height: 100%;
}
div#content div#billboard a:first-of-type{
margin-right: 40px;
}
div#content div#billboard div#buttony{
width: 565px;
position: relative;
top: 380px;
left: 321px;
}
div#content h2.naglowek{
font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
font-size: 36px;
color: #191a1c;
padding: 5px 55px;
margin: 20px auto;
border-bottom: 2px #d4d4d4 dashed;
background: url('img/tools.jpg') no-repeat;
}
/* jQuery podpisy*/
div.photo{
margin: 0 7px 7px;
position: relative;
overflow: hidden;
float: left;
width: 292px;
height: 292px;
border: 4px #212226 solid;
}
div.photo div.heading, div.photo div.caption {
position: absolute;
background-color: #0e0e0f;
height: 30px;
width: 300px;
color: white;
text-align: center;
opacity:0.8;
filter:alpha(opacity=80);
-moz-opacity:0.8;
-khtml-opacity: 0.8;
}
div.photo div.heading{
padding-top: 10px;
top: -40px;
}
div.photo div.heading span{
font-size: 20px;
display: block;
margin-top: -2px;
}
div.photo div.caption{
padding-top: 10px;
bottom: -40px;
}
div.photo div.caption span{
color: #d3d3d3;
font-size: 11px;
display: block;
padding: 0 10px;
}
/* jQuery podpisy koniec*/
/* CONTENT END*/
/* FOOTER */
div#footer{
clear: both;
margin-top: 60px;
color: #636363;
font-size: 14px;
height: 300px;
background-color: #131415;
background-image: url('img/pasek2.jpg');
background-repeat: repeat-x;
}
div#footer div#footerwrap{
width: 960px;
margin: 0 auto;
}
div#footer div.footerblock{
float: left;
width: 320px;
margin-top: 40px;
}
div.footerblock h3{
font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
letter-spacing: 0.1em;
text-align: center;
font-size: 24px;
color: white;
padding-top: 15px;
height: 39px;
}
div.footerblock h3#nav{
background: url('img/world.jpg') no-repeat 25px;
}
div.footerblock h3#info{
background: url('img/info.jpg') no-repeat 25px;
}
div.footerblock h3#plus{
background: url('img/chat.jpg') no-repeat 25px;
}
div.footerblock li{
font-size: 18px;
padding: 15px 0 10px 40px;
margin: 0 20px;
background: url('img/flash.jpg') no-repeat 10px;
border-bottom: 1px white solid;
}
div.footerblock a:hover{
color: #808080;
}
div.footerblock p{
margin: 20px;
line-height: 20px;
}
div.footerblock p.links{
background: url('img/cloud.jpg') no-repeat 10px 0;
margin: 17px 20px;
}
div.footerblock p a{
font-size: 16px;
color: #636363;
padding-left: 45px;
padding-bottom: 6px;
display: block;
border-bottom: 1px #636363 solid;
}
Wasn't sure which parts of css to drop since as long as suspected parts changes didn't work for me it could be anything i guess. If it's too much please tell i'll drop unnecessary parts.
Here is what you need to do.
Put all the div.photo divs in a one display-block container with height specified. See here http://jsfiddle.net/pXRj3/