CSS Multi-Level Accordion Menu - css

I have written some codes in HTML and CSS. The output is shown in the screenshot.
When a menu item is selected ( is expanded), the color section at the right side of the menu disapears while aforementioned menu is selected (after mouse is not hovering the item).
How to make the color stay even after the mouse is not over the menu?
(Please do not suggest any Java Script code.)
CSS Multi-Level Accordion Menu
* {
margin: 0;
padding: 0;
font-family: Arial;
font-size: 14px;
}
.block {
float: right;
max-width: 360px;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
margin: 0;
}
.block > div {
display: block;
position: relative;
background-color: #fff;
color: #767676;
border-bottom: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
}
.block > div:nth-child(1):before {
font-family: 'FontAwesome';
content: "\F0CA";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #E94B3B;
background: none; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block > div:nth-child(1):hover:before {
background-position: 100% 0;
color: white;
}
.block > div:nth-child(2):before {
font-family: 'FontAwesome';
content: "\F0F6";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #ffb61c;
background: none; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block > div:nth-child(2):hover:before {
background-position: 100% 0;
color: white;
}
.block > div > input + label {
cursor: pointer;
display: block;
line-height: 50px;
background-color: white;
transition: background-color 0.5s;
color: #767676;
padding-right: 60px;
text-align: right;
}
.block > div > input ~ div {
visibility: hidden;
max-height: 0;
padding: 0;
opacity: 0;
transition: all 0.5s;
}
.block > div > input:checked + label {
background-color: #f3f3f3;
transition: background-color 0.5s;
color: black;
}
.block > div > input:checked ~ div {
display: block;
opacity: 1;
visibility: visible;
height: auto;
max-height: 10000px;
padding: 0;
transition: all 0.5s;
}
.block a {
display: block;
line-height: 50px;
text-decoration: none;
color: black;
border-top: solid 1px #e5e5e5;
padding-right: 50px;
text-align: right;
}
.block a:hover {
background: #eeeeee;
}
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/FontAwesome.otf') format('opentype');
}
<div class="block">
<div>
<input type="radio" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
<div>
<input type="radio" name="item" id="item-two" hidden />
<label for="item-two">second</label>
<div>
<p>Menu 2.1</p>
<p>Menu 2.2</p>
<p>Menu 2.3</p>
</div>
</div>
</div>

You can refactor your HTML a bit so that the hover state is possible to achieve with :checked on your inputs instead.
First, replace the pseudo element on .block>div with a span element that goes after the label. We need something that's after the input so we can select it with CSS, since there is no CSS parent selector. And we can't use pseudo elements on inputs, so we'll just add a span instead.
<div class="block">
<div>
<input type="checkbox" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<span></span>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
</div>
Note that I took the little box symbol out of your content property from the pseudo element and jut put it in the span.
After that, it's just a matter of changing your selectors. So this...
.block > div:nth-child(1):before { ... }
.block > div:nth-child(1):hover:before { ... }
Becomes this...
#item-one + label + span { ... }
.block>div:nth-child(1):hover #item-one + label + span,
#item-one:checked + label + span { ... }
That's it!
You do need to add an explicit height on the span that was not there for the pseudo element, as well as set the span to display: block. The rest of the styles are exactly the same.
Final note is that I changed your inputs from type="radio" to type="checkbox". That way, you can collapse them instead of one being forced to be open all the time once you click one.
Here's a snippet where the first input uses the new style and the second one is the same as your original:
* {
margin: 0;
padding: 0;
font-family: Arial;
font-size: 14px;
}
.block {
float: right;
max-width: 360px;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
margin: 0;
}
.block>div {
display: block;
position: relative;
background-color: #fff;
color: #767676;
border-bottom: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
}
#item-one + label + span {
display: block;
font-family: 'FontAwesome';
content: "\F0CA";
font-size: 16px;
width: 50px;
height: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #E94B3B;
background: none;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block>div:nth-child(1):hover #item-one + label + span,
#item-one:checked + label + span {
background-position: 100% 0;
color: white;
}
.block>div:nth-child(2):before {
font-family: 'FontAwesome';
content: "\F0F6";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #ffb61c;
background: none;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block>div:nth-child(2):hover:before {
background-position: 100% 0;
color: white;
}
.block>div>input+label {
cursor: pointer;
display: block;
line-height: 50px;
background-color: white;
transition: background-color 0.5s;
color: #767676;
padding-right: 60px;
text-align: right;
}
.block>div>input~div {
visibility: hidden;
max-height: 0;
padding: 0;
opacity: 0;
transition: all 0.5s;
}
.block>div>input:checked+label {
background-color: #f3f3f3;
transition: background-color 0.5s;
color: black;
}
.block>div>input:checked~div {
display: block;
opacity: 1;
visibility: visible;
height: auto;
max-height: 10000px;
padding: 0;
transition: all 0.5s;
}
.block a {
display: block;
line-height: 50px;
text-decoration: none;
color: black;
border-top: solid 1px #e5e5e5;
padding-right: 50px;
text-align: right;
}
.block a:hover {
background: #eeeeee;
}
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/FontAwesome.otf') format('opentype');
}
<div class="block">
<div>
<input type="checkbox" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<span></span>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
<div>
<input type="checkbox" name="item" id="item-two" hidden />
<label for="item-two">second</label>
<div>
<p>Menu 2.1</p>
<p>Menu 2.2</p>
<p>Menu 2.3</p>
</div>
</div>
</div>

$('.t-blog-list-sidebar').find('li').click(function(e){
$('.t-blog-list-sidebar').find('li').removeClass('active');
// console.log(this, e);
$(this).addClass('active');
e.stopPropagation();
})
$("li.no-a").click(function(e){
$(this).toggleClass('rev');
$(this).children("ul").collapse('toggle');
e.stopPropagation();
} );
#import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css";
#import "https://use.fontawesome.com/releases/v5.2.0/css/all.css";
.bg-grey{
background:#f5f5f5;
}.t-blog-list-sidebar ul:nth-child(2) li.no-a {
border: 1px solid #333;
}
section#t-page-title .t-sub-header {
margin-bottom: 30px;
}
#t-page-title .t-sub-header h2 {
font-weight: 400;
text-transform: uppercase;
}
.h-tab{
margin-top: 130px;
}
.h-tab .container span {
display: inline-block;
cursor: pointer;
padding: 28px 40px;
}
.h-tab .container a span h3 {
font-size: 27px;
text-transform: uppercase;
color: #fff;
}
.h-tab .container a span.active h3 {
font-weight: 500;
}
#t-page-title {
position: relative;
padding: 15px 0;
background-color: #F5F5F5;
border-bottom: 1px solid #EEE;
}
#t-page-title .breadcrumb {
position: absolute !important;
width: auto !important;
left: 15px !important;
margin: -5px 0 0 0 !important;
background-color: transparent !important;
padding: 0 !important;
font-size: 12px;
}
.h-tab .container span.active {
border-bottom: 7px solid #e87327;
box-shadow: 0px 0px 20px -2px #ffffff;
}
ul.t-ul-r {
float: right;
}
.t-recent-post {
width: 100%;
list-style-type: none;
}
.widget-sidebar li.t-recent-post .t-sub-header h3 i {
font-size: 32px;
padding-right: 5px;
}
.widget-sidebar li.t-recent-post .t-sub-header h3{
text-transform: uppercase;
}
.t-subbody ul.t-ul li:not(.no-a):hover {
cursor: pointer;
background: #e0e0e0;
}
.t-subbody ul.t-ul li {
line-height: 11px;
float: none;
padding-left: 21px;
padding: 4px;
color: #676666;
position: relative;
cursor: pointer;
}
.t-subbody .t-ul li:before {
content: "\f061";
font-family: 'Font Awesome 5 Free';
font-weight: 900;
font-style: normal;
padding-right: 2px;
font-size: 10px;
}
li> ul.t-ul {
padding-top: 13px;
transition: .5s;
}
#t-page-title {
margin-bottom: 16px;
}
.t-subbody .t-ul li.active:not(.no-a):after {
content: "\00a0";
width: 35px;
height: 35px;
background: #f5f5f5;
position: absolute;
transform: rotate(46deg);
right: -33px;
margin-top: -10px;
}
.t-subbody .t-ul li> ul li.active:not(.no-a):after {
right: -45px;
}
.t-subbody .t-ul li> ul li ul > li.active:not(.no-a):after {
right: -50px;
}
.t-subbody .t-ul li> ul li ul > li.active:not(.no-a):after {
right: -55px;
}
.t-subbody .t-ul li> ul li > ul li > ul li.active:not(.no-a):after {
right: -65px;
}
.t-subbody ul.t-ul li.no-a:after {
content: "\f107";
font-family: 'Font Awesome 5 Free';
font-weight: 900;
padding-right: 2px;
font-size: 18px;
position: absolute;
top:0;
font-style: normal;
right: 17px;
transition: .2s;
}
.t-subbody ul.t-ul li.no-a.rev:after {
transition: .2s;
transform: rotate(180deg);
}
.t-entry .entry-c {
background: #fff;
box-shadow: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
position: relative;
padding: 24px;
border-radius: 2px;
margin: 20px 0;
}
li.t-recent-post p small {
display: block;
margin-top: 10px;
padding-bottom: 11px;
border-bottom: 1px solid #b9b9b9;
}
.t-blog-list-sidebar ul{
list-style:none;
padding-left:0px;
}
/* blog css end */
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section class="section">
<div class="container ">
<div class="col-md-3 col-sm-3">
<div class="widget-sidebar">
<h2 class="title-widget-sidebar">TUTORIAL</h2>
<div class="t-blog-list-sidebar">
<ul>
<li class="t-recent-post">
<div class="t-sub-header">
<h3><i class="fab fa-java"></i> java</h3>
</div>
<div class="t-subbody">
<ul class="entry-meta clearfix t-ul">
<li class='active'> menu-1 </li>
<li> menu-2 </li>
<li class="no-a"> menu-3 start
<ul class="t-ul collapse">
<li>menu-3.1 </li>
<li class="no-a"> menu-3.2
<ul class="t-ul collapse">
<li class="no-a"> menu-3.2.1
<ul class="t-ul collapse">
<li> menu-3.2.1.1 </li>
<li> menu-3.2.1.2 </li>
</ul>
</li>
<li> menu-3.2.2 </li>
</ul>
</li>
<li> menu-3.3 </li>
</ul>
</li>
</ul>
</div>
<p><small><i class="fa fa-calendar" data-original-title="" title=""></i>15 November 2014</small> </p>
</li>
</ul>
<ul>
<li class="t-recent-post">
<div class="t-sub-header">
<h3><i class="fab fa-java"></i> java</h3>
</div>
<div class="t-subbody">
<ul class="entry-meta clearfix t-ul">
<li class='active'> menu-1 </li>
<li> menu-2 </li>
<li class="no-a"> menu-3 start
<ul class="t-ul collapse">
<li>menu-3.1 </li>
<li class="no-a"> menu-3.2
<ul class="t-ul collapse">
<li class="no-a"> menu-3.2.1
<ul class="t-ul collapse">
<li> menu-3.2.1.1 </li>
<li> menu-3.2.1.2 </li>
</ul>
</li>
<li> menu-3.2.2 </li>
</ul>
</li>
<li> menu-3.3 </li>
</ul>
</li>
</ul>
</div>
<p><small><i class="fa fa-calendar" data-original-title="" title=""></i>15 November 2014</small> </p>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-9 col-sm-9 small-thumbs bg-grey">
<section id="t-page-title">
<div class="t-sub-header">
<h2><i class="fab fa-java"></i> java</h2>
</div>
<div class="container clearfix">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<ol class="breadcrumb">
<li>Tutorial </li>
<li class="active">java</li>
</ol>
</div>
</div>
</div>
</section>
<div class="clearfix t-entry">
<!-- card start -->
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<!-- card start end-->
</div>
</div>
</div>
</section>

Related

trying to remove css grid right margin [duplicate]

This question already has answers here:
Does UL have default margin or padding [duplicate]
(2 answers)
Closed 1 year ago.
I have made a div and assigned display grid to it everything is fine but the problem is there is a margin I don't know if its a code that i wrote wrong or sthg else .. i tried to use margin : 0 auto; but didn't work it made it worse actually xD. i also checked if the container has margin or padding
Here is what am i talking about :
$('#owl-carousel').owlCarousel({
loop: true,
margin: 30,
dots: true,
nav: false,
rtl: true,
items: 2,
})
.text {
text-align: center;
height: 100px;
background: #0b0a0d;
color: #FFF;
}
.text .logo a{
margin: 0;
line-height: 100px;
font-size: 48px;
font-family: 'Zen Dots', cursive;}
.nav {
background: #0c70de;
color: #FFF;
display: flex;
z-index: 9999;
}
.text .logo a{
color: #FFF;
text-decoration: none
}
.nav ul {
margin: 0 auto;
padding: 0;
display: flex;
/* width: 50%; */
/* margin-left: auto; */
}
ul li{
padding: 20px;
list-style: none
}
ul li a{
color: #FFF;
display: block;
text-decoration: none;
text-transform: uppercase;
font-family: 'Changa', sans-serif;
}
.sticky{
position: fixed;
top: 0;
left: 0;
width: 100%
}
.contain {
margin: 0 auto;
max-width: 1200px;
width: 100%;
margin-top: 50px;
}
.item {
align-items: center;
display: flex;
height: 300px;
justify-content: center;
}
/* slider */
#import url('https://fonts.googleapis.com/css?family=Raleway:100,400');
body {
font-family: 'Raleway', sans-serif;
font-weight: thin;
background: black;
margin: 0;
padding: 0;
}
body:after{
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
margin: 0;
z-index: -1;
width: 200%;
height: 200%;
background-color: #16151d;
}
.movie-card {
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 800px;
height: 300px;
background-position: center;
background-size: cover;
margin: 4vh auto;
border-radius: 4px;
box-shadow: 2px 3px 12px rgba(0, 0, 0, .4);
color: white;
padding: 2vh 3%;
}
.movie-card:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 4px;
background: linear-gradient(to left, rgba(40,40,60,1) 0%,rgba(40,0,60,0) 90%);
background-blend-mode: multiply;
will-change: transform;
z-index: 0;
}
i {
font-size: .7em;
color: #ff5b84;
}
h1 {
font-size: 170%;
position: relative;
z-index: 10;
}
span {
display: inline-block;
position: relative;
z-index: 10;
margin-right: 80px;
color: rgb(210, 210, 210);
}
.watch {
display: block;
border: 1px solid white;
border-radius: 4px;
position: relative;
z-index: 10;
color: white;
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, .3);
margin: 20px 0px;
outline: none;
box-shadow: 0 0 10px rgba(0,0,0,.5);
transition: all .2s;
}
button:hover {
background: rgba(255, 255, 255, .8);
color: black;
box-shadow: 0 0 10px rgba(255,255,255,.5);
mix-blend-mode: screen;
}
button:active {
transform: translateY(2px);
}
p {
position: relative;
z-index: 10;
font-size: .8em;
width: 60%;
height: 35%;
}
#media (max-width: 768px) {
body {
/* background: none; */
}
.movie-card {
width: 75%;
height: 200px;
}
h1 {
font-size: 120%;
}
p {
display: none;
/* overflow: hidden;
width: 100%;
height: 30%; */
}
.watch {
margin: 5% auto;
}
}
#media (max-width: 500px) {
.movie-card {
width: 100%;
}
}
.hot {
background-color: #694ba1;
padding: 8px 15px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.hot h3 {
color: #FFF;
}
h3 {
font-size: 1.1em;
line-height: 20px;
font-weight: 500;
margin: 0;
position: relative;
}
.anime-list {
background-color: #222;
}
/*
AUTO GRID
Set the minimum item size with `--auto-grid-min-size` and you'll
get a fully responsive grid with no media queries.
*/
.auto-grid {
--auto-grid-min-size: 16rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--auto-grid-min-size), 1fr));
grid-gap: 1rem;
}
/* Presentational styles */
.anime-list ul li {
padding: 5rem 1rem;
text-align: center;
font-size: 1.2rem;
background-size: cover;
background-position: center;
}
.anime-list {
align-items: center;
}
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>owl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa:wght#500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css">
</head>
<body>
<!-- * Header START -->
<div class="text">
<div class="logo">
ON ANIME
</div>
</div>
<div class="nav">
<ul>
<li>الرئيسية</li>
<li>قائمة الانميات</li>
<li>افلام الانمي</li>
</ul>
</div>
<div class="contain">
<div id="owl-carousel" class="owl-carousel owl-theme">
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
</div>
</div>
<div class="contain">
<div class="postss">
<div class="hot">
<h3>انميات مميزة</h3>
</div>
<div class="anime-list">
<ul class="auto-grid">
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 1</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 2</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 3</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 4</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 5</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 6</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 7</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 8</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 9</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 10</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 11</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 12</li>
</ul>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
<script src="script.js" async defer></script>
</body>
</html>
You need to over wright the default of the grid ul
So I added ul {padding-inline-start: 0px;} and it seems to be fixed
$('#owl-carousel').owlCarousel({
loop: true,
margin: 30,
dots: true,
nav: false,
rtl: true,
items: 2,
})
ul {padding-inline-start: 0px;}
.text {
text-align: center;
height: 100px;
background: #0b0a0d;
color: #FFF;
}
.text .logo a{
margin: 0;
line-height: 100px;
font-size: 48px;
font-family: 'Zen Dots', cursive;}
.nav {
background: #0c70de;
color: #FFF;
display: flex;
z-index: 9999;
}
.text .logo a{
color: #FFF;
text-decoration: none
}
.nav ul {
margin: 0 auto;
padding: 0;
display: flex;
/* width: 50%; */
/* margin-left: auto; */
}
ul li{
padding: 20px;
list-style: none
}
ul li a{
color: #FFF;
display: block;
text-decoration: none;
text-transform: uppercase;
font-family: 'Changa', sans-serif;
}
.sticky{
position: fixed;
top: 0;
left: 0;
width: 100%
}
.contain {
margin: 0 auto;
max-width: 1200px;
width: 100%;
margin-top: 50px;
}
.item {
align-items: center;
display: flex;
height: 300px;
justify-content: center;
}
/* slider */
#import url('https://fonts.googleapis.com/css?family=Raleway:100,400');
body {
font-family: 'Raleway', sans-serif;
font-weight: thin;
background: black;
margin: 0;
padding: 0;
}
body:after{
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
margin: 0;
z-index: -1;
width: 200%;
height: 200%;
background-color: #16151d;
}
.movie-card {
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 800px;
height: 300px;
background-position: center;
background-size: cover;
margin: 4vh auto;
border-radius: 4px;
box-shadow: 2px 3px 12px rgba(0, 0, 0, .4);
color: white;
padding: 2vh 3%;
}
.movie-card:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 4px;
background: linear-gradient(to left, rgba(40,40,60,1) 0%,rgba(40,0,60,0) 90%);
background-blend-mode: multiply;
will-change: transform;
z-index: 0;
}
i {
font-size: .7em;
color: #ff5b84;
}
h1 {
font-size: 170%;
position: relative;
z-index: 10;
}
span {
display: inline-block;
position: relative;
z-index: 10;
margin-right: 80px;
color: rgb(210, 210, 210);
}
.watch {
display: block;
border: 1px solid white;
border-radius: 4px;
position: relative;
z-index: 10;
color: white;
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, .3);
margin: 20px 0px;
outline: none;
box-shadow: 0 0 10px rgba(0,0,0,.5);
transition: all .2s;
}
button:hover {
background: rgba(255, 255, 255, .8);
color: black;
box-shadow: 0 0 10px rgba(255,255,255,.5);
mix-blend-mode: screen;
}
button:active {
transform: translateY(2px);
}
p {
position: relative;
z-index: 10;
font-size: .8em;
width: 60%;
height: 35%;
}
#media (max-width: 768px) {
body {
/* background: none; */
}
.movie-card {
width: 75%;
height: 200px;
}
h1 {
font-size: 120%;
}
p {
display: none;
/* overflow: hidden;
width: 100%;
height: 30%; */
}
.watch {
margin: 5% auto;
}
}
#media (max-width: 500px) {
.movie-card {
width: 100%;
}
}
.hot {
background-color: #694ba1;
padding: 8px 15px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.hot h3 {
color: #FFF;
}
h3 {
font-size: 1.1em;
line-height: 20px;
font-weight: 500;
margin: 0;
position: relative;
}
.anime-list {
background-color: #222;
}
/*
AUTO GRID
Set the minimum item size with `--auto-grid-min-size` and you'll
get a fully responsive grid with no media queries.
*/
.auto-grid {
--auto-grid-min-size: 16rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--auto-grid-min-size), 1fr));
grid-gap: 1rem;
}
/* Presentational styles */
.anime-list ul li {
padding: 5rem 1rem;
text-align: center;
font-size: 1.2rem;
background-size: cover;
background-position: center;
}
.anime-list {
align-items: center;
}
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>owl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa:wght#500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css">
</head>
<body>
<!-- * Header START -->
<div class="text">
<div class="logo">
ON ANIME
</div>
</div>
<div class="nav">
<ul>
<li>الرئيسية</li>
<li>قائمة الانميات</li>
<li>افلام الانمي</li>
</ul>
</div>
<div class="contain">
<div id="owl-carousel" class="owl-carousel owl-theme">
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
</div>
</div>
<div class="contain">
<div class="postss">
<div class="hot">
<h3>انميات مميزة</h3>
</div>
<div class="anime-list">
<ul class="auto-grid">
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 1</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 2</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 3</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 4</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 5</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 6</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 7</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 8</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 9</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 10</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 11</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 12</li>
</ul>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
<script src="script.js" async defer></script>
</body>
</html>

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 do I fix the push sidebar menu CSS?

I have a problem with a push sidebar menu. When the toggle button is clicked the page goes to the right .The problem is that I want the side bar menu to be next to the page just like the example that is in the picture . Also when i scroll down to the page ,I want the side bar menu to be fixed. I am only using css.
#media (max-width: 575px) {
.navbar-brand {
margin-bottom: 0;
}
.slideout-sidebar {
position: fixed;
top: 0px;
left: -80%;
height: 100%;
background-color: #fff;
transition: all .15s ease-in-out;
-webkit-box-shadow: inset -15px 0px 10px -15px rgba(0, 0, 0, 0.75);
box-shadow: inset -15px 0px 10px -15px rgba(0, 0, 0, 0.75);
}
.slideout-sidebar ul li {
display: block !important;
cursor: pointer;
padding: 10px 10px;
letter-spacing: 1px;
font-weight: 700;
font-size: 15px;
color: #0d6490;
margin: 0;
}
.slideout-sidebar button {
font-size: 1rem !important;
width: 220px;
height: 37px;
}
.navbar-brand {
width: 12rem;
height: 3.2rem;
margin-left: 50px;
}
.container-content {
position: relative;
left: 0px;
}
#menu-toggle {
display: none;
}
.menu-icon {
position: fixed;
top: 5px;
left: 5px;
font-size: 35px;
z-index: 1;
transition: all.15s ease-in-out;
padding: 5px 15px;
background-color: transparent;
}
#menu-toggle:checked ~ .slideout-sidebar {
left: 0;
}
#menu-toggle:checked + .menu-icon {
left: 250px;
}
#menu-toggle:checked ~ .container-content {
-webkit-transform: translateX(80%);
transform: translateX(80%);
transition: all .15s ease-in-out;
}
<input type="checkbox" id="menu-toggle" class="menu-icon" />
<label for="menu-toggle" class="menu-icon"><i class="fa fa-bars mt-2"></i></label>
<div class="container-content">
<header>
<div class="header-container d-flex justify-content-around container-fluid">
<div class="slideout-sidebar order-1">
<ul class="d-md-flex flex-md-column flex-lg-row mt-md-4">
<li class="brd mr-md-2 align-self-center menu">МЕНИ</li>
<li class=" order-lg-last btn-order"> <button class="btn" type="submit">НАРАЧАЈТЕ
ВЕДНАШ</button></li>
<li class="brd border-bottom border-top border-primary d-none ">КОНТАКТИРАЈТЕ НЕ</li>
<li class="brd d-none">УСЛОВИ ЗА КОРИСТЕЊЕ</li>
<li class=" border-bottom border-primary d-none brd">РЕСТОРАНИ</li>
<li class="order-lg-first mr-md-4 text-center brd align-self-center">
<a class="">МК</a>
<div class="d-inline-block
language-line"> | </div>
<a class="">EN</a>
</li>
</ul>
</div>
<div class="mx-auto mx-lg-0 mt-2">
<img src="./images/logo.png" alt="dominoslogo" class="navbar-brand" />
</div>
<div class="cart mt-2">
<img src="images/basket.png" alt="basket" class="d-lg-none">
<span class="header-cart-order d-lg-none">0</span>
</div>
</div>
</header>

How to make child element inherit parent's width in Bootstrap 4

How to make child element inherit parent's width using Bootstrap 4.
I need to fix download_resume block's width.
I'm using two primary js script's.
1.First function change img like hover effect
2.Second function adding sticky class to our empty_row block make it position fixed
Please look this code in wide screen devices or in codepen for understand the problem and what I want to realize
// this function change img like hover effect using js
let avatarSimple = document.querySelector(".avatar_simple");
let avatarQuantumBreak = document.querySelector(".avatar_quantum_break");
avatarQuantumBreak.style.opacity = "0";
let hover = () => {
avatarQuantumBreak.style.opacity = "1";
}
let normal = () => {
avatarQuantumBreak.style.opacity = "0";
}
// this function adding sticky class to our empty_row block make it position fixed
window.onscroll = function() {
let w = document.documentElement.clientWidth;
if (w > 940) {
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
scrolled >= 20 ? document.querySelector(".empty_row").classList.add("sticky") : document.querySelector(".empty_row").classList.remove("sticky");
}
}
.other_block {
background-color:lightblue;
}
.main_wrap {
margin-top:15px;
background-color:pink;
height:600px;
}
.home_link , .main_text {
color: #fff;
font-size: 1.5em;
}
.left_block {
/*height: 60%;*/
padding: 30px 20px 20px;
box-shadow: -4px 7px 15px 1px rgba(0,0,0,.2);
}
.avatar {
position: relative;
border-radius: 50%;
display: flex;
justify-content: center;
height: 195px;
}
.avatar_simple,
.avatar_quantum_break {
position: absolute;
display: block;
text-align:center;
transition: opacity 1s ease-out;
}
.avatar .avatar_simple img,
.avatar .avatar_quantum_break img {
border-radius: 50%;
display: inline-block;
}
.info {
margin-top: 33px;
}
.text_uppercase {
text-transform: uppercase;
color: #fff;
font-size: 1.4em;
text-align: center;
margin-bottom: 15px;
}
.text_muted {
text-align: center;
opacity: 0.65;
}
.social_links {
display: flex;
justify-content: center;
}
.social_links li {
list-style-type: none;
margin: 5px 12px;
vertical-align: middle;
}
.social_links li a {
color: #fff;
cursor: pointer;
transition: all .2s ease-out;
background-color: transparent;
}
.social_links li a i {
font-size: 1.25em;
transition: all .2s ease-out;
}
.social_links li a i:hover {
opacity: 0.65;
}
.download_resume {
position:absolute;
width: 100%;
left: 0%;
padding: 30px;
margin: 0;
font-size: .875em;
background-color: #313C42;
box-shadow: -4px 7px 15px 1px rgba(0,0,0,.2);
}
.text_widget {
vertical-align: middle;
}
.text_widget a {
background-color: #DEC746 !important;
border-color: #DEC746 !important;
color: #000 !important;
font-size: 15px !important;
padding: 12px 30px !important;
border-radius: 35px !important;
}
center {
display: block;
text-align: -webkit-center;
}
.btn_link:hover, .share-btn:hover {
box-shadow: -1px 2px 4px rgba(0,0,0,.25);
}
.btn_link {
font-weight: 700 !important;
}
.sticky {
position: fixed !important;
top: 2%;
width: 285px;
}
<div class="container">
<div class="row justify-content-between">
<div class="col-lg-3 col-xl-3 any_block"><div class="empty_row left_block" style="background-color: #1FA184;">
<div class="avatar" onmouseover="hover();" onmouseout="normal();">
<span class="avatar_simple">
<img src="https://certy.px-lab.com/developer/wp-content/uploads/sites/6/2017/08/certy-programmer-1-195x195.png">
</span>
<span class="avatar_quantum_break">
<img src="https://certy.px-lab.com/developer/wp-content/uploads/sites/6/2017/08/certy-programmer-2-195x195.png">
</span>
</div>
<div class="info">
<h2 class="text_uppercase">Sergio Ramos</h2>
<p class="text_muted">Front End Developer</p>
<ul class="social_links">
<li>
<a href="#">
<i class="fa fa-facebook"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-linkedin"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-github"></i>
</a>
</li>
</ul>
</div>
<div class="download_resume">
<div class="text_widget">
<center>
Download CV
</center>
</div>
</div>
</div></div>
<div class="col-lg-8 col-xl-8 other_block">
<div class="main_wrap">text</div>
</div>
</div>
</div>
Setting the width to inherit isn't the best solution. When you don't have "sticky" on it does things you don't expect.
I've added an extra div to wrap your top section in question. You're really only concerned about the padding staying for that top section with your picture when you move from sticky to non-sticky. This separates it from the resume download button. Then you don't need to specify any width on that div, as it will work like it is supposed to.
HTML (I've added the "left-block-padding" div)
<div class="container">
<div class="row justify-content-between">
<div class="col-lg-3 col-xl-3 any_block"><div class="empty_row left_block" style="background-color: #1FA184;">
<div class="left-block-padding">
<div class="avatar" onmouseover="hover();" onmouseout="normal();">
<span class="avatar_simple">
<img src="https://certy.px-lab.com/developer/wp-content/uploads/sites/6/2017/08/certy-programmer-1-195x195.png">
</span>
<span class="avatar_quantum_break">
<img src="https://certy.px-lab.com/developer/wp-content/uploads/sites/6/2017/08/certy-programmer-2-195x195.png">
</span>
</div>
<div class="info">
<h2 class="text_uppercase">Sergio Ramos</h2>
<p class="text_muted">Front End Developer</p>
<ul class="social_links">
<li>
<a href="#">
<i class="fa fa-facebook"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-linkedin"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-github"></i>
</a>
</li>
</ul>
</div>
</div>
<div class="download_resume">
<div class="text_widget">
<center>
Download CV
</center>
</div>
</div>
</div></div>
<div class="col-lg-8 col-xl-8 other_block">
<div class="main_wrap">text</div>
</div>
</div>
</div>
CSS (added .left-block-padding and removed position:absolute; and width: 100%; from .download_resume
.other_block {
background-color:lightblue;
}
.main_wrap {
margin-top:15px;
background-color:pink;
height:600px;
}
.home_link , .main_text {
color: #fff;
font-size: 1.5em;
}
.left_block {
/*height: 60%;*/
box-shadow: -4px 7px 15px 1px rgba(0,0,0,.2);
}
.avatar {
position: relative;
border-radius: 50%;
display: flex;
justify-content: center;
height: 195px;
}
.avatar_simple,
.avatar_quantum_break {
position: absolute;
display: block;
text-align:center;
transition: opacity 1s ease-out;
}
.avatar .avatar_simple img,
.avatar .avatar_quantum_break img {
border-radius: 50%;
display: inline-block;
}
.info {
margin-top: 33px;
}
.text_uppercase {
text-transform: uppercase;
color: #fff;
font-size: 1.4em;
text-align: center;
margin-bottom: 15px;
}
.text_muted {
text-align: center;
opacity: 0.65;
}
.social_links {
display: flex;
justify-content: center;
}
.social_links li {
list-style-type: none;
margin: 5px 12px;
vertical-align: middle;
}
.social_links li a {
color: #fff;
cursor: pointer;
transition: all .2s ease-out;
background-color: transparent;
}
.social_links li a i {
font-size: 1.25em;
transition: all .2s ease-out;
}
.social_links li a i:hover {
opacity: 0.65;
}
.download_resume {
left: 0%;
padding: 30px;
margin: 0;
font-size: .875em;
background-color: #313C42;
box-shadow: -4px 7px 15px 1px rgba(0,0,0,.2);
}
.text_widget {
vertical-align: middle;
}
.text_widget a {
background-color: #DEC746 !important;
border-color: #DEC746 !important;
color: #000 !important;
font-size: 15px !important;
padding: 12px 30px !important;
border-radius: 35px !important;
}
center {
display: block;
text-align: -webkit-center;
}
.btn_link:hover, .share-btn:hover {
box-shadow: -1px 2px 4px rgba(0,0,0,.25);
}
.btn_link {
font-weight: 700 !important;
}
.sticky {
position: fixed !important;
top: 2%;
width: 285px;
}
.left-block-padding {
padding: 30px 20px 20px;
}
JS (unchanged)
// this function change img like hover effect using js
let avatarSimple = document.querySelector(".avatar_simple");
let avatarQuantumBreak = document.querySelector(".avatar_quantum_break");
avatarQuantumBreak.style.opacity = "0";
let hover = () => {
avatarQuantumBreak.style.opacity = "1";
}
let normal = () => {
avatarQuantumBreak.style.opacity = "0";
}
// this function adding sticky class to our empty_row block make it position fixed
window.onscroll = function() {
let w = document.documentElement.clientWidth;
if (w > 940) {
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
scrolled >= 20 ? document.querySelector(".empty_row").classList.add("sticky") : document.querySelector(".empty_row").classList.remove("sticky");
}
}
https://codepen.io/adprocas/pen/QmLjJM
Use width:inherit to inherit parent element's width
.download_resume {
position:absolute;
width: inherit;
left: 0%;
padding: 30px;
margin: 0;
font-size: .875em;
background-color: #313C42;
box-shadow: -4px 7px 15px 1px rgba(0,0,0,.2);
}
Code sample - https://codepen.io/nagasai/pen/xWKGvW

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