I need help with this site: http://www.jsdkqwoj.eu/
In mobile drop down menu goes under the div. Tried z-index:9999 for the header / topnav elements and z-index:-9999 to div. Not help. Also tried this Dropdown menu hidden under div and it is not helping.
I googled yesterday few hours and tried many things, and not helping. I also would like to get image top of the page under the header, but i am satisfied of the menu fix.
I linked the page but here is code of the top nav/header and div.
Summary: I want menu open over the div and image shows behind the menu dropdown. I can do dropdown menu like pushing down the div, but that is not what i want.
CSS
header {
background-color: rgba(0,0,0,0.7);
width: 100%;
height: 100px;
}
.topnav {
overflow: hidden;
background-color: rgba(0,0,0,0.7);
position: relative;
}
.topnav #myLinks {
display: none;
}
.topnav a {
color: white;
padding: 14px 16px;
text-decoration: none;
font-size: 20px;
display: block;
height: 60px;
}
.topnav2 a {
text-align: center;
}
.topnav a.icon {
display: block;
position: absolute;
right: 0;
top: 0;
height: 90px;
width: 90px;
}
.topnav2 a:hover {
background-color: rgba(0,0,0,0.4);
color: #ff6000;
}
TOPNAV
<h2 class="black">OSKARI ALAJÄRVI</h2><p class="light">Portfolio</p>
<div class="topnav2" id="myLinks">
Home
Blog
Contact
</div>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="hamburger_bars" onclick="myFunction2(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</i>
</a>
</div>
DIV
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-sm pt-5 pb-5">
<div class="etusivun_teksti" data-aos="fade-up">
<?php if (have_posts()) : while(have_posts()) : the_post();?>
<?php the_content();?>
<?php endwhile; endif;?>
</div>
</div>
<div class="col-sm etusivun_kuva"></div>
</div>
</div>
</div>
.topnav2{
position:relative;
z-index:1;
}
Add this to your css. Hope this works
Related
Im trying to get the bootstrap 4 responsive top nav to appear over my container div with no luck, and I cant seem to find a solution for it.
Here is how the Top nav is supposes to work
W3Schools editor
and here is my jsfiddle of the code
jsfiddle
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Add an active class to highlight the current page */
.active {
background-color: #4CAF50;
color: white;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
/* Dropdown container - needed to position the dropdown content */
.dropdown {
float: left;
overflow: visible;
}
/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
/* Style the dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: relative;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 2;
}
/* Style the links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover,
.dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
display: block;
}
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
#media screen and (max-width: 600px) {
.topnav a:not(:first-child),
.dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
#media screen and (max-width: 600px) {
.topnav.responsive {
position: relative;
}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {
float: none;
}
.topnav.responsive .dropdown-content {
position: relative;
}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
<button class="dropbtn">Equipment
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Manage equipment
Add equipment
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Stock
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Manage stock
Add stock
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Reports
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Report 1
Report 1
Report 1
</div>
</div>
☰
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<?php echo display_msg($msg); ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon bg-green">
<i class="glyphicon glyphicon-user"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top">
<?php echo $c_contractors['total']; ?> </h2>
<p class="text-muted">Contractors</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-red">
<i class="glyphicon glyphicon-list"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top">
<?php echo $c_jobs_active['total']; ?> </h2>
<p class="text-muted">Active Jobs</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-blue">
<i class="glyphicon glyphicon-list"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top">
<?php echo $c_jobs_pending['total']; ?> </h2>
<p class="text-muted">Pending jobs</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-yellow">
<i class="glyphicon glyphicon-list"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top">
<?php echo $c_jobs_completed['total']; ?>
</h2>
<p class="text-muted">Completed Jobs YTD</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="jumbotron text-center">
<h1>Any problems let me know.</h1>
</div>
</div>
</div>
</div>
</div>
I am sure it is something simple that I have over looked
Cheers,
Firstly, change the .topnav class to:
.topnav {
float:left;
width:100%;
position:relative;
background-color: #333;
}
Then remove the overflow from .dropdown class. Finally, change position: relative to position: absolute in the .dropdown-content class.
Don't forget to add a clear: both style before the container-fluid.
Here's the Fiddle.
I was looking at the mega menus on the w3schools website: (https://www.w3schools.com/howto/howto_css_mega_menu.asp).
Using the "try it yourself", I was playing around with it, but struggling to see how to add another mega menu or another link button next to the dropdown link.
Can anyone help me out?
Please check the code below, might help you:
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.navbar {
overflow: hidden;
background-color: #333;
font-family: Arial, Helvetica, sans-serif;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font: inherit;
margin: 0;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content .header {
background: red;
padding: 16px;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
background-color: #ccc;
height: 250px;
}
.column a {
float: none;
color: black;
padding: 16px;
text-decoration: none;
display: block;
text-align: left;
}
.column a:hover {
background-color: #ddd;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
height: auto;
}
}
<div class="navbar">
Home
News
<!-- START FIRST DROPDOWN -->
<div class="dropdown">
<button class="dropbtn">First Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="header">
<h2>Mega Menu - first dropdown</h2>
</div>
<div class="row">
<div class="column">
<h3>Category 1</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 2</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 3</h3>
Link 1
Link 2
Link 3
</div>
</div>
</div>
</div>
<!-- END FIRST DROPDOWN -->
<!-- START SECOND DROPDOWN -->
<div class="dropdown">
<button class="dropbtn">Second Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="header">
<h2>Mega Menu - second dropdown</h2>
</div>
<div class="row">
<div class="column">
<h3>Category 1</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 2</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 3</h3>
Link 1
Link 2
Link 3
</div>
</div>
</div>
</div>
<!-- END SECOND DROPDOWN -->
</div>
The code which gives you the megamenu is the following:
<div class="dropdown">
<button class="dropbtn">Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="header">
<h2>Mega Menu</h2>
</div>
<div class="row">
<div class="column">
<h3>Category 1</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 2</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 3</h3>
Link 1
Link 2
Link 3
</div>
</div>
</div>
Hope this is what you were looking for.
Please try to add some code to your question next time. It will be easier and quicker to analyze.
Regards
I'm building a button into my header so people can click on it and it takes them to a modal to fill out contact information. It cuts off the button like shown in the picture above.
My HTML:
<header class="site-header">
<div class="wrapper">
<div class="site-header__logo">
<div class="icon site-header__logo__graphic icon--clear"></div>
</div>
<div class="site-header__menu-icon">
<div class="site-header__menu-icon__middle"></div>
</div>
<div class="site-header__menu-content">
<div class="site-header__btn-container">
Request A Demo
</div>
<nav class="primary-nav primary-nav__pull-right">
<ul>
.....
</ul>
</nav>
</div>
</div>
</header>
My CSS
.site-header {
padding-top: 20px;
padding-bottom: 20px;
position: absolute;
width: 100%;
z-index: 2;
background-color: rgb(207, 206, 206, .5);
&__btn {
background-color: $mainOrange;
color: #fff;
font-size: 1.5rem;
padding: 5px 10px 5px 10px;
border-radius: 5px;
}
&__btn-container {
float: right;
}
}
When I remove the padding, the header flushes with the top. When I change the padding to margin it pushes the header down from the top.
Any ideas on how to make the button whole?
So im creating a website in bootstrap and im having 3 backgrounds under each other in div's. The thing is, the second and third background won't show up under the first one. So the page just shows up as one div with only the .one background, the other ones won't appear. It worked before... so I don't know if I messed something up that ruined it or something?
HTML:
<body>
<div class="container-fluid one">
<nav>
<li class="nav-item">
<a class="nav-link" href="">HOME</a>
<br>
<a class="nav-link" href="">OVER DE CAMPAGNE</a>
<br>
<a class="nav-link" href="">WORD JIJ BESPEELD?</a>
</li>
</nav>
<img class="sire" src="img/Sire.png">
<h2 class="headline">Wees geen pop,<br>
want je valt hardop
</h2>
<div class="center"><img class="marionet" src="img/marionet.png">
</div>
</div>
<div class="container-fluid two">
</div>
<div class="container-fluid three">
</div>
</body>
CSS:
a {
font-family: Zing Rust Demo Base;
text-decoration: none;
color: white;
font-size: 48px;
letter-spacing: 3px;
line-height: 1.75;
}
a:hover {
text-decoration: none;
color: white;
}
li {
list-style-type: none;
}
h2 {
font-family: Zing Rust Demo Base;
font-size: 36px;
color: white;
}
.headline {
padding-top: 400px;
padding-left: 15px;
}
.sire {
height: 50px;
width: 125px;
float: right;
margin-top: 450px;
}
.marionet {
width: 400px;
height: 700px;
margin-top: -800px;
margin-left: 570px;
}
.center {
display: inline;
}
.one {
background-image: url(../img/Deel1.png);
background-repeat: no-repeat;
}
.two {
background-image: url(../img/Deel2.png);
background-repeat: no-repeat;
}
.three {
background-image: url(../img/Deel3.png);
background-repeat: no-repeat;
}
This is because those containers are empty. You need to add at least one row-column pair into each one.
Once you have created those row-column pairs you either need to add some content into the columns or you need to specify the height for those columns otherwise they will be zero height and that's the reason why you don't see those background images.
This is what the code for the 2 empty containers should look like:
<div class="container-fluid two">
<div class="row">
<div class="col">
Content <br> goes <br> here...
</div>
</div>
</div>
<div class="container-fluid three">
<div class="row">
<div class="col">
Content goes here...
</div>
</div>
</div>
And of course, you can put more than one column into each row.
So I've created the Navbar which jumps to sections on the page via clicking. It works for my 'projects' and 'contact' sections but when I click 'about' the navbar jumps to it, but becomes transparent and unclickable. I tried adding a padding-top X px; to the 'about' element, but it still doesn't work.
Code is as follows in Codepen:
HTML:
<body>
<div class="fluid-container">
<h2> My Web Portfolio</h2>
<!--Creates the Navigation bar -->
<div class="navbar">
About
Projects
Contact
</div>
<!-- this creates the About section-->
<div class="main">
<div id=about>
<h3>Blank</h3>
</div>
<!-- This creates the 'project' section of the webpage-->
<div id=projects>
<h3><pre>My tribute page to Neil Armstrong<pre></h3>
<a href="#"><img border="0" alt="My Tribute page" align="center" src="#"/>
</a>
</div>
<!--contact section-->
<div id=contact>
<h3>Contact me via Facebook, Twitter, and Instagram!<h3>
<a href="#" class="fa fa-facebook" ></a>
</div>
</div>
</div>
</body>
CSS:
body {
background-color:turquoise;
padding-top:25px;
}
h2 {
text-align:center;
}
.navbar {
overflow:hidden;
background-color:#333;
position:fixed;
top:0px;
width:100%;
}
.navbar a {
float:left;
display:block;
color:#f2f2f2;
text-align:center;
padding:14px 16px;
text-decoration:none;
font-size:17px;
}
.main {
padding:16px;
margin-top:65px;
}
#projects {
position:relatve;
width:150px;
height:100px;
margin-top:200px;
margin-left:150px;
}
#contact {
position:relatve;
text-align:center;
margin-top:800px;
}
#about{
position:relative;
text-align:center;
padding-top:25px;
}
What am I doing wrong here?
When the page jumps to about, the sections obscure the nav bar. If you set a z-index to #main and the nav bar, you can ensure the navbar is always above the sections. I hope this helps.
body {
background-color: turquoise;
padding-top: 25px;
}
h2 {
text-align: center;
}
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0px;
width: 100%;
z-index: 10;
}
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.main {
padding: 16px;
position: relative;
z-index: 0
margin-top: 65px;
}
#projects {
position: relatve;
width: 150px;
height: 100px;
margin-top: 200px;
margin-left: 150px;
}
#contact {
position: relatve;
text-align: center;
margin-top: 800px;
}
#about {
position: relative;
text-align: center;
padding-top: 25px;
}
<body>
<div class="fluid-container">
<h2> My Web Portfolio</h2>
<!--Creates the Navigation bar -->
<div class="navbar">
About
Projects
Contact
</div>
<!-- this creates the About section-->
<div class="main">
<div id=about>
<h3>Blank</h3>
</div>
<!-- This creates the 'project' section of the webpage-->
<div id=projects>
<h3><pre>My tribute page to Neil Armstrong<pre></h3>
<a href="#"><img border="0" alt="My Tribute page" align="center" src="#"/>
</a>
</div>
<!--contact section-->
<div id=contact>
<h3>Contact me via Facebook, Twitter, and Instagram!<h3>
<a href="#" class="fa fa-facebook" ></a>
</div>
</div>
</div>
</body>