i'm trying to make the drop down content to get over all the content in the home page but i can't do that, i've tried to change the z-index to higher but didn't work(i believe i'm changing the wrong ones?) also tried to change position of the nav and drop down content to absolute but also didn't work , any help?
this is my HTML and CSS files :
li {
float: left;
border-right: 1px solid #bbb;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 9999;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
position: absolute;
display: block;
text-align: left;
z-index: 9999;
}
body {
background: url(https://static.wixstatic.com/media/516d2c_c88a595abc2846c5bf03bfa9bfa5182a.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.dropdown-content a:hover {
background-color: #f1f1f1
}
#Menu-bar ul {
position: fixed;
TOP: 0px;
Left: 0px;
list-style-type: none;
margin: 0px;
overflow: hidden;
background-color: black;
opacity: 0.7;
filter: alpha (opacity=70);
z-index: 2;
}
#fix {
position: relative;
z-index: 9999;
}
nav {
background: #000000;
height: 80px;
width: auto;
margin-left: -10px;
line-height: 0px;
position: fixed;
}
.fixed {
position: fixed;
}
.nav>li>a {
text-decoration: none;
color: #ffffff;
}
.nav>li>a>img {
width: 300px;
height: 300px;
float: left;
padding: 0px;
}
.nav>li>a:hover {
color: #5F0500;
}
#wdt {
resize: none;
height: 80px;
width: 529px;
}
.middlecone {
float: right;
margin-left: 0px;
width: 100%;
height: 72%;
}
.nwsf {
text-align: right;
position: absolute;
height: 100%;
width: 50%;
float: right;
}
.box {
color: white;
border: 2px solid black;
float: left;
background-color: black;
opacity: 0.7;
filter: alpha (opacity=70);
}
#middlec {
position: absolute;
TOP: 130px;
LEFT: 380px;
height: 400px;
width: 590px;
border: 3px white solid;
overflow-x: scroll;
overflow-y: scroll;
background-color: #ffb84d;
text-align: left;
margin-top: 0px;
border-radius: 10px;
}
.jti {
height: 15%;
width: 99%;
border-radius: 3px;
margin-bottom: 1%;
text-align: left;
}
.jtiiii {
position: absolute;
TOP: 80px;
LEFT: 10px;
height: 400px;
width: 365px;
background-color: Orange;
float: right;
overflow: scroll;
}
#myMes {
display: none;
border: 1px solid;
float: right;
position: absolute;
margin-left: 78%;
background-color: #F5F5DC;
z-index: 9999;
}
#myNo {
display: none;
border: 1px solid;
float: right;
position: absolute;
margin-left: 105%;
background-color: #F5F5DC;
}
#jtiy {
text-align: center;
}
a.perss {
font-weight: inherit;
color: blue;
font-size: 13px;
text-decoration: underline;
}
<div id="fix">
<div id="Menu-bar">
<ul class="nav">
<li>
<a href="" id="homes"><img src="img/computer.png" style="position:absolute;
TOP:0px;LEFT:0px;height: 40px;width : 40px;">
</a>
</li>
<li>Profile</li>
<li>My Connections</li>
<li>All Users</li>
<li>All Jobs</li>
<li>Messages</li>
<li>Notifications</li>
<li style="float: right">
Logout</li>
</ul>
</div>
</div>
<br>
<div class="middlecone">
<div class="nwsf">
<div id="coun"></div>
<div class="jti">
<div id="myConn">
<ul id="myConn2">
</ul>
</div>
<div id="myMes">
<ul id="myMes2">
<li>1 </li>
<li>2 </li>
<li>3 </li>
<li>4 </li>
</ul>
</div>
</div>
<form name="newsfeedForm" metho="POST" style="position:absolute;
TOP:50px;LEFT:405px;height: 30px;width : 70px;">
<textarea id="wdt" type="text" name="po" placeholder="What do you think?"></textarea>
<input type="hidden" name="post_type" value="add_post">
<button type="submit" style="position:absolute;
TOP:10px;LEFT:550px;height: 50px;width : 90px;background-color: rgb(255, 165, 0);color: white;border: none;">share</button>
</form>
Related
I want to position the text on top of the image, but with 40px margin. I also want to position the two buttons on each side of the li (one on the right side and one on the left side). I've tried with the code below, and various other solution, but with no luck. The closest I've come is what the picture below shows, but the buttons are not in position. I want to have the same layout for every li, so I want this to apply to every li on the page.
CSS:
.container {
width: 100%;
}
.posts {
position: absolute;
top: 200px;
bottom: 0;
right: 30px;
margin: 0;
}
.post {
background-color: #606060;
border-radius: 30px;
width: 600px;
min-height: 300px;
float: right;
margin-bottom: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
bottom: auto;
top: auto;
}
.img {
background-color: #606060;
background-repeat: no-repeat;
background-size: contain;
width: 90%;
height: 300px;
position: relative;
margin-bottom: 100px;
border-radius: 50px;
}
.content {
font-size: 15px;
text-align: left;
min-height: 120px;
position: relative;
left: 10px;
color: white;
font-weight: 700;
margin-top: 40px;
}
.comment {
background-color: #006FC4;
border: 1px solid #00508D;
font-size: 15px;
color: #FFFFFF;
padding: 5px;
border-radius: 7px;
height: 30px;
position: absolute;
bottom: 0;
float: left;
}
.like {
background-color: #006FC4;
border: 1px solid #00508D;
font-size: 15px;
color: #FFFFFF;
padding: 5px;
border-radius: 7px;
height: 30px;
position: absolute;
float: right;
}
HTML:
<div class="container">
<ul class="posts">
<li class="post">
<div class="content">Test</div>
<button class="comment" onclick="comment('posts/XiqNjxsov3hUXX1zJLk3ta7mQul2/userPosts/PkIm2NOhjOlTZk7J7Dyk')">Comment</button>
<button class="like" onclick="like('posts/XiqNjxsov3hUXX1zJLk3ta7mQul2/userPosts/PkIm2NOhjOlTZk7J7Dyk')">Like</button><img class="img" src="https://firebasestorage.googleapis.com/v0/b/mysharify-4ea69.appspot.com/o/posts%2F6.png?alt=media&token=f1881e5e-e9f4-4e90-bf0f-f211a74ccd42" onclick="openImage('https://firebasestorage.googleapis.com/v0/b/mysharify-4ea69.appspot.com/o/posts%2F6.png?alt=media&token=f1881e5e-e9f4-4e90-bf0f-f211a74ccd42')"></li><br><br>
<li class="post">
<div class="content">dasdasd</div>
<button class="comment" onclick="comment('posts/hg23gh1beGO7cpUvRSkKpqcY9O22/userPosts/TpiuWCRoZQliuhmlj1su')">Comment</button>
<button class="like" onclick="like('posts/hg23gh1beGO7cpUvRSkKpqcY9O22/userPosts/TpiuWCRoZQliuhmlj1su')">Like</button></li><br><br>
</ul>
</div>
I'm not entirely sure what you're going for based on your post (would be helpful to have a link to something similar to what you're trying to get), but here's my best guess.
HTML (I removed the second LI, since they'll all look the same anyways and that one didn't have an image)
<div class="container">
<ul class="posts">
<li class="post">
<div class="content">Test</div>
<button
class="comment"
onclick="comment('posts/XiqNjxsov3hUXX1zJLk3ta7mQul2/userPosts/PkIm2NOhjOlTZk7J7Dyk')"
>
Comment
</button>
<button
class="like"
onclick="like('posts/XiqNjxsov3hUXX1zJLk3ta7mQul2/userPosts/PkIm2NOhjOlTZk7J7Dyk')"
>
Like
</button>
<img
alt="foo"
class="img"
src="https://firebasestorage.googleapis.com/v0/b/mysharify-4ea69.appspot.com/o/posts%2F6.png?alt=media&token=f1881e5e-e9f4-4e90-bf0f-f211a74ccd42"
onclick="openImage('https://firebasestorage.googleapis.com/v0/b/mysharify-4ea69.appspot.com/o/posts%2F6.png?alt=media&token=f1881e5e-e9f4-4e90-bf0f-f211a74ccd42')"
/>
</li>
</ul>
</div>
CSS
.container {
width: 100%;
}
.posts {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
list-style: none;
}
.post {
background-color: #606060;
border-radius: 30px;
width: 100%;
float: right;
position: relative;
margin: 1rem 0;
}
.img {
position: relative;
background-color: #606060;
background-repeat: no-repeat;
background-size: contain;
width: 100%;
border-radius: 50px;
}
.content {
font-size: 15px;
position: absolute;
z-index: 10;
color: white;
font-weight: 700;
margin: 40px;
}
.comment {
background-color: #006fc4;
border: 1px solid #00508d;
font-size: 15px;
color: #ffffff;
padding: 5px;
border-radius: 7px;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
}
.like {
background-color: #006fc4;
border: 1px solid #00508d;
font-size: 15px;
color: #ffffff;
padding: 5px;
border-radius: 7px;
position: absolute;
bottom: 0;
right: 0;
z-index: 10;
}
My dropdown menu is stuck behind my main div or trapped within the header. I have messed with the z-index and that has not helped. How would I be able to tell if it was the header trapping it rather than the main div hiding it.
Here is a pic of the issue:
body {
margin: 0;
font-family: arial;
}
button {
border-style: solid;
border-color: black;
border-radius: 5px;
}
a {
text-decoration: none;
color: blue;
}
#header {
overflow: hidden;
background-color: #FFF;
position: fixed;
top: 0;
width: 100%;
height: 50px;
border-bottom: solid;
border-bottom-color: black;
}
.headerSection {
float: left;
width: 33%;
height: 100%;
display: table;
text-align: center;
}
.headerSection>.headerItem {
display: table-cell;
vertical-align: middle;
}
#asdf {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
border-radius: 0;
background: #1466C0;
color: #FFAD01;
border-bottom: 0;
}
#asdf:hover {
background-color: #00B2EE;
}
.TOC {
margin-top: 25px;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 999;
}
.dropdown:hover .TOC {
display: block;
}
.TOC a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
#main {
margin-top: 55px;
z-index: 1;
}
<div id="header">
<div class="headerSection">
<div class="dropdown">
<button class="headerItem" id="asdf">☰</button>
<div class='TOC'>
<a href='#OS'>OS Information</a>
<a href='#GI'>General Information</a>
<a href='#DI'>Domain Information</a>
<a href='#SUC'>Start-Up Command</a>
<a href='#shares'>Shares</a>
<a href='#EV'>Environment Vars</a>
<a href='#proc'>Processes</a>
</div>
</div>
</div>
<div class="headerSection">
<h1 class="headerItem">Windows Audit Script Report</h1>
</div>
<div class="headerSection">
<p class="headerItem" id="aede">Run Time: 2018-06-28 10:11:24.145067</p>
</div>
</div>
<div id="main">
<div style='clear:both'></div>
Does anyone have any ideas on how to fix this issue?
It happens because your header has overflow:hidden you should remove overflow hidden
please check the changes :
body
{
margin: 0;
font-family: arial;
}
button
{
border-style: solid;
border-color: black;
border-radius: 5px;
}
a
{
text-decoration: none;
color: blue;
}
#header
{
background-color: #FFF;
position: fixed;
top: 0;
width: 100%;
height: 50px;
border-bottom: solid;
border-bottom-color: black;
}
.headerSection
{
float: left;
width: 33%;
height: 100%;
display: table;
text-align: center;
}
.hidden-height-header{width:66%; float:left; height:50px; overflow:hidden}
.hidden-height-header >.headerSection {width:50%}
.headerSection > .headerItem
{
display: table-cell;
vertical-align: middle;
}
#asdf
{
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
border-radius: 0;
background: #1466C0;
color: #FFAD01;
border-bottom: 0;
}
#asdf:hover
{
background-color: #00B2EE;
}
.TOC {
margin-top: 25px;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 999;
}
.dropdown:hover .TOC {
display: block;
}
.TOC a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
#main
{
margin-top: 55px;
z-index: 1;
}
<body>
<div id="header">
<div class="headerSection">
<div class="dropdown">
<button class="headerItem" id="asdf">☰</button>
<div class='TOC'>
<a href='#OS'>OS Information</a>
<a href='#GI'>General Information</a>
<a href='#DI'>Domain Information</a>
<a href='#SUC'>Start-Up Command</a>
<a href='#shares'>Shares</a>
<a href='#EV'>Environment Vars</a>
<a href='#proc'>Processes</a>
</div>
</div>
</div>
<div class="hidden-height-header">
<div class="headerSection">
<h1 class="headerItem">Windows Audit Script Report</h1>
</div>
<div class="headerSection">
<p class="headerItem" id="aede">Run Time: 2018-06-28 10:11:24.145067</p>
</div>
</div>
</div>
<div id="main">
<div style = 'clear:both'></div>
</div></body>
The issue is the overflow: hidden that you have set on the #header. If you remove that the dropdown should work fine.
jsfiddle: https://jsfiddle.net/1du6f928/1/
I looked through similar issues other users have had, but none of the fixes have worked for me. I started on the site about a year ago and haven't touched it since. As the title suggests, there's a bit of white space on the right side of the site that I can't seem to get rid of.
html * {
font-family: 'Open Sans', sans-serif;
margin: 0;
}
body{
}
.header1 {
background: #000;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
-khtml-opacity: 0.8;
opacity: 0.8;
background-size: cover;
height: 100px;
width: 100%;
padding: 0;
position: fixed;
z-index: 1000;
margin-right: -12px;
margin-left: -12px;
margin-top: -6px;
}
.header1 img {
float: left;
width: 258px;
height: 56px;
margin-left: 30px;
margin-top: 44px;
padding: 0;
}
ul#nav {
list-style-type: none;
height: 20px;
margin-top: 73px;
-webkit-padding-start: 40px;
display: block;
}
a:link,
a:visited {
text-decoration: none;
color: #FFFFFF !important;
}
ul#nav li.contact a {
float: right;
width: 100px;
}
ul#nav li.about a {
float: right;
width: 75px;
}
ul#nav li.search a {
float: right;
width: 100px;
}
.header2 {
background: url(rockhdr.png) no-repeat top center fixed;
background-size: cover;
height: 600px;
width: 100%;
margin-right: -18px;
margin-left: -8px;
margin-top: -12px;
padding: 0;
}
.box {
background: no-repeat top center fixed;
margin: auto;
padding-left: -15px;
padding-top: 275px;
width: 400px;
height: 100px;
white-space: nowrap;
position: relative;
}
.container-1 {
width: 600px;
height: 200px;
vertical-align: middle;
white-space: nowrap;
position: relative;
background: #000;
margin-left: -85px;
border-radius: 5px;
}
.container-1 input#search {
width: 300px;
height: 50px;
background: #2b303b;
border: none;
font-size: 10pt;
float: left;
color: #FFFFFF;
margin-left: 150px;
margin-top: 60px;
padding-left: 20px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.container-1 .icon {
position: absolute;
top: 50%;
margin-left: 17px;
margin-top: 17px;
z-index: 1;
color: #FFFFFF;
}
.button {
position: absolute;
font-size: 12px;
left: 150px;
top: 60%;
width: 148px;
height: 20px;
background: #ffff;
border: none;
border-radius: 5px;
}
.advbutton {
position: absolute;
font-size: 12px;
left: 302px;
top: 60%;
width: 148px;
height: 20px;
background: #ffff;
border: none;
border-radius: 5px;
}
.container-1 input#search::-webkit-input-placeholder {
color: #65737e;
}
.container-1 input#search:-moz-placeholder {
/* Firefox 18- */
color: #65737e;
}
.container-1 input#search::-moz-placeholder {
/* Firefox 19+ */
color: #65737e;
}
.container-1 input#search:-ms-input-placeholder {
color: #65737e;
}
h1 {
text-align: center;
font-size: 50px;
}
#bottom-wrap {
background: #000;
}
#bottom {
width: 100%;
height: 0;
padding: 0 0 20%;
background-size: 100%;
background-repeat: no-repeat;
background-size: cover;
margin-left: auto;
margin-right: auto;
}
.contact {
color: #FFFFFF;
text-align: center;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="fossils.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="fossils.js"></script>
<div class='header_top'>
<div class='header1'>
<img src="GFS/images/eslogo.png" alt="logo" />
<ul id="nav">
<li class="contact"><a name="contact" href="#bottom" title="Contact">Contact</a></li>
<li class="about">About</li>
<li class="search">Search</li>
</div>
</div>
<div class='header_box'>
<div class='header2'>
<div class="box">
<div class="container-1">
<span class="icon"><i class="fa fa-search"></i></span>
<input type="search" id="search" placeholder="Search..." />
<form action="advancedsearch.html">
<input type="submit" class="advbutton" type="button" value="Advanced Search">
</form>
<input class="button" type="button" value="Search">
</div>
</div>
</div>
</div>
<iframe src="https://truview.ortery.com/HTMLJavaScript/MotorBike/HTML5Viewer.html"></iframe>
<h1>Catalogued Rocks</h1>
<div id="bottom-wrap">
<div id="bottom">
<br>
<br>
<br>
</div>
</div>
Help would be much appreciated!
Simply remove this from header1:
margin-right: -12px;
margin-left: -12px;
margin-top: -6px;
The white margin you are referring to is just on your header container and nowhere else and the negative margin above was the cause of it.
html * {
font-family: 'Open Sans', sans-serif;
margin: 0;
}
body{
}
.header1 {
background: #000;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
-khtml-opacity: 0.8;
opacity: 0.8;
background-size: cover;
height: 100px;
width: 100%;
padding: 0;
position: fixed;
z-index: 1000;
}
.header1 img {
float: left;
width: 258px;
height: 56px;
margin-left: 30px;
margin-top: 44px;
padding: 0;
}
ul#nav {
list-style-type: none;
height: 20px;
margin-top: 73px;
-webkit-padding-start: 40px;
display: block;
}
a:link,
a:visited {
text-decoration: none;
color: #FFFFFF !important;
}
ul#nav li.contact a {
float: right;
width: 100px;
}
ul#nav li.about a {
float: right;
width: 75px;
}
ul#nav li.search a {
float: right;
width: 100px;
}
.header2 {
background: url(rockhdr.png) no-repeat top center fixed;
background-size: cover;
height: 600px;
width: 100%;
margin-right: -18px;
margin-left: -8px;
margin-top: -12px;
padding: 0;
}
.box {
background: no-repeat top center fixed;
margin: auto;
padding-left: -15px;
padding-top: 275px;
width: 400px;
height: 100px;
white-space: nowrap;
position: relative;
}
.container-1 {
width: 600px;
height: 200px;
vertical-align: middle;
white-space: nowrap;
position: relative;
background: #000;
margin-left: -85px;
border-radius: 5px;
}
.container-1 input#search {
width: 300px;
height: 50px;
background: #2b303b;
border: none;
font-size: 10pt;
float: left;
color: #FFFFFF;
margin-left: 150px;
margin-top: 60px;
padding-left: 20px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.container-1 .icon {
position: absolute;
top: 50%;
margin-left: 17px;
margin-top: 17px;
z-index: 1;
color: #FFFFFF;
}
.button {
position: absolute;
font-size: 12px;
left: 150px;
top: 60%;
width: 148px;
height: 20px;
background: #ffff;
border: none;
border-radius: 5px;
}
.advbutton {
position: absolute;
font-size: 12px;
left: 302px;
top: 60%;
width: 148px;
height: 20px;
background: #ffff;
border: none;
border-radius: 5px;
}
.container-1 input#search::-webkit-input-placeholder {
color: #65737e;
}
.container-1 input#search:-moz-placeholder {
/* Firefox 18- */
color: #65737e;
}
.container-1 input#search::-moz-placeholder {
/* Firefox 19+ */
color: #65737e;
}
.container-1 input#search:-ms-input-placeholder {
color: #65737e;
}
h1 {
text-align: center;
font-size: 50px;
}
#bottom-wrap {
background: #000;
}
#bottom {
width: 100%;
height: 0;
padding: 0 0 20%;
background-size: 100%;
background-repeat: no-repeat;
background-size: cover;
margin-left: auto;
margin-right: auto;
}
.contact {
color: #FFFFFF;
text-align: center;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="fossils.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="fossils.js"></script>
<div class='header_top'>
<div class='header1'>
<img src="GFS/images/eslogo.png" alt="logo" />
<ul id="nav">
<li class="contact"><a name="contact" href="#bottom" title="Contact">Contact</a></li>
<li class="about">About</li>
<li class="search">Search</li>
</div>
</div>
<div class='header_box'>
<div class='header2'>
<div class="box">
<div class="container-1">
<span class="icon"><i class="fa fa-search"></i></span>
<input type="search" id="search" placeholder="Search..." />
<form action="advancedsearch.html">
<input type="submit" class="advbutton" type="button" value="Advanced Search">
</form>
<input class="button" type="button" value="Search">
</div>
</div>
</div>
</div>
<iframe src="https://truview.ortery.com/HTMLJavaScript/MotorBike/HTML5Viewer.html"></iframe>
<h1>Catalogued Rocks</h1>
<div id="bottom-wrap">
<div id="bottom">
<br>
<br>
<br>
</div>
</div>
Here's the link for the fiddle: https://jsfiddle.net/LpLp75zm/
The problem is that although I've assigned a position:fixed attribute to the topbar (the red colored part) it won't accompany the side navigation menu when I scroll down.
<!DOCTYPE html>
<html>
<head>
<style>
* { margin:0;padding:0;}
div.container {
position: relative;
}
div.topbar {
background-color: #f44336;
font-size: 25px;
height: 50px;
width: 100%;
z-index: 1;
position: fixed;
}
a.left-top-bar {
font-family: ISOCPEUR;
background-color: #0e0e0e;
color: whitesmoke;
width: 200px;
text-align: center;
font-size: 30px;
padding: 5px 0 15px 0;
height: 30px;
position: fixed;
text-decoration: none;
z-index: 2;
}
div.sidenav {
background-color: #b5b5b5;
width: 200px;
height: 100%;
position: fixed;
top: 50px;
z-index: 3;
}
ul {
width: 200px;
background-color: #b5b5b5;
list-style-type: none;
}
li.main a {
padding: 10px 0 10px 15px;
font-family: Calibri;
display: block;
text-decoration: none;
color: white;
}
li.main a:hover {
background-color: #343434;
}
div.center {
background-color: #a1b9a4;
position: absolute;
left: 200px;
top: 50px;
height: 1000px;
width: 1141px;
padding-top: 25px;
padding-left: 25px;
z-index: 2;
}
div.dropbtn {
height: 23px;
padding: 10px 0 10px 15px;
font-family: Calibri;
display:block;
text-decoration: none;
color: white;
}
div.dropbtn:hover {
background-color: #343434;
}
div.dropdown-content {
display: none;
background-color: #343434;
width: 200px;
height: 129px;
text-align: center;
position: relative;
left: 185px;
bottom: 29px;
}
a.dropdown {
text-decoration: none;
color: white;
font-family: Calibri;
display: block;
padding: 12px 0 12px 0;
}
a.dropdown:hover {
background-color: #b5b5b5;
}
div.dropbtn:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<div class="container">
<div class="topbar"></div>
<a class="left-top-bar" href="https://www.wikipedia.org" target="_blank">This Website </a>
<div class="sidenav">
<ul>
<li class="main">Home</li>
<li class="main">Facebook</li>
<li class="main">Quora</li>
<li class="main">Reddit</li>
<li class="dropdown">
<div class="dropbtn">Dropdown
<div class="dropdown-content">
<a class="dropdown" href="#">Text<br></a>
<a class="dropdown" href="#">Link 2<br></a>
<a class="dropdown" href="#">Link 3<br></a>
</div>
</div>
</li>
</div>
<div class="center">
<h1>Test text</h1>
<p style="padding-top: 10px";>
Lorem Ipsum
</p>
</div>
</div>
</body>
</html>
The problem is not that the red bar scrolls up, but that the green .center div scrolls up on top of it.
Solution: decrease the z-index of the .center div to below 1, so that it appears behind the red bar.
* {
margin: 0;
padding: 0;
}
div.container {
position: relative;
}
div.topbar {
background-color: #f44336;
font-size: 25px;
height: 50px;
width: 100%;
z-index: 1;
position: fixed;
}
a.left-top-bar {
font-family: ISOCPEUR;
background-color: #0e0e0e;
color: whitesmoke;
width: 200px;
text-align: center;
font-size: 30px;
padding: 5px 0 15px 0;
height: 30px;
position: fixed;
text-decoration: none;
z-index: 2;
}
div.sidenav {
background-color: #b5b5b5;
width: 200px;
height: 100%;
position: fixed;
top: 50px;
z-index: 3;
}
ul {
width: 200px;
background-color: #b5b5b5;
list-style-type: none;
}
li.main a {
padding: 10px 0 10px 15px;
font-family: Calibri;
display: block;
text-decoration: none;
color: white;
}
li.main a:hover {
background-color: #343434;
}
div.center {
background-color: #a1b9a4;
position: absolute;
left: 200px;
top: 50px;
height: 1000px;
width: 1141px;
padding-top: 25px;
padding-left: 25px;
z-index: 0;
/* here */
}
div.dropbtn {
height: 23px;
padding: 10px 0 10px 15px;
font-family: Calibri;
display: block;
text-decoration: none;
color: white;
}
div.dropbtn:hover {
background-color: #343434;
}
div.dropdown-content {
display: none;
background-color: #343434;
width: 200px;
height: 129px;
text-align: center;
position: relative;
left: 185px;
bottom: 29px;
}
a.dropdown {
text-decoration: none;
color: white;
font-family: Calibri;
display: block;
padding: 12px 0 12px 0;
}
a.dropdown:hover {
background-color: #b5b5b5;
}
div.dropbtn:hover .dropdown-content {
display: block;
}
<div class="container">
<div class="topbar"></div>
<a class="left-top-bar" href="https://www.wikipedia.org" target="_blank">This Website </a>
<div class="sidenav">
<ul>
<li class="main">Home
</li>
<li class="main">Facebook
</li>
<li class="main">Quora
</li>
<li class="main">Reddit
</li>
<li class="dropdown">
<div class="dropbtn">Dropdown
<div class="dropdown-content">
<a class="dropdown" href="#">Text<br></a>
<a class="dropdown" href="#">Link 2<br></a>
<a class="dropdown" href="#">Link 3<br></a>
</div>
</div>
</li>
</ul>
</div>
<div class="center">
<h1>Test text</h1>
<p style="padding-top: 10px" ;>
Lorem Ipsum
</p>
</div>
</div>
Try using 3 for z-index value for div.topbar
div.topbar {
background-color: #f44336;
font-size: 25px;
height: 50px;
position: fixed;
width: 100%;
z-index: 3;
}
I can't figure out why my elements (logo, menu, info box) are outside the light grey container. Could you help me? Many thanks
See: http://jsfiddle.net/vqoudo6d/3/
HTML:
<header class="header">
<div class="header-wrapper">
<img class="header-logo" src="http://lorempixel.com/output/fashion-q-g-284-119-5.jpg">
<nav class="header_nav">
<ul class="header_nav-wrapper">
<li class="header_nav-item"> <a id="aboutOpen" class="header_nav-item-a" href="jkk">l'Atelier</a>
</li>
<li class="header_nav-item"> <a class="header_nav-item-a header_nav-item-a--btn" href="jkjks" target="_blank">La Carte des soins</a>
</li>
<li class="header_nav-item"> <a class="header_nav-item-a header_nav-item-a--btn" href="jkjks" target="_blank">Contact</a>
</li>
</ul>
</nav>
</div>
<div class="infos-pratiques clearfix">
<p class="info-pratiques-tag">Informations pratiques</p>
<div class="info-pratiques-content">
<p>3 rue dfdsf
<br>sdsqdssdd</p>
<p>Lundi:
<br>Mardi:
<br>Mercredi:
<br>Jeudi</p>
</div>
</div>
</header>
<div class="slider">
<ul class="slider__wrapper">
<li class="slider__item">
<div class="box" style="background-image:url(images/test.jpg);background-size: cover;
background-repeat: no-repeat; background-position: 50% 50%;"></div>
</li>
<li class="slider__item">
<div class="box" style="background-image:url(images/test2.jpg);background-size: cover;
background-repeat: no-repeat; background-position: 50% 50%;"></div>
</li>
</ul>
</div>
CSS:
.slider {
position: relative;
margin-left: auto;
margin-right: auto;
width: 90%;
height: 550px;
background: #eee;
overflow: hidden;
box-shadow: 0 2px 5px rgba(0, 0, 0, .5);
max-width: 1200px;
}
.slider__wrapper {
height: 100%;
list-style: none;
overflow: hidden;
*zoom: 1;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
}
.slider__item {
height: 100%;
float: left;
clear: none;
}
.slider__arrows-item {
position: absolute;
display: block;
margin-bottom: -20px;
padding: 20px;
}
.slider__arrows-item--right {
bottom: 50%;
right: 30px;
}
.slider__arrows-item--left {
bottom: 50%;
left: 30px;
}
.slider__nav {
position: absolute;
bottom: 30px;
}
.slider__nav-item {
width: 12px;
height: 12px;
float: left;
clear: none;
display: block;
margin: 0 5px;
background: #fff;
}
.slider__nav-item--current {
background: #ccc;
}
.slider__nav-item:hover {
background: #ccc;
}
.box {
width: 100%;
height: 100%;
}
.header {
z-index: 999;
width: 100%;
margin-left: auto;
margin-right: auto;
position: absolute;
}
.header-wrapper {
padding: 54px 60px;
}
.header-logo {
float: left;
clear: none;
}
.header_nav {
float: right;
clear: none;
font-family:'Maven Pro', sans-serif;
font-weight: normal;
}
.header_nav-wrapper {
list-style: none;
}
.header_nav-item {
margin-left: 22px;
float: left;
clear: none;
}
.header_nav-item-a {
color: #474032;
text-decoration: none;
}
.header_nav-item-a:hover {
color: #eee;
}
.header_nav-item-a--btn {
padding: 16px 18px;
border-radius: 5px;
border: 1px solid #474032;
background-color: transparent;
}
.header_nav-item-a--donate {
margin-top: -18px;
}
.header_nav-item-a--btn:hover {
border: 1px solid #eee;
}
.info-pratiques-content {
float: left;
clear: both;
margin-top: 14px;
margin-left: 4.52489%;
font-size: 13px;
line-height: 1.38;
color: #433d2b;
}
.info-pratiques-content p {
margin-bottom: 1em;
}
.info-pratiques-tag {
margin-top: 14px;
margin-right: auto;
margin-left: auto;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 2px;
padding-left: 2px;
background-color: #9d926a;
font-size: 13px;
font-weight: 400;
line-height: 1.38;
text-align: center;
text-transform: uppercase;
color: rgb(65, 61, 45);
}
.infos-pratiques {
position: absolute;
top: 217px;
right: 5.1984375%;
z-index: 26;
width: 221px;
height: 200px;
background-color: rgb(222, 222, 222);
opacity: 0.91;
}
The max-width and the background are on .slider, but your header is not inside of it. just add the background and max-width to body and everything should be fine.
Also keep in mind that absolutely positioned elements are always relative to the closest non-static element (position: fixed, relative, absolute).
edit: I also agree with Paulie_D's comment, try to reduce absolute positioning