Difficulty resolving white space below my webpage - html

I am a noob at HTML/CSS, and I'm trying to put a timeline on my website. I've run into a strange issue: I have a weird block of space under my #timeline class anytime I try to change the height.
What I've tried: I've read some posts about absolute/relative positioning and how if you try to change the height with An absolute or relatively positioned object, it will leave a gap of space between where it is and where it used to be.
With this information, I'm not sure how to reposition my timeline elements without using absolute positioning, because I don't want the timeline to be too large. Any recommendations or tips would be great. here's my code (please view in full window - timeline has some compatibility issues with safari right now:( use chrome if you can)
My CSS is kind of long, but I wanted you to see the whole webpage and understand how It all worked together. I experienced the issue after styling the body and #timeline component, so I believe the styling below these components is causing the issues.
Any pointers would be appreciated.
html{
font-size: 10px;
font-family: Raleway;
width: 100%;
height: 100%;
background: linear-gradient(#FF9940, white);
font-weight: normal;
}
h1{
font-family: Raleway;
padding: 20px;
font-size: 53px;
text-shadow: 2px 2px 1px grey;
background-color: #1E2752;
text-align: center;
border: 5px solid black;
color: #FCFCFF;
margin-top: 10px;
}
li{
float: left;
padding-right: 30px;
}
li a{
display: block;
color: white;
text-decoration: none;
padding: 19px 16px;
border: 2px solid #ffffff;
right: -100px;
}
li a:hover{
color: #ffffff;
background: #FF9940;
transition: all 0.4s ease 0s;
}
ul{
transition: all 0.4s ease 0s;
list-style-type: none;
text-decoration: none;
font-size: 12px;
text-transform: uppercase;
color: #ffffff;
background: transparent;
display: inline-block;
position: absolute;
text-align: center;
padding: 0px;
top: 28px;
left: 23px;
right: 23px;
width: 100%;
}
h2{
text-align: center;
font-size: 25px;
}
h2 p{
font-size: 18px;
}
.right-button{
float: right;
padding-right: 47px
}
.other-button{
float: right;
padding-right: 30px;
}
body{
font-family: tahoma;
font-size: 15px;
line-height: 1.75;
padding: 0;
margin: 0;
}
#timeline{
margin-left: 470px;
height: 400px;
width: 500px;
display:flex;
background-color: #031625;
}
#timeline:hover .t1-item{
max-width: 400px;
max-height: 500px;
width:23.3333%;
}
.t1-item:before, .t1-item:after{
transform: translate3d(0,0,0);
content: ' ';
position: absolute;
left: 0;
top: 0;
}
.t1-item{
transform: translate3d(0,0,0);
position: relative;
width: 25%;
height: 100vh;
min-height: 600px;
color:white;
overflow: hidden;
transition: width 0.5s ease;
}
.t1-item:after{
background: rgba(3,22,37,0.85);
opacity: 1;
transition: opacity .5s ease;
}
.t1-item:before{
background: linear-gradient(to bottom,
rgba(0,0,0,0) 0%, rgba(0,0,0,1) 75%);
z-index: 1;
opacity: 0;
transform: translate3d(0,0,0) translateY(50%);
transition: opacity .5s ease,
transform .5s ease;
}
.t1-item:hover{
width: 30%;
}
.t1-item:hover:after{
opacity: 0;
}
.t1-item:hover:before{
opacity: 1;
transform: translate3d(0,0,0) translateY(0);
transition: opacity 1s ease, transform 1s ease
.25s;
}
.t1-item:hover .t1-content{
opacity: 1;
transform: translateY(0);
transition: all .75s ease .5s;
}
.t1-item:hover .t1-bg{
filter: grayscale(0);
}
.t1-content{
transform: translate3d(0,0,0) translateY(25px);
position: relative;
z-index: 1;
text-align: center;
margin: 0.1618em;
top: 55%;
opacity: 0%;
}
.t1-content h3{
font-family: tahoma;
text-transform: uppercase;
color: #1779cf;
font-size: 1.44rem;
font-weight: normal;
}
.t1-year{
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
border-top: 1px solid white;
border-bottom: 1px solid white;
}
.t1-year p{
font-family: tahoma;
font-size: 1.628rem;
line-height: 0;
}
.t1-bg{
transform: translate3d(0,0,0);
position: absolute;
top: 0;
left: 0;
background-size: cover;
background-position: center center;
transition: filter .5se ease;
filter: grayscale(100%);
}
<!DOCTYPE html>
<html lang = "en" >
<head>
<meta charset = "UTF-8">
<title> Isabelle Kreienbrink </title>
<link href="styles/style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
</head>
<body>
<h1> Header </h1>
<ul>
<li>Resume</li>
<li>Academics</li>
<li><a href="#projects" >Projects</a></li>
<li class="right-button">Contact Info</li>
<li class="other-button">Test</li>
<li class="other-button">Testing</li>
</ul>
<h2> Welcome to my website!
<p> I hope you learn a little about me while you're here. </p>
</h2>
<section id="timeline">
<div class="t1-item">
<div class="t1-bg" style="background-image:url(https://eng-dev.stanford.edu/sites/default/files/styles/full_width_banner_tall/public/chalkboard_web.jpg?itok=xqk3ef56)">
</div>
<div class="t1-year">
<p class="f2 heading">2014</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(001.jpeg)"></div>
<div class="t1-year">
<p class="f2 heading">2015</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(001.jpeg)"></div>
<div class="t1-year">
<p class="f2 heading">2016</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(001.jpeg)"></div>
<div class="t1-year">
<p class="f2 heading">2015</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
</section>
</body>
</html>

If i'm understanding your problem correctly, it's the .t1-item {height: 100vh;} that's giving you the issue, along with the min-height: 600px. That is pushing the .t1-item down in its pre-hover state, thus creating that space.
An alternative to using these height specifications would be to use margin-top to position your instances of .t1-item:
.t1-item {
transform: translate3d(0,0,0);
position: relative;
width: 25%;
color: white;
overflow: hidden;
transition: width 0.5s ease;
margin-top: 20rem;
}

Related

Why the images in the background are glow up when I click?

When I click my <a> tag for the popup box, the images in the background (with overlay effects) are glowing up, and I don't know why. If anybody know something I write the code under here.
As you can see I've put href to #popup1 in the first <a> tag, and it opens the popup box, but in the background you can see the image like glowing, the border too.
I've changed the display tag and other CSS tags, but nothing.
Here is the Codepen.
the problem is actually you add pop-up before container 2 so that's why it is glowing.
So, if you dont want to make this glow just add your pop-up division after both
containers like this.
Dont change your Css. you just have to change position of divisions like this
<div class="container1" style="cursor:default;">
<div class="container2">
<div class="content">
<a id="ant" href="#popup1" onclick="show('popup2')">
<div class="content-overlay"></div>
<img class="content-image" src="https://i.postimg.cc/5tNkjkV5/2.png" style="z-index: 0;height: 200px;width: 330px;border:2px solid rgb(205,144,76);padding:0;">
<div class="content-details fadeIn-bottom" style="background-size:cover;">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif;">ANTIPASTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<div class="container2">
<div class="content">
<a id="prim">
<div class="content-overlay"></div>
<img class="content-image" src="https://i.postimg.cc/5tNkjkV5/2.png" style="border:2px solid rgb(205,144,76);padding:0; height:200px; width:330px;">
<div class="content-details fadeIn-bottom">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif;"> PRIMI PIATTI </h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
</div>
<div id="popup1" class="popup">
×
<h2>The Popup Has Arrived</h2>
<p>QUESTI SONO GLI ANTIPASTI</p>
</div>
<a href="#ant" class="close-popup"></a
It depends on the order of your HTML-Elements. This example will fix the problem
.container1 {
display: flex;
width: 100%;
flex-wrap: wrap;
margin-top: 110px;
align-content: space-around;
justify-content: center;
transition: all 0.2s linear;
}
.container1 > div {
padding: 40px;
justify-content: center;
}
*,
*:before,
*:after {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.main-title {
color: #2d2d2d;
text-align: center;
text-transform: capitalize;
padding: 0.7em 0;
}
.container {
padding: 1em 0;
float: left;
width: 50%;
}
#media screen and (max-width: 640px) {
.container {
display: block;
width: 100%;
}
}
#media screen and (min-width: 900px) {
.container {
width: 33.33333%;
}
}
.container .title {
color: #1a1a1a;
font-family: 'Roboto', sans-serif;
text-align: center;
margin-bottom: 10px;
}
.content {
position: relative;
width: 100%;
max-width: 400px;
height: 100%;
margin: auto;
overflow: hidden;
transition: transform 0.4s;
}
.content .content-overlay {
/* background: rgba(70,34,0);*/
background: rgba(214, 142, 60, 70%);
/* background: rgb(214,142,60);*/
position: absolute;
height: 97%;
width: 100%;
left: 30px;
top: 0;
bottom: 0;
right: 0;
opacity: 0;
-webkit-transition: all 0.4s ease-in-out 0s;
-moz-transition: all 0.4s ease-in-out 0s;
transition: all 0.4s ease-in-out 0s;
}
.content:hover .content-overlay {
opacity: 0.5;
}
.content-details {
position: absolute;
text-align: center;
padding-left: 1em;
padding-right: 1em;
width: 100%;
top: 50%;
left: 50%;
opacity: 0;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-webkit-transition: all 0.3s ease-in-out 0s;
-moz-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.content:hover .content-details {
top: 50%;
left: 50%;
right: 50%;
opacity: 1;
}
.content-details h3 {
color: #fff;
font-weight: 500;
text-align: center;
letter-spacing: 0.15em;
margin-bottom: 0.5em;
padding-left: 20px;
text-transform: uppercase;
}
.content-details p {
color: #fff;
font-size: 0.8em;
text-align: center;
padding-left: 20px;
}
.fadeIn-bottom {
top: 80%;
}
.fadeIn-top {
top: 20%;
}
.fadeIn-left {
left: 20%;
}
.fadeIn-right {
left: 80%;
}
h1 {
font-size: 3em;
text-align: center;
color: #00898e;
margin: 0;
padding: 30vh 0 1em;
}
h2 {
text-align: center;
white-space: nowrap;
color: #00898e;
}
a {
text-decoration: none;
color: #fff;
}
p {
text-align: left;
}
.btn {
display: inline-block;
padding: 10px 20px;
border: 2px solid #00898e;
border-radius: 10px;
transition: background 0.3s;
}
.btn:hover {
background: #00898e;
}
.popup {
position: fixed;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.9);
visibility: hidden;
opacity: 0;
/* "delay" the visibility transition */
-webkit-transition: opacity 0.5s, visibility 0s linear 0.5s;
transition: opacity 0.5s, visibility 0s linear 0.5s;
z-index: 1;
}
.popup:target {
visibility: visible;
opacity: 1;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
.popup-close {
position: absolute;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.9);
}
.popup .close {
position: absolute;
right: 5px;
top: 5px;
padding: 5px;
color: #000;
transition: color 0.3s;
font-size: 2em;
line-height: 0.6em;
font-weight: bold;
}
.popup .close:hover {
color: #00e5ee;
}
.close-popup {
background: rgba(0, 0, 0, 0.7);
cursor: default;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
visibility: hidden;
/* "delay" the visibility transition */
-webkit-transition: opacity 0.5s, visibility 0s linear 0.5s;
transition: opacity 0.5s, visibility 0s linear 0.5s;
}
.popup:target + .close-popup {
opacity: 1;
visibility: visible;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
<div class="container1" style="cursor: default">
<div class="container2">
<div class="content">
<a id="ant" href="#popup1" onclick="show('popup2')">
<div class="content-overlay"></div>
<img
class="content-image"
src="https://i.postimg.cc/5tNkjkV5/2.png"
style="z-index: 0; height: 200px; width: 330px; border: 2px solid rgb(205, 144, 76); padding: 0"
/>
<div class="content-details fadeIn-bottom" style="background-size: cover">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif">ANTIPASTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<div class="container2">
<div class="content">
<a id="prim">
<div class="content-overlay"></div>
<img
class="content-image"
src="https://i.postimg.cc/5tNkjkV5/2.png"
style="border: 2px solid rgb(205, 144, 76); padding: 0; height: 200px; width: 330px"
/>
<div class="content-details fadeIn-bottom">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif">PRIMI PIATTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<!-- The popup should be entered as the last element so that it overlays the other elements -->
<div id="popup1" class="popup">
×
<h2>The Popup Has Arrived</h2>
<p>QUESTI SONO GLI ANTIPASTI</p>
</div>
</div>

Why is the width of my CSS animation dependent on previous HTML or CSS features?

So I'm trying to have an underline that goes the width of each text. E.g. I have headers "Team" and "Schedule", and I want the underline to go the full length of each word despite them being different lengths. This is my current code (I've included most all of the code):
html,
body {
margin: 0;
}
.menu {
position: relative;
transition: 0.3s;
z-index: 2;
}
.change .menu {
background-color: white;
width: 60vh;
height: 100vh;
color: black;
position: absolute;
top: -10px;
left: -30px;
z-index: 2;
box-shadow: 0px 8px 16px 0px;
}
.header {
position: fixed;
font-size: 20px;
top: 8px;
left: 16px;
font-family: 'Bebas Neue', cursive;
text-align: left;
color: black;
padding: 10px;
}
.change .content {
position: relative;
}
.menu a {
opacity: 0%;
}
.change .menu a {
opacity: 100%;
color: black;
text-decoration: none;
display: block;
position: relative;
left: 100px;
bottom: -50px;
font-size: 30px;
font-family: 'Bebas Neue', cursive;
z-index: 2;
}
.content h3 {
opacity: 0%;
}
.underbar {
position: relative;
}
.underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 0px;
right: 0;
background: #24478f;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
. .underbar:hover:after {
width: 12%;
left: 0;
background: #24478f;
}
.sub_underbar {
position: relative;
}
.sub_underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 5px;
right: 0;
background: #ffcc00;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
.sub_underbar:hover:after {
width: 38% left: 0;
background: #ffcc00;
}
<div class="container">
<img src="team_sunset.JPG" alt="Team Picture" style="width:100%;">
<div class="centered" style="font-size:20vw;">UMWSC</div>
<div class="header" onclick="myFunction(this)">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
<div class="menu" id="menu_scroll">
<div class="content">
HOME
<h3 class="sub_underbar">MISSION STATEMENT</h3>
<h3 class="sub_underbar">CONTACT US</h3>
TEAM
<h3 class="sub_underbar">ROSTER</h3>
<h3 class="sub_underbar">LEADERSHIP</h3>
<h3 class="sub_underbar">SCHEDULE</h3>
<h3 class="sub_underbar">STATS</h3>
NEWS
<h3 class="sub_underbar">GALLERY</h3>
<h3 class="sub_underbar">BLOG</h3>
GET INVOLVED
<h3 class="sub_underbar">MERCH</h3>
<h3 class="sub_underbar">DONATE</h3>
<h3 class="sub_underbar">PARTNER WITH US</h3>
<h3 class="sub_underbar">WORK WITH US</h3>
MORE INFO
<h3 class="sub_underbar">FORMS</h3>
<h3 class="sub_underbar">FAQS</h3>
</div>
</div>
<div id="scroll_header">
<h4>UMWSC</h4>
</div>
</div>
</div>
I think currently the width is dependent on some parent feature because when you hover to the right of the text, there's a specific spot that "triggers" the animation of the underline to occur.
I'm sure there's a lot wrong with my previous code that might be causing this current issue. Any help would be greatly appreciated! Thank you.
EDIT: The picture shows how the underline goes past the width I want it to go, I just want it to be the length of the word 'HOME'. drop-down content picture
If I'm understanding this correctly you want the main menu titles underline to span across the biggest item in that group of items. If so try this:
a {
text-decoration: none;
}
.menu {
position: relative;
transition: 0.3s;
z-index: 2;
}
.change.menu {
background-color: white;
width: 60vh;
height: 100vh;
color: black;
position: absolute;
top: -10px;
left: -30px;
z-index: 2;
box-shadow: 0px 8px 16px 0px;
}
.header {
position: fixed;
font-size: 20px;
top: 8px;
left: 16px;
font-family: 'Bebas Neue', cursive;
text-align: left;
color: black;
padding: 10px;
}
.change.content {
position: relative;
}
.underbar {
position: relative;
}
.underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 0px;
right: 0;
background: #24478f;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
.underbar:hover:after {
width: 100%;
left: 0;
background: #24478f;
}
.sub_underbar {
position: relative;
}
.sub_underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 5px;
right: 0;
background: #ffcc00;
transition: 100% .5s ease;
-webkit-transition: 100% .5s ease;
}
.sub_underbar:hover:after {
width: 38% left: 0;
background: #ffcc00;
}
<div class="container">
<div class="header" onclick="myFunction(this)">
<div class="menu" id="menu_scroll">
<div class="content-holder">
<div class="content">
HOME
<h3 class="sub_underbar">MISSION STATEMENT</h3>
<h3 class="sub_underbar">CONTACT US</h3>
</div>
<div class="content">
TEAM
<h3 class="sub_underbar">ROSTER</h3>
<h3 class="sub_underbar">LEADERSHIP</h3>
<h3 class="sub_underbar">SCHEDULE</h3>
<h3 class="sub_underbar">STATS</h3>
</div>
<div class="content">
NEWS
<h3 class="sub_underbar">GALLERY</h3>
<h3 class="sub_underbar">BLOG</h3>
</div>
<div class="content">
GET INVOLVED
<h3 class="sub_underbar">MERCH</h3>
<h3 class="sub_underbar">DONATE</h3>
<h3 class="sub_underbar">PARTNER WITH US</h3>
<h3 class="sub_underbar">WORK WITH US</h3>
</div>
<div class="content">
MORE INFO
<h3 class="sub_underbar">FORMS</h3>
<h3 class="sub_underbar">FAQS</h3>
</div>
</div>
</div>
<div id="scroll_header">
<h4>UMWSC</h4>
</div>
</div>
</div>

Can't move background image up on website

I'm trying to add a background image to my timeline on a website, but I can't seem to move my background image up and down without it shrinking. It almost seems like there's some invisible bar keeping me from moving the image up. If it moves up, it just shrinks.
edit: Sorry for the confusion. I am wanting to move the image up in the background of the timeline. I can't move it up using top.
Initially I couldn't even get the image to show up, but now I need to use the
background-image: cover
property and it's not working as expected. I'm doing something wrong.
What I've tried:
adjusting the height and width of my elements
using Top to move the background image up/down
Here's the code for the timeline and it's styling sheets:
html {
font-size: 10px;
font-family: Raleway;
width: 100%;
height: 100%;
background: linear-gradient(#FF9940, white);
font-weight: normal;
}
h1 {
font-family: Raleway;
padding: 20px;
font-size: 53px;
text-shadow: 2px 2px 1px grey;
background-color: #1E2752;
text-align: center;
border: 5px solid black;
color: #FCFCFF;
margin-top: 10px;
}
li {
float: left;
padding-right: 30px;
}
li a {
display: block;
color: white;
text-decoration: none;
padding: 19px 16px;
border: 2px solid #ffffff;
right: -100px;
}
li a:hover {
color: #ffffff;
background: #FF9940;
transition: all 0.4s ease 0s;
}
ul {
transition: all 0.4s ease 0s;
list-style-type: none;
text-decoration: none;
font-size: 12px;
text-transform: uppercase;
color: #ffffff;
background: transparent;
display: inline-block;
position: absolute;
text-align: center;
padding: 0px;
top: 28px;
left: 23px;
right: 23px;
width: 100%;
}
h2 {
text-align: center;
font-size: 25px;
}
h2 p {
font-size: 18px;
}
.right-button {
float: right;
padding-right: 47px
}
.other-button {
float: right;
padding-right: 30px;
}
#timeline {
font-family: tahoma;
font-size: 15px;
line-height: 1.75;
padding: 0;
margin-left: 400px;
height: 400px;
width: 650px;
display: flex;
background-color: #031625;
}
.t1-item:before,
.t1-item:after {
transform: translate3d(0, 0, 0);
content: ' ';
position: absolute;
left: 0;
top: 0;
}
.t1-item {
padding: 25px;
transform: translate3d(0, 0, 0);
position: relative;
width: 25%;
margin-top: 20rem;
color: white;
overflow: hidden;
transition: width 0.5s ease;
}
.t1-item:after {
background: rgba(3, 22, 37, 0.85);
opacity: 1;
transition: opacity .5s ease;
}
.t1-item:before {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%);
z-index: 1;
opacity: 0;
transform: translate3d(0, 0, 0) translateY(50%);
transition: opacity .5s ease, transform .5s ease;
}
.t1-item:hover {
width: 30%;
}
.t1-item:hover:after {
opacity: 0;
}
.t1-item:hover:before {
opacity: 1;
transform: translate3d(0, 0, 0) translateY(0);
transition: opacity 1s ease, transform 1s ease .25s;
}
.t1-item:hover .t1-content {
opacity: 1;
transform: translateY(0);
transition: all .75s ease .5s;
}
.t1-item:hover .t1-bg {
filter: grayscale(0);
}
.t1-content {
transform: translate3d(0, 0, 0) translateY(25px);
position: relative;
z-index: 1;
text-align: center;
margin: 0.1618em;
top: 55%;
opacity: 0%;
}
.t1-content h3 {
font-family: tahoma;
text-transform: uppercase;
color: #1779cf;
font-size: 1.44rem;
font-weight: normal;
}
.t1-year {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
border-top: 1px solid white;
border-bottom: 1px solid white;
}
.t1-year p {
font-family: tahoma;
font-size: 1.628rem;
line-height: 0;
}
.t1-bg {
transform: translate3d(0, 0, 0);
position: absolute;
left: 0;
top: 0px;
background-size: cover;
background-position: center center;
transition: filter .5se ease;
filter: grayscale(100%);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Isabelle Kreienbrink </title>
<link href="styles/style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
</head>
<body>
<h1> Isabelle Kreienbrink </h1>
<ul>
<li>Resume</li>
<li>Academics</li>
<li>Projects</li>
<li class="right-button">Contact Info</li>
<li class="other-button">Test</li>
<li class="other-button">Testing</li>
</ul>
<h2> Welcome to my website!
<p> I hope you learn a little about me while you're here. </p>
</h2>
<section id="timeline">
<div class="t1-item">
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg); height: 100%; width: 100%;">
</div>
<div class="t1-year">
<p class="f2 heading">2014</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg) height: 100%, width: 100%"></div>
<div class="t1-year">
<p class="f2 heading">2015</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(001.jpeg)"></div>
<div class="t1-year">
<p class="f2 heading">2016</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
</section>
</body>
</html>

Can't get background image to show up on website

I'm trying to put a timeline on my website but can't seem to get my background image to show up.
What I've tried:
checking the path of my image
matching the height of my divs/HTML elements to make sure the image is covering the right height
made sure I put background-image in my HTML tags
tried using a negative value for top to move the image around - didn't work
I also tried deleting my other styling elements and adding them back in to see if they were causing it. I'm not quite sure where I'm going wrong.
The CSS element I'm wrestling with is called t1-bg (located at bottom of CSS sheet) - here is my code:
(run the snippet in a full window for a proper overview)
html {
font-size: 10px;
font-family: Raleway;
width: 100%;
height: 100%;
background: linear-gradient(#FF9940, white);
font-weight: normal;
}
h1 {
font-family: Raleway;
padding: 20px;
font-size: 53px;
text-shadow: 2px 2px 1px grey;
background-color: #1E2752;
text-align: center;
border: 5px solid black;
color: #FCFCFF;
margin-top: 10px;
}
li {
float: left;
padding-right: 30px;
}
li a {
display: block;
color: white;
text-decoration: none;
padding: 19px 16px;
border: 2px solid #ffffff;
right: -100px;
}
li a:hover {
color: #ffffff;
background: #FF9940;
transition: all 0.4s ease 0s;
}
ul {
transition: all 0.4s ease 0s;
list-style-type: none;
text-decoration: none;
font-size: 12px;
text-transform: uppercase;
color: #ffffff;
background: transparent;
display: inline-block;
position: absolute;
text-align: center;
padding: 0px;
top: 28px;
left: 23px;
right: 23px;
width: 100%;
}
h2 {
text-align: center;
font-size: 25px;
}
h2 p {
font-size: 18px;
}
.right-button {
float: right;
padding-right: 47px
}
.other-button {
float: right;
padding-right: 30px;
}
#timeline {
font-family: tahoma;
font-size: 15px;
line-height: 1.75;
padding: 0;
margin-left: 400px;
height: 400px;
width: 650px;
display: flex;
background-color: #031625;
}
.t1-item:before,
.t1-item:after {
transform: translate3d(0, 0, 0);
content: ' ';
position: absolute;
left: 0;
top: 0;
}
.t1-item {
padding: 25px;
transform: translate3d(0, 0, 0);
position: relative;
width: 25%;
margin-top: 20rem;
color: white;
overflow: hidden;
transition: width 0.5s ease;
}
.t1-item:after {
background: rgba(3, 22, 37, 0.85);
opacity: 1;
transition: opacity .5s ease;
}
.t1-item:before {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%);
z-index: 1;
opacity: 0;
transform: translate3d(0, 0, 0) translateY(50%);
transition: opacity .5s ease, transform .5s ease;
}
.t1-item:hover {
width: 30%;
}
.t1-item:hover:after {
opacity: 0;
}
.t1-item:hover:before {
opacity: 1;
transform: translate3d(0, 0, 0) translateY(0);
transition: opacity 1s ease, transform 1s ease .25s;
}
.t1-item:hover .t1-content {
opacity: 1;
transform: translateY(0);
transition: all .75s ease .5s;
}
.t1-item:hover .t1-bg {
filter: grayscale(0);
}
.t1-content {
transform: translate3d(0, 0, 0) translateY(25px);
position: relative;
z-index: 1;
text-align: center;
margin: 0.1618em;
top: 55%;
opacity: 0%;
}
.t1-content h3 {
font-family: tahoma;
text-transform: uppercase;
color: #1779cf;
font-size: 1.44rem;
font-weight: normal;
}
.t1-year {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
border-top: 1px solid white;
border-bottom: 1px solid white;
}
.t1-year p {
font-family: tahoma;
font-size: 1.628rem;
line-height: 0;
}
.t1-bg {
transform: translate3d(0, 0, 0);
position: absolute;
left: 0;
background-size: cover;
background-position: center center;
transition: filter .5se ease;
filter: grayscale(100%);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Isabelle Kreienbrink </title>
<link href="styles/style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
</head>
<body>
<h1> Isabelle Kreienbrink </h1>
<ul>
<li>Resume</li>
<li>Academics</li>
<li>Projects</li>
<li class="right-button">Contact Info</li>
<li class="other-button">Test</li>
<li class="other-button">Testing</li>
</ul>
<h2> Welcome to my website!
<p> I hope you learn a little about me while you're here. </p>
</h2>
<section id="timeline">
<div class="t1-item">
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg)">
</div>
<div class="t1-year">
<p class="f2 heading">2014</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg)"></div>
<div class="t1-year">
<p class="f2 heading">2015</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
<div class="t1-item">
<div class="t1-bg" style="background-image:url(001.jpeg)"></div>
<div class="t1-year">
<p class="f2 heading">2016</p>
</div>
<div class="t1-content">
<h3>Lorem ipsum dolor </h3>
<p>
test
</p>
</div>
</div>
</section>
</body>
</html>
As someone mentioned in a comment on your question, you have no height set on your div. It does in fact have no content. A css background image does not count as content in the html. You can easily prove this by creating a simple html file with just your div in it. If you do the following, there will be no image:
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg)"></div>
Add height and width and the image will appear:
<div class="t1-bg" style="background-image:url(https://www.eschoolnews.com/files/2016/12/computer-science-education-600x400.jpg); height: 100%; width: 100%"></div>

Hover effect +hyperlink on img

I'm trying place pictures as links, while having some hover effect on the image. Neither the hover effect or the link work at the moment.
I tried to use :hover on different elements, I tried to use z-index, I tried to check on selector specificity, but something stops hover effect entirely, but I can't see what's going wrong.
<div class="fourthsection">
<h1>Recent Projects</h1>
<div class="projectpic-container">
<div class="picbox">
<div class= "imgBox">
</div>
</div>
<div class="picbox">
<div class= "imgBox">
</div>
</div>
<div class="picbox">
<div class= "imgBox">
</div>
</div>
<div class="picbox">
<div class= "imgBox">
</div>
</div>
</div>
</div>
.fourthsection{
background-color: rgb(247, 197, 164);
position: relative;
padding-top: 80px;
padding-bottom: 60px;
font-family: 'Nunito', sans-serif;
z-index: -2;
font-size: 10px;
}
.fourthsection h1{
position: absolute;
margin-left: 15%;
margin-right: 15%;
font-size: 1.8rem;
letter-spacing: 3px;
top:2%;
padding-top:1.5%;
}
.projectpic-container{
display: flex;
flex-direction: row;
justify-content: space-around;
margin-left: 13%;
margin-right: 15%;
padding-top: 45px;
width: 80vw;
height: 28 vh;
}
.projectpic-container .picbox{
position: relative;
width: 400px;
height: 250px;
margin: 8px;
}
.projectpic-container .picbox .imgBox{
position: relative;
}
.projectpic-container .picbox .imgBox img{
max-width: 100%;
border-radius: 4%;
-webkit-filter: sepia(100%);
filter: sepia(100%);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.projectpic-container .picbox .imgBox:hover img{
transform: 0.3s ease-in;
-webkit-filter: sepia(0);
filter: sepia(0);
cursor: pointer;
-webkit-transform: 0.3s ease-in;
}
I actually don't know your whole page and I don't know if z-index is needed or not, but if you remove z-index: -2 from
.fourthsection{
background-color: rgb(247, 197, 164);
position: relative;
padding-top: 80px;
padding-bottom: 60px;
font-family: 'Nunito', sans-serif;
z-index: -2;
font-size: 10px;
}
it works just fine...here's the snippet (I obviously used an image from google with a href directed to google in target _blank)
.fourthsection{
background-color: rgb(247, 197, 164);
position: relative;
padding-top: 80px;
padding-bottom: 60px;
font-family: 'Nunito', sans-serif;
font-size: 10px;
}
.fourthsection h1{
position: absolute;
margin-left: 15%;
margin-right: 15%;
font-size: 1.8rem;
letter-spacing: 3px;
top:2%;
padding-top:1.5%;
}
.projectpic-container{
display: flex;
flex-direction: row;
justify-content: space-around;
margin-left: 13%;
margin-right: 15%;
padding-top: 45px;
width: 80vw;
height: 28 vh;
}
.projectpic-container .picbox{
position: relative;
width: 400px;
height: 250px;
margin: 8px;
}
.projectpic-container .picbox .imgBox{
position: relative;
}
.projectpic-container .picbox .imgBox img{
max-width: 100%;
border-radius: 4%;
-webkit-filter: sepia(100%);
filter: sepia(100%);
-webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.projectpic-container .picbox .imgBox:hover img{
transform: 0.3s ease-in;
-webkit-filter: sepia(0);
filter: sepia(0);
cursor: pointer;
-webkit-transform: 0.3s ease-in;
}
<div class="fourthsection">
<h1>Recent Projects</h1>
<div class="projectpic-container">
<div class="picbox">
<div class= "imgBox">
<img src="https://besthqwallpapers.com/Uploads/25-8-2016/3005/thumb2-remains-of-bridge-lake-park-kromelow-kromelow-lake-rakott.jpg" alt="Project1">
</div>
</div>
</div>
</div>
I had the same conclusion as alesssz.
Remove the z-index: -2; setting from the .fourthsection rule and things work fine. Put that setting back, and the hover action is broken.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="hu" xml:lang="hu" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Page Title</title>
<link href="__imghover.css" type="text/css" rel="stylesheet" />
</head>
<body>
<main>
<div class="fourthsection">
<h1>Recent Projects</h1>
<div class="projectpic-container">
<div class="picbox">
<div class="imgBox">
<img src="http://keve.maclab.org/pub/tmp/demopic.jpg" alt="Project1" />
</div>
</div>
<div class="picbox">
<div class="imgBox">
<img src="http://keve.maclab.org/pub/tmp/demopic.jpg" alt="Project2" />
</div>
</div>
<div class="picbox">
<div class= "imgBox">
<img src="http://keve.maclab.org/pub/tmp/demopic.jpg" alt="Project3" />
</div>
</div>
<div class="picbox">
<div class= "imgBox">
<img src="http://keve.maclab.org/pub/tmp/demopic.jpg" alt="Project4" />
</div>
</div>
</div>
</div>
</main>
</body>
</html>
Please note: I replaced the flask reference with a static img url.
.fourthsection {
background-color: rgb(247, 197, 164);
position: relative;
padding-top: 80px;
padding-bottom: 60px;
font-family: 'Nunito', sans-serif;
/*z-index: -2;*/
font-size: 10px;
}
.fourthsection h1 {
position: absolute;
margin-left: 15%;
margin-right: 15%;
font-size: 1.8rem;
letter-spacing: 3px;
top:2%;
padding-top:1.5%;
}
.projectpic-container {
display: flex;
flex-direction: row;
justify-content: space-around;
margin-left: 13%;
margin-right: 15%;
padding-top: 45px;
width: 80vw;
height: 28vh;
}
.projectpic-container .picbox {
position: relative;
width: 400px;
height: 250px;
margin: 8px;
}
.projectpic-container .picbox .imgBox {
position: relative;
}
.projectpic-container .picbox .imgBox img {
max-width: 100%;
border-radius: 4%;
-webkit-filter: sepia(100%);
filter: sepia(100%);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.projectpic-container .picbox .imgBox img:hover {
transform: 0.3s ease-in;
-webkit-filter: sepia(0);
filter: sepia(0);
cursor: pointer;
-webkit-transform: 0.3s ease-in;
}