Pure CSS carousel - issue with sliding animation on changing slides - css

I've created pure CSS based Carousal. I'm using javascript just for auto changing the slides, other than that everything is CSS. I'm trying to get the sliding animation effect on changing each slide through CSS "transition" property, but it's not sliding throughout the slide-container.
HTML:
<div class="carousel">
<div class="carousel-inner" id="carousel-inner">
<input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
<div class="carousel-item">
<h1>This is my first slide</h1>
</div>
<input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<h1>This is my second slide</h1>
</div>
<input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<h1>This is my third slide</h1>
</div>
<label for="carousel-3" class="carousel-control prev control-1">‹</label>
<label for="carousel-2" class="carousel-control next control-1">›</label>
<label for="carousel-1" class="carousel-control prev control-2">‹</label>
<label for="carousel-3" class="carousel-control next control-2">›</label>
<label for="carousel-2" class="carousel-control prev control-3">‹</label>
<label for="carousel-1" class="carousel-control next control-3">›</label>
<ol class="carousel-indicators">
<li>
<label for="carousel-1" class="carousel-bullet">●</label>
</li>
<li>
<label for="carousel-2" class="carousel-bullet">●</label>
</li>
<li>
<label for="carousel-3" class="carousel-bullet">●</label>
</li>
</ol>
</div>
</div>
Javascript:
var n = 0;
window.ev = false;
document.getElementById("carousel-inner").onmouseenter = function () {
window.ev = true;
};
document.getElementById("carousel-inner").onmouseleave = function () {
window.ev = false;
setTimeout(autoSlide, 400);
};
function autoSlide() {
if (window.ev == false) {
n++;
if (n === 4)
n = 1;
document.getElementById("carousel-" + n).checked = true;
setTimeout(autoSlide, 4000);
}
}
autoSlide();
CSS:
.carousel {
position: relative;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.64);
width: 100%;
}
.carousel-inner {
position: relative;
overflow: hidden;
width: 100%;
}
.carousel-open:checked + .carousel-item {
position: static;
opacity: 100;
}
.carousel-item {
position: absolute;
opacity: 0;
-webkit-transition: opacity 0.6s ease-out;
transition: opacity 0.6s ease-out;
display: block;
min-height: 330px;
width: calc(100% - 100px);
margin: 0 auto;
}
.carousel-control {
border-radius: 50%;
color: #aaa;
cursor: pointer;
display: none;
font-size: 80px;
line-height: 35px;
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
cursor: pointer;
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
text-align: center;
width: 40px;
z-index: 10;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
color: #000;
}
#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
display: block;
}
.carousel-indicators {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
z-index: 10;
}
.carousel-indicators li {
display: inline-block;
}
.carousel-bullet {
color: #757575;
cursor: pointer;
display: block;
font-size: 24px;
font-weight: 300;
}
#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
color: #009eb1;
}
.carousel-item {
background: lightblue;
padding: 20px;
text-align: center;
}
Here's the js fiddle working example: https://jsfiddle.net/jt68zz9L/4/
Let us know if anyone of you have CSS solution for sliding animation. Appreciate your help.

Cool idea BTW, Always good to make heavy / continuous animations in CSS for GPU leverage.
Small problem in the CSS :-)
You have used the transform property only on the controls, which is redundant.
You needed to:
1) Add transitions to all, not just opacity for the items.
2) Give the checked items a translate of 0, and the unchecked items a 100% translate x axis (you could make that negative to switch the direction.)
Here's the jsfiddle I forked from you: JsFiddle
And here is the updated code plus snippet:
var n = 0;
window.ev = false;
document.getElementById("carousel-inner").onmouseenter = function () {
window.ev = true;
};
document.getElementById("carousel-inner").onmouseleave = function () {
window.ev = false;
setTimeout(autoSlide, 400);
};
function autoSlide() {
if (window.ev == false) {
n++;
if (n === 4)
n = 1;
document.getElementById("carousel-" + n).checked = true;
setTimeout(autoSlide, 4000);
}
}
autoSlide();
.carousel {
position: relative;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.64);
width: 100%;
}
.carousel-inner {
position: relative;
overflow: hidden;
width: 100%;
}
.carousel-open:checked + .carousel-item {
position: static;
opacity: 100;
}
.carousel-item {
position: absolute;
opacity: 0;
-webkit-transition: all 1s ease-out;
transition: all 1s ease-out;
display: block;
min-height: 330px;
width: calc(100% - 100px);
margin: 0 auto;
-webkit-transform: translate(100%, 0px);
cursor: pointer;
-ms-transform: translate(100%, 0px);
transform: translate(100%, 0px);
}
.carousel-open:checked + .carousel-item {
-webkit-transform: translate(0px, 0px);
cursor: pointer;
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
}
.carousel-control {
border-radius: 50%;
color: #aaa;
cursor: pointer;
display: none;
font-size: 80px;
line-height: 35px;
position: absolute;
top: 50%;
/* -webkit-transform: translate(0, -50%);
cursor: pointer;
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);*/
text-align: center;
width: 40px;
z-index: 10;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
color: #000;
}
#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
display: block;
}
.carousel-indicators {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
z-index: 10;
}
.carousel-indicators li {
display: inline-block;
}
.carousel-bullet {
color: #757575;
cursor: pointer;
display: block;
font-size: 24px;
font-weight: 300;
}
#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
color: #009eb1;
}
.carousel-item {
background: lightblue;
padding: 20px;
text-align: center;
}
<div class="carousel">
<div class="carousel-inner" id="carousel-inner">
<input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
<div class="carousel-item">
<h1>This is my first slide</h1>
</div>
<input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<h1>This is my second slide</h1>
</div>
<input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<h1>This is my third slide</h1>
</div>
<label for="carousel-3" class="carousel-control prev control-1">‹</label>
<label for="carousel-2" class="carousel-control next control-1">›</label>
<label for="carousel-1" class="carousel-control prev control-2">‹</label>
<label for="carousel-3" class="carousel-control next control-2">›</label>
<label for="carousel-2" class="carousel-control prev control-3">‹</label>
<label for="carousel-1" class="carousel-control next control-3">›</label>
<ol class="carousel-indicators">
<li>
<label for="carousel-1" class="carousel-bullet">●</label>
</li>
<li>
<label for="carousel-2" class="carousel-bullet">●</label>
</li>
<li>
<label for="carousel-3" class="carousel-bullet">●</label>
</li>
</ol>
</div>
</div>

Related

Show a hidden side panel with :checked

I would like to have a navigation menu in a side panel which can be toggled into view with an animated hamburger menu. I would like to create this with CSS only, without any JS.
The :checked pseudo-class seems the way to go, but I can't get it to work. The code I have so far:
.site-navigation {
z-index: 99;
background-color: rgba(0, 0, 0, 0.8);
position: fixed;
top: 0;
left: 0;
width: 40%;
height: 100%;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease-in-out;
}
.toggle-btn {
display: block;
position: fixed;
z-index: 10;
right: 10px;
top: 10px;
cursor: pointer;
}
.toggle-btn .bar {
width: 30px;
height: 2px;
margin: 7px auto;
background-color: #fff;
transition: all 0.3s ease-in-out;
box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3);
}
.toggle-btn .bar:nth-child(2) {
width: 28px;
}
#toggle {
display: none;
}
#toggle:checked~.site-navigation {
display: block;
opacity: 1;
visibility: visible;
}
#toggle:checked~nav ul {
top: 70px;
}
#toggle:checked~nav ul li {
transform: translateY(0px);
opacity: 1;
}
#toggle:checked+label.toggle-btn .bar {
background-color: #efefef;
}
#toggle:checked+label.toggle-btn .bar:nth-child(2) {
opacity: 0;
}
#toggle:checked+label.toggle-btn .bar:nth-child(1) {
transform: translateY(10px) rotate(45deg);
}
#toggle:checked+label.toggle-btn .bar:nth-child(3) {
transform: translateY(-8px) rotate(-45deg);
}
<header id="masthead" class="site-header" role="banner">
<div class="container">
<div id="brand">
<h1 class="site-title">Nice site</h1>
</div>
<div id="menu">
<input type="checkbox" id="toggle">
<label class="toggle-btn toggle-btn__cross" for="toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</label>
</div>
<div class="clear"></div>
</div>
<!--/container -->
<!-- .site-navigation .main-navigation -->
<nav role="navigation" id="navigation" class="site-navigation main-navigation">
<span class="menuLabel">menu</span>
<ul>
<li>Home</li>
<li>About</li>
<li>News</li>
<li>Contact</li>
</ul>
</nav>
Any help and/or advice would be much appreciated!
Fix your typos in CSS, and move the INPUT element outside of #menu
<header id="masthead" class="site-header" role="banner">
<!-- Move it right here -->
<input type="checkbox" id="toggle">
in order for this line of CSS to make sense
#toggle:checked ~ .site-navigation {
There's also another way by using :has() but I'll stick to this simpler solution.

how to remove white space on right side of page

I'm building a responsive site and I'm using overflow-x: hidden property to stop the page from scrolling horizontally and showing white space but it's not working on phones. Every time I navigate back to the page, the horizontal scrollbar is shown again and white space appears on the right. I have looked at various other questions on this issue but cannot seem to solve it.
I believe it is related to the cards on the page, is any of the styling on the cards causing this issue? How can I remove the white space?
html {
overflow-x: hidden;
}
.portfolio-header {
margin-top: 19rem;
margin-left: 31%;
font-size: 30px;
}
}
.card-square
{
position: relative;
width: 90%;
height: 300px;
display: flex;
margin-left: 0px;
margin-top: 50px;
margin-bottom: 100px;
justify-content: center;
align-items: center;
}
.card-square-2 {
margin-top: 0rem;
}
.card-square span:nth-child(1) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate 6s linear infinite;
}
.card-square:hover span:nth-child(1) {
border: none;
background: rgba(22,168,194,0.8);
}
.card-square span:nth-child(2) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate2 4s linear infinite;
}
.card-square:hover span:nth-child(2) {
border: none;
background: rgba(22,168,194,0.8);
}
.card-square span:nth-child(3) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate 10s linear infinite;
}
.card-square:hover span:nth-child(3) {
border: none;
background: rgba(22,168,194,0.8);
}
#keyframes animate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#keyframes animate2 {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
.content {
position: relative;
color: #000;
text-align: center;
transition: 0.5s;
z-index: 1000;
}
.content a {
position: relative;
/* display: inline-block; */
margin-top: 10px;
border: 2px solid #fff;
padding: 6px 18px;
text-decoration: none;
color: #fff;
margin-left: 12px;
font-weight: 600;
border-radius: 73% 27% 44% 56% /
49% 44% 56% 51%;
}
.content a:hover {
background: #000;
color: #333;
}
.content p, .content h2 {
text-align: center;
width: 85%;
margin-left: 7.5%;
}
.content p {
font-size: 16px;
}
#media only screen and (min-width: 768px) {
.card-square {
width: 400px;
height: 400px;
margin-left: 130px;
}
.card-square-2 {
margin-top: -500px;
margin-left: 55%;
}
.card-square-4 {
margin-left: 55%;
margin-top: -500px;
}
.content p {
font-size: 20px;
}
}
<section class="portfolio" id="portfolio">
<h1 class="portfolio-header">Card section</h1>
<div class="card-square">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 1</h2>
<p> This is card 1.
</p>
Link btn
</div>
</div>
<div class="card-square card-square-2">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 2</h2>
<p>This is card 2. </p>
Link
</div>
</div>
<div class="card-square card-square-3">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 3</h2>
<p>This is card 3.</p>
Link
<a class="second-btn" href="#">Link 2</a>
</div>
</div>
<div class="card-square card-square-4">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 4</h2>
<p>This is card 4.</p>
Link 4
</div>
</div>
</section>
It's because you use width: 100vw - if you have a vertical scroll, your vw will not take the scrollbar into account and will give you horizontal scroll too. Use width: 100% instead (or remove it as h2 is a block element and will take the full width anyway)
html,
body {
margin: 0;
min-height: 100%;
min-width: 100%;
}
body {
margin: 0;
padding: 0;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
section {
margin-bottom: -33px;
}
h1 {
margin-left: 20%;
color: rgb(22, 168, 194);
}
/* Hero Image & navbar */
.banner-text {
width: 100%;
position: absolute;
}
* {
box-sizing: border-box;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: none;
color: white;
font-size: 20px;
}
.navbar-links ul {
margin: 0;
padding: 0;
display: flex;
}
.navbar-links li {
list-style: none;
}
.navbar-links li a {
text-decoration: none;
color: white;
padding-left: 1rem;
padding-right: 1em;
display: block;
}
.navbar-links li:hover {
background: #555;
}
.toggle-button {
position: absolute;
top: .75rem;
right: 2.5rem;
display: none;
flex-direction: column;
justify-content: space-between;
width: 31px;
height: 21px;
}
/* Phones */
#media (min-width: 320px) and (max-width: 480px) {
.toggle-button {
display: flex;
}
.navbar-links li:hover {
background: #555;
}
.navbar-links {
display: none;
width: 100%;
}
.navbar {
flex-direction: column;
align-items: flex-start;
}
.navbar-links ul {
flex-direction: column;
width: 100%;
/* margin-top: 30px; */
}
.navbar-links li {
text-align: center;
}
.navbar-links li .navlink {
padding: 0.5rem 1rem;
}
.navbar-links.active {
display: flex;
}
}
.toggle-button .bar {
height: 3px;
width: 100%;
background: white;
border-radius: 10px;
}
.banner-text h2 {
text-align: center;
color: #fff;
width: 100%;
font-size: 28px;
margin-top: 48%;
}
.banner-text .name {
margin-bottom: -95px;
}
/* For desktop: */
#media only screen and (min-width: 768px) {
.banner-text h2 {
margin-top: 14%;
font-size: 54px;
}
.banner-text .name {
margin-bottom: -100px;
}
}
.animation-area {
/* background: linear-gradient(to left, #16A8C2, #1B1C1C); */
background: rgb(22, 168, 194);
background: linear-gradient(0deg, rgba(22, 168, 194, 1) 0%, rgba(27, 28, 28, 1) 100%);
width: 100%;
height: 100vh;
}
.box-area {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 97%;
overflow: hidden;
}
.box-area .box-item {
position: absolute;
display: block;
list-style: none;
width: 25px;
height: 25px;
background: rgba(255, 255, 255, 0.2);
animation: animatedSquares 20s linear infinite;
bottom: -150px;
}
.box-area li:nth-child(1) {
left: 86%;
width: 80px;
height: 80px;
animation-delay: 0s
}
.box-area li:nth-child(2) {
left: 12%;
width: 30px;
height: 30px;
animation-delay: 1.5s;
animation-duration: 10s;
}
.box-area li:nth-child(3) {
left: 70%;
width: 100px;
height: 100px;
animation-duration: 5.5s;
}
.box-area li:nth-child(4) {
left: 42%;
width: 150px;
height: 150px;
animation-delay: 0s;
animation-duration: 15s;
}
.box-area li:nth-child(5) {
left: 65%;
width: 40px;
height: 40px;
animation-delay: 0s;
}
.box-area li:nth-child(6) {
left: 15%;
width: 110px;
height: 110px;
animation-delay: 3.5s;
}
#keyframes animatedSquares {
0% {
transform: translateY(0) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(-800px) rotate(360deg);
opacity: 0;
}
}
<section>
<div class="banner-text">
<nav class="navbar">
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="navbar-links">
<ul>
<li><a class="navlink" href="#">navlink1</a></li>
<li><a class="navlink" href="#">navlink2</a></li>
<li><a class="navlink" href="#">navlink3</a></li>
<li><a class="navlink" href="#">navlink4">CV</a></li>
</ul>
</div>
</nav>
<h2 class="header name">title name</h2>
<h2 class="header role">title role</h2>
</div>
<div class="animation-area">
<ul class="box-area">
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
</ul>
</div>
</section>
<section class="about" id="about">
<!-- social media icon bar -->
<ul class="social-media">
<li class="social-item">
<a href="" class="github">
<i class="fa fa-github"></i></a>
</li>
<li class="social-item">
<a href="">
<i class="fa fa-linkedin"></i></a>
</li>
<li class="social-item">
<a href="">
<i class="fa fa-stack-overflow"></i></a>
</li>
</ul>
<ul class="social-media-2">
<li class="social-item">
<a href="" class="codepen">
<i class="fa fa-codepen"></i></a>
</li>
<li class="social-item">
<a href="" class="dribble">
<i class="fa fa-dribbble"></i></a>
</li>
<li class="social-item">
<a href="" class="twitter">
<i class="fa fa-twitter"></i></a>
</li>
</ul>
<h1 class="about-header">About</h1>
<p class="about-text">text
</p>
<p class="career-story">
text
</p>
<div class="polaroid">
<img class="work-colleagues" src="./Images/img.jpg" alt="alt">
<div class="description">
<p class="description-text">text
<a class="featured-link" href="link" width="100%" height="100%">
Polaroid text</a> </p>
</div>
</div>
<p class="interests">
text
</p>
<div class="polaroid polaroid-2">
<img src="./Images/img.jpg" alt="alt" width="100%" height="100%">
<div class="description">
<p class="description-text">text
</p>
</div>
</div>
</section>
You are on the right track, but one thing to keep in mind is that you need to also add meta tags to your HTML header.
Solution
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0, minimum-scale=1, maximum-scale=1">
And of course, in the CSS specify the overflow behavior:
html {
overflow-x: hidden;
}
Explanation
I'll break down the meta tag:
width=device-width this means we are telling the browser to adjust to the device-width
width=minimum-scale this is the smallest scale that you should go
width=maximum-scale this is the biggest scale that you should go
width=initial-scale where to start
user-scalable to allow the user to pinch (zoom in on mobile) or not.
You can read more about it on w3schools.
I found the reason why it's behaving like this.
You have the header and main content in a single section.
This caused all the issues.
Always try to segregate section wisely
Once you segregate. you can see the cards displaying in center.
later adjust your margin-left for .card-square class.
I haven't changed your CSS. Just modified your HTML to segregate the sections. now I cant see white space in the mobile view.
<section class="portfolio" id="portfolio">
<h1 class="portfolio-header">Card section</h1>
</section><section>
<div class="card-square">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 1</h2>
<p> This is card 1.
</p>
Link btn
</div>
</div>
<div class="card-square card-square-2">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 2</h2>
<p>This is card 2. </p>
Link
</div>
</div>
<div class="card-square card-square-3">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 3</h2>
<p>This is card 3.</p>
Link
<a class="second-btn" href="#">Link 2</a>
</div>
</div>
<div class="card-square card-square-4">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 4</h2>
<p>This is card 4.</p>
Link 4
</div>
</div>
</section>

How to make my slider responsive

I have a problem and this isn't really my area and am not able to find a good solution, please help me. I want to make my slider on my website responsive. Do you have any idea how I should do it?
The slider needs to be smaller or be shaped differently when I make the window smaller. Can I use the #media rule or is it something else I should do?
Thanx for helping a beginner like me:)!
<ul class="slides">
<input type="radio" name="radio-btn" id="img-1" checked />
<li class="slide-container">
<div class="slide">
<img src="bilder/blommor.jpg" />
</div>
<div class="nav">
<label for="img-6" class="prev">‹</label>
<label for="img-2" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-2" />
<li class="slide-container">
<div class="slide">
<img src="bilder/Berg.jpg" />
</div>
<div class="nav">
<label for="img-1" class="prev">‹</label>
<label for="img-3" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-3" />
<li class="slide-container">
<div class="slide">
<img src="bilder/water.jpg" />
</div>
<div class="nav">
<label for="img-2" class="prev">‹</label>
<label for="img-4" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-4" />
<li class="slide-container">
<div class="slide">
<img src="bilder/ros.jpg" />
</div>
<div class="nav">
<label for="img-3" class="prev">‹</label>
<label for="img-5" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-5" />
<li class="slide-container">
<div class="slide">
<img src="bilder/glasogon.jpg" />
</div>
<div class="nav">
<label for="img-4" class="prev">‹</label>
<label for="img-6" class="next">›</label>
</div>
</li>
<li class="nav-dots">
<label for="img-1" class="nav-dot" id="img-dot-1"></label>
<label for="img-2" class="nav-dot" id="img-dot-2"></label>
<label for="img-3" class="nav-dot" id="img-dot-3"></label>
<label for="img-4" class="nav-dot" id="img-dot-4"></label>
<label for="img-5" class="nav-dot" id="img-dot-5"></label>
</li>
Css:
#import url(https://fonts.googleapis.com/css?family=Varela+Round);
html, body { background: #333 url("https://codepen.io/images/classy_fabric.png"); }
.slides {
padding: 0;
width: 609px;
height: 420px;
display: block;
margin: 0 auto;
position: relative;
}
.slides * {
user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.slides input { display: none; }
.slide-container { display: block; }
.slide {
top: 0;
opacity: 0;
width: 609px;
height: 420px;
display: block;
position: absolute;
transform: scale(0);
transition: all .7s ease-in-out;
}
.slide img {
width: 100%;
height: 100%;
}
.nav label {
width: 200px;
height: 100%;
display: none;
position: absolute;
opacity: 0;
z-index: 9;
cursor: pointer;
transition: opacity .2s;
color: #FFF;
font-size: 156pt;
text-align: center;
line-height: 380px;
font-family: "Varela Round", sans-serif;
background-color: rgba(255, 255, 255, .3);
text-shadow: 0px 0px 15px rgb(119, 119, 119);
}
.slide:hover + .nav label { opacity: 0.5; }
.nav label:hover { opacity: 1; }
.nav .next { right: 0; }
input:checked + .slide-container .slide {
opacity: 1;
transform: scale(1);
transition: opacity 1s ease-in-out;
}
input:checked + .slide-container .nav label { display: block; }
.nav-dots {
width: 100%;
bottom: 9px;
height: 11px;
display: block;
position: absolute;
text-align: center;
}
.nav-dots .nav-dot {
top: -5px;
width: 11px;
height: 11px;
margin: 0 4px;
position: relative;
border-radius: 100%;
display: inline-block;
background-color: rgba(0, 0, 0, 0.6);
}
.nav-dots .nav-dot:hover {
cursor: pointer;
background-color: rgba(0, 0, 0, 0.8);
}
input#img-1:checked ~ .nav-dots label#img-dot-1,
input#img-2:checked ~ .nav-dots label#img-dot-2,
input#img-3:checked ~ .nav-dots label#img-dot-3,
input#img-4:checked ~ .nav-dots label#img-dot-4,
input#img-5:checked ~ .nav-dots label#img-dot-5,
input#img-6:checked ~ .nav-dots label#img-dot-6 {
background: rgba(0, 0, 0, 0.8);
}

Carousel wouldn't fill div

I'm trying to fill a div with an carousel. I got it to work but the carousel wouldn't fill the width of the entire div and I can't seem to be able to get it to work.
I made a jsfiddle to let you see:
https://jsfiddle.net/svdvem97/
I'd like to fill the div with just a little bit of padding on the sides, but whatever I try, the width of the carousel wouldn't change.
Thanks in advance.
#wrapper
{
background: rgba(162,162,162,.1);
}
#banner-wrapper
{
overflow: hidden;
padding: 3em 0em;
background: #E24E2A;
}
#banner
{
overflow: hidden;
width: 1000px;
padding: 0px 100px;
text-align: center;
color: rgba(255,255,255,.7);
border-bottom: 2px solid #E3E3E3;
}
#banner a
{
color: rgba(255,255,255,.9);
}
#banner .box-left
{
float: left;
}
#banner .box-right
{
float: right;
}
#banner h2
{
margin: 0em;
padding: 0em;
font-weight: 400;
font-size: 1.6em;
color: #F8F8FF;
}
#banner span
{
display: block;
padding-top: 0.20em;
text-transform: uppercase;
font-size: 1.2em;
color: #A2A2A2;
}
.carousel {
position:relative;
box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.64);
margin-top: 10px;
margin-bottom: 10px;
}
.carousel-inner {
position: relative;
overflow: hidden;
}
.carousel-open:checked + .carousel-item {
position: static;
opacity: 100;
}
.carousel-item {
position: absolute;
opacity: 0;
-webkit-transition: opacity 0.6s ease-out;
transition: opacity 0.6s ease-out;
}
.carousel-item img {
display: block;
height: auto;
max-width: 100%;
}
.carousel-control {
background: rgba(0, 0, 0, 0.28);
border-radius: 50%;
color: #fff;
cursor: pointer;
display: none;
font-size: 40px;
height: 40px;
line-height: 35px;
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
cursor: pointer;
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
text-align: center;
width: 40px;
z-index: 10;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
background: rgba(0, 0, 0, 0.8);
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
display: block;
}
.carousel-indicators {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 2%;
left: 0;
right: 0;
text-align: center;
z-index: 10;
}
.carousel-indicators li {
display: inline-block;
margin: 0 5px;
}
.carousel-bullet {
color: #fff;
cursor: pointer;
display: block;
font-size: 35px;
}
.carousel-bullet:hover {
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
color: #428bca;
}
#title {
width: 100%;
position: absolute;
padding: 0px;
margin: 0px auto;
text-align: center;
font-size: 27px;
color: rgba(255, 255, 255, 1);
font-family: 'Open Sans', sans-serif;
z-index: 9999;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
}
<div id="wrapper" class= "container">
<div id="banner" class="container">
<div class="carousel">
<div class="carousel-inner">
<input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/0079D8/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/DC5732/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="http://fakeimg.pl/2000x300/289672/fff/?text=Test">
</div>
<label for="carousel-3" class="carousel-control prev control-1">‹</label>
<label for="carousel-2" class="carousel-control next control-1">›</label>
<label for="carousel-1" class="carousel-control prev control-2">‹</label>
<label for="carousel-3" class="carousel-control next control-2">›</label>
<label for="carousel-2" class="carousel-control prev control-3">‹</label>
<label for="carousel-1" class="carousel-control next control-3">›</label>
<ol class="carousel-indicators">
<li>
<label for="carousel-1" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-2" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-3" class="carousel-bullet">•</label>
</li>
</ol>
</div>
</div>
</div>
</div>
Added style to #banner class
#wrapper
{
background: rgba(162,162,162,.1);
}
#banner-wrapper
{
overflow: hidden;
padding: 3em 0em;
background: #E24E2A;
}
#banner
{
overflow: hidden;
/* set width to 100% */
width: 98%;
/* delete the padding */
/* added margin */
margin :0 1%;
text-align: center;
color: rgba(255,255,255,.7);
border-bottom: 2px solid #E3E3E3;
}
#banner a
{
color: rgba(255,255,255,.9);
}
#banner .box-left
{
float: left;
}
#banner .box-right
{
float: right;
}
#banner h2
{
margin: 0em;
padding: 0em;
font-weight: 400;
font-size: 1.6em;
color: #F8F8FF;
}
#banner span
{
display: block;
padding-top: 0.20em;
text-transform: uppercase;
font-size: 1.2em;
color: #A2A2A2;
}
.carousel {
position:relative;
box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.64);
margin-top: 10px;
margin-bottom: 10px;
}
.carousel-inner {
position: relative;
overflow: hidden;
}
.carousel-open:checked + .carousel-item {
position: static;
opacity: 100;
}
.carousel-item {
position: absolute;
opacity: 0;
-webkit-transition: opacity 0.6s ease-out;
transition: opacity 0.6s ease-out;
}
.carousel-item img {
display: block;
height: auto;
max-width: 100%;
}
.carousel-control {
background: rgba(0, 0, 0, 0.28);
border-radius: 50%;
color: #fff;
cursor: pointer;
display: none;
font-size: 40px;
height: 40px;
line-height: 35px;
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
cursor: pointer;
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
text-align: center;
width: 40px;
z-index: 10;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
background: rgba(0, 0, 0, 0.8);
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
display: block;
}
.carousel-indicators {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 2%;
left: 0;
right: 0;
text-align: center;
z-index: 10;
}
.carousel-indicators li {
display: inline-block;
margin: 0 5px;
}
.carousel-bullet {
color: #fff;
cursor: pointer;
display: block;
font-size: 35px;
}
.carousel-bullet:hover {
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
color: #428bca;
}
#title {
width: 100%;
position: absolute;
padding: 0px;
margin: 0px auto;
text-align: center;
font-size: 27px;
color: rgba(255, 255, 255, 1);
font-family: 'Open Sans', sans-serif;
z-index: 9999;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
}
<div id="wrapper" class= "container">
<div id="banner" class="container">
<div class="carousel">
<div class="carousel-inner">
<input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/0079D8/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/DC5732/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="http://fakeimg.pl/2000x300/289672/fff/?text=Test">
</div>
<label for="carousel-3" class="carousel-control prev control-1">‹</label>
<label for="carousel-2" class="carousel-control next control-1">›</label>
<label for="carousel-1" class="carousel-control prev control-2">‹</label>
<label for="carousel-3" class="carousel-control next control-2">›</label>
<label for="carousel-2" class="carousel-control prev control-3">‹</label>
<label for="carousel-1" class="carousel-control next control-3">›</label>
<ol class="carousel-indicators">
<li>
<label for="carousel-1" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-2" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-3" class="carousel-bullet">•</label>
</li>
</ol>
</div>
</div>
</div>
</div>
1) you defined padding:0 100px; this shift #banner to right.
2) you use of width:1000px,if width browser be less than 1000px,scroll is created,so use width:100% and max-width:1000px;
#banner {
width: 100%;<----------------------Changed
padding: 0;<-----------------------Changed
max-width:1000px;<-----------------Changed
//more code...
}
#wrapper {
background: rgba(162,162,162,.1);
}
#banner-wrapper {
overflow: hidden;
padding: 3em 0em;
background: #E24E2A;
}
#banner {
overflow: hidden;
width: 100%;
max-width:1000px;
padding: 0px;
text-align: center;
color: rgba(255,255,255,.7);
border-bottom: 2px solid #E3E3E3;
}
#banner a {
color: rgba(255,255,255,.9);
}
#banner .box-left {
float: left;
}
#banner .box-right {
float: right;
}
#banner h2 {
margin: 0em;
padding: 0em;
font-weight: 400;
font-size: 1.6em;
color: #F8F8FF;
}
#banner span {
display: block;
padding-top: 0.20em;
text-transform: uppercase;
font-size: 1.2em;
color: #A2A2A2;
}
.carousel {
position:relative;
box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.64);
margin-top: 10px;
margin-bottom: 10px;
}
.carousel-inner {
position: relative;
overflow: hidden;
}
.carousel-open:checked + .carousel-item {
position: static;
opacity: 100;
}
.carousel-item {
position: absolute;
opacity: 0;
-webkit-transition: opacity 0.6s ease-out;
transition: opacity 0.6s ease-out;
}
.carousel-item img {
display: block;
height: auto;
max-width: 100%;
}
.carousel-control {
background: rgba(0, 0, 0, 0.28);
border-radius: 50%;
color: #fff;
cursor: pointer;
display: none;
font-size: 40px;
height: 40px;
line-height: 35px;
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
cursor: pointer;
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
text-align: center;
width: 40px;
z-index: 10;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
background: rgba(0, 0, 0, 0.8);
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
display: block;
}
.carousel-indicators {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 2%;
left: 0;
right: 0;
text-align: center;
z-index: 10;
}
.carousel-indicators li {
display: inline-block;
margin: 0 5px;
}
.carousel-bullet {
color: #fff;
cursor: pointer;
display: block;
font-size: 35px;
}
.carousel-bullet:hover {
color: #aaaaaa;
}
#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
color: #428bca;
}
#title {
width: 100%;
position: absolute;
padding: 0px;
margin: 0px auto;
text-align: center;
font-size: 27px;
color: rgba(255, 255, 255, 1);
font-family: 'Open Sans', sans-serif;
z-index: 9999;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
}
<div id="wrapper" class= "container">
<div id="banner" class="container">
<div class="carousel">
<div class="carousel-inner">
<input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/0079D8/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="https://fakeimg.pl/2000x300/DC5732/fff/?text=Test">
</div>
<input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
<div class="carousel-item">
<img src="http://fakeimg.pl/2000x300/289672/fff/?text=Test">
</div>
<label for="carousel-3" class="carousel-control prev control-1">‹</label>
<label for="carousel-2" class="carousel-control next control-1">›</label>
<label for="carousel-1" class="carousel-control prev control-2">‹</label>
<label for="carousel-3" class="carousel-control next control-2">›</label>
<label for="carousel-2" class="carousel-control prev control-3">‹</label>
<label for="carousel-1" class="carousel-control next control-3">›</label>
<ol class="carousel-indicators">
<li>
<label for="carousel-1" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-2" class="carousel-bullet">•</label>
</li>
<li>
<label for="carousel-3" class="carousel-bullet">•</label>
</li>
</ol>
</div>
</div>
</div>
</div>

How to make a login box that opens on hover over a menu item

I tried to make a small login box that opens when you hover over the login item in the menu bar, keeping in mind that the user doesn't have to go to another page to log in but I can't get it working.
Please help
body {
background-image: url("back.jpg");
background-attachment: fixed;
}
#container {
height: 1000px;
}
#head {
position: absolute;
height: 150px;
width: 100%;
background-color: #ffffff;
right: 0px;
left: 0px;
top: 0px;
}
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
width: 100%;
}
.navigationmenu-main {
list-style-type: none;
overflow: hidden;
background-color: #333;
}
.navigationmenu-parent {
float: left;
}
.navigationmenu-child {
display: inline-block;
color: white;
width: 50px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.navigationmenu-child:hover {
background-color: #111;
}
.navigationmenu-child:hover + .navigationmenu-line {
width: 100%;
}
.navigationmenu-line {
height: 3px;
background-color: red;
width: 0%;
-webkit-transition: width .3s;
-webkit-transition-timing-function: ease;
}
#main {
position: relative;
height: 700px;
width: 90%;
margin-left: auto;
margin-right: auto;
background-color: #ffffff;
top: 155px;
bottom: 100px;
box-shadow: 4px 4px 3px 1px #4d4d4d;
}
#logo-image {
position: relative;
margin-top: 40px;
margin-left: 40px;
}
#logo-image:hover {
-webkit-animation: blur 0.5s ease-in;
}
#-webkit-keyframes blur {
0% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
50% {
-webkit-filter: blur(1px);
filter: blur(2px);
}
100% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
}
.login-parent {
float: right;
}
.login-child {
display: inline-block;
color: white;
width: 60px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.login-child:hover {
background-color: #111;
}
.login-child:hover + .navigationmenu-line {
width: 100%;
}
#loginbox {
display: block;
visibility: hidden;
position: absolute;
top: 132px;
right: 90px;
z-index: 999;
background: #a6a6a6;
background-image: linear-gradient(top, #fff, #eee);
padding: 15px;
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, .9);
border-radius: 3px 0 3px 3px;
-webkit-transition: padding .3s;
}
.loginchild:hover + .loginbox {
visibility: visible;
}
#loginform {
padding: 5px;
}
#loginelement {
padding: 5px;
}
<!DOCTYPE html>
<title>
Le Meridian | A home away from home
</title>
<body>
<div id="container">
<div id="head">
<img src="logo.png" id="logo-image" height="20%" width="20%">
<ul id="nav_bar" class="navigationmenu-main">
<li class="navigationmenu-parent">
A
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
B
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
C
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
D
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
E
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
F
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
G
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child">Sign Up</div>
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child" id="trigger">Login ▼</div>
<div class="navigationmenu-line">
</div>
<div id="loginbox">
<form id="loginform">
<input type="text" name="email" id="loginelement">
<br>
<br>
<input type="password" name="password" id="loginelement">
<br>
<br>
<input type="submit" name="loginsubmit" id="loginelement">
<input type="checkbox" name="loggedin" id="loginelement"> Stay Signed In
</form>
</div>
</li>
</ul>
</div>
<div id="main">
dsa
</div>
</div>
</body>
To achieve what want you need to replace the hover code with this code:
.login-parent:hover #loginbox {
visibility: visible;
}
And that keep the loginbox visible as long as the cursor is inside the <li> tag with the class .login-parent.
if you do the hover on the div loginchild it will only show when you hover on that div.
body {
background-image: url("back.jpg");
background-attachment: fixed;
}
#container {
height: 1000px;
}
#head {
position: absolute;
height: 150px;
width: 100%;
background-color: #ffffff;
right: 0px;
left: 0px;
top: 0px;
}
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
width: 100%;
}
.navigationmenu-main {
list-style-type: none;
overflow: hidden;
background-color: #333;
}
.navigationmenu-parent {
float: left;
}
.navigationmenu-child {
display: inline-block;
color: white;
width: 50px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.navigationmenu-child:hover {
background-color: #111;
}
.navigationmenu-child:hover + .navigationmenu-line {
width: 100%;
}
.navigationmenu-line {
height: 3px;
background-color: red;
width: 0%;
-webkit-transition: width .3s;
-webkit-transition-timing-function: ease;
}
#main {
position: relative;
height: 700px;
width: 90%;
margin-left: auto;
margin-right: auto;
background-color: #ffffff;
top: 155px;
bottom: 100px;
box-shadow: 4px 4px 3px 1px #4d4d4d;
}
#logo-image {
position: relative;
margin-top: 40px;
margin-left: 40px;
}
#logo-image:hover {
-webkit-animation: blur 0.5s ease-in;
}
#-webkit-keyframes blur {
0% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
50% {
-webkit-filter: blur(1px);
filter: blur(2px);
}
100% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
}
.login-parent {
float: right;
}
.login-child {
display: inline-block;
color: white;
width: 60px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.login-child:hover {
background-color: #111;
}
.login-child:hover + .navigationmenu-line {
width: 100%;
}
#loginbox {
display: block;
visibility: hidden;
position: absolute;
top: 132px;
right: 90px;
z-index: 999;
background: #a6a6a6;
background-image: linear-gradient(top, #fff, #eee);
padding: 15px;
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, .9);
border-radius: 3px 0 3px 3px;
-webkit-transition: padding .3s;
}
.login-parent:hover #loginbox {
visibility: visible;
}
#loginform {
padding: 5px;
}
#loginelement {
padding: 5px;
}
<!DOCTYPE html>
<title>
Le Meridian | A home away from home
</title>
<body>
<div id="container">
<div id="head">
<img src="logo.png" id="logo-image" height="20%" width="20%">
<ul id="nav_bar" class="navigationmenu-main">
<li class="navigationmenu-parent">
A
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
B
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
C
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
D
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
E
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
F
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
G
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child">Sign Up</div>
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child" id="trigger">Login ▼</div>
<div class="navigationmenu-line">
</div>
<div id="loginbox">
<form id="loginform">
<input type="text" name="email" id="loginelement">
<br>
<br>
<input type="password" name="password" id="loginelement">
<br>
<br>
<input type="submit" name="loginsubmit" id="loginelement">
<input type="checkbox" name="loggedin" id="loginelement"> Stay Signed In
</form>
</div>
</li>
</ul>
</div>
<div id="main">
dsa
</div>
</div>
</body>
You had some typos on class names. Also the hover should be on the parent otherwise the box will not render properly. It will flicker as soon as your mouse focus gets out of the child class.
body {
background-image: url("back.jpg");
background-attachment: fixed;
}
#container {
height: 1000px;
}
#head {
position: absolute;
height: 150px;
width: 100%;
background-color: #ffffff;
right: 0px;
left: 0px;
top: 0px;
}
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
width: 100%;
}
.navigationmenu-main {
list-style-type: none;
overflow: hidden;
background-color: #333;
}
.navigationmenu-parent {
float: left;
}
.navigationmenu-child {
display: inline-block;
color: white;
width: 50px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.navigationmenu-child:hover {
background-color: #111;
}
.navigationmenu-child:hover + .navigationmenu-line {
width: 100%;
}
.navigationmenu-line {
height: 3px;
background-color: red;
width: 0%;
-webkit-transition: width .3s;
-webkit-transition-timing-function: ease;
}
#main {
position: relative;
height: 700px;
width: 90%;
margin-left: auto;
margin-right: auto;
background-color: #ffffff;
top: 155px;
bottom: 100px;
box-shadow: 4px 4px 3px 1px #4d4d4d;
}
#logo-image {
position: relative;
margin-top: 40px;
margin-left: 40px;
}
#logo-image:hover {
-webkit-animation: blur 0.5s ease-in;
}
#-webkit-keyframes blur {
0% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
50% {
-webkit-filter: blur(1px);
filter: blur(2px);
}
100% {
-webkit-filter: blur(0px);
filter: blur(0px);
}
}
.login-parent {
float: right;
}
.login-child {
display: inline-block;
color: white;
width: 60px;
text-align: center;
padding: 10px 16px;
text-decoration: none;
background-color: #333;
-webkit-transition: background-color .3s;
}
.login-child:hover {
background-color: #111;
}
.login-child:hover + .navigationmenu-line {
width: 100%;
}
#loginbox {
display: block;
visibility: hidden;
position: absolute;
top: 132px;
right: 90px;
z-index: 999;
background: #a6a6a6;
background-image: linear-gradient(top, #fff, #eee);
padding: 15px;
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, .9);
border-radius: 3px 0 3px 3px;
-webkit-transition: padding .3s;
}
.login-parent:hover #loginbox {
visibility: visible;
}
#loginform {
padding: 5px;
}
#loginelement {
padding: 5px;
}
<!DOCTYPE html>
<title>
Le Meridian | A home away from home
</title>
<body>
<div id="container">
<div id="head">
<img src="logo.png" id="logo-image" height="20%" width="20%">
<ul id="nav_bar" class="navigationmenu-main">
<li class="navigationmenu-parent">
A
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
B
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
C
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
D
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
E
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
F
<div class="navigationmenu-line">
</div>
</li>
<li class="navigationmenu-parent">
G
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child">Sign Up</div>
<div class="navigationmenu-line">
</div>
</li>
<li class="login-parent">
<div class="login-child" id="trigger">Login ▼</div>
<div class="navigationmenu-line">
</div>
<div id="loginbox">
<form id="loginform">
<input type="text" name="email" id="loginelement">
<br>
<br>
<input type="password" name="password" id="loginelement">
<br>
<br>
<input type="submit" name="loginsubmit" id="loginelement">
<input type="checkbox" name="loggedin" id="loginelement"> Stay Signed In
</form>
</div>
</li>
</ul>
</div>
<div id="main">
dsa
</div>
</div>
</body>

Resources