So, apparently I can't seem to figure out why the text inside the li keeps sticking to the top of it ... I've tried playing with heights, line-heights, vertical-aligns, displays (table, table-cell, inline-block, inline ... ) and all that stuff, but idk why, I can't see what's wrong with it ...
jsFiddle - http://jsfiddle.net/qdq1jg4g/2/
HTML
<header>
<span id="headerTitle">Title</span>
<ul id="headerMenu">
<li> Plugin </li>
<li> how-to </li>
<li> Docs </li>
</ul>
</header>
CSS
#headerMenu{
position: absolute;
border: 1px dashed blue;
font-size: 16pt;
right: 15%;
height: 100%;
line-height: 100%;
bottom: 0px;
margin: 0px;
padding: 0px;
}
#headerMenu a{
height: 100%;
line-height: 100%;
}
#headerMenu a li{
border: 1px solid red;
float: left;
list-style: none;
height: 100%;
line-height: 100%;
padding: 0px 20px;
}
Thank you in advance.
Here is one way of doing it with the a tags embedded with the li tags:
header{
background: #eee;
color: #333;
height: 100px;
width: 100%;
top: 0px;
margin: 0px 0px 10px 0px;
font-size: 26pt;
position: relative;
z-index: 100;
transition: all 0.1s;
}
#headerTitle{
position: absolute;
bottom: 15px;
left: 10px;
}
#headerMenu{
position: absolute;
border: 1px dashed blue;
font-size: 16pt;
right: 15%;
height: 100%;
line-height: 1;
bottom: 0px;
margin: 0px;
padding: 0px;
}
#headerMenu li {
float: left;
display: table;
border: 1px solid red;
height: 100%;
margin: 0 20px; /* optional, depends on your layour */
}
#headerMenu a {
display: table-cell;
vertical-align: middle;
border: 1px dashed red;
height: 100%;
padding: 0 20px;
}
<header>
<span id="headerTitle">Title</span>
<ul id="headerMenu">
<li>Plugin</li>
<li>how-to</li>
<li>Docs</li>
</ul>
</header>
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;
}
I am trying to create a Navigation Menu with dropdown sub-menus. When I am trying to change "display" property from "None"to "Block" for Nested it is not working. Here below is code.
In the Code I have created Main Navigation Menu under with class="nav". and dropdown required on hover over elements in nav class.
body {
margin: 0;
padding: 0;
}
.head {
padding: 15px;
}
#contact span {
font-weight: bold;
}
#contact {
position: absolute;
top: 30px;
right: 10px;
line-height: 5px;
text-align: right;
}
.nav {
background: #000;
color: #fff;
overflow: auto;
padding: 15px 0px;
}
.nav>ul {
list-style-type: none;
padding: 0px 10px;
float: right;
margin: 0px;
}
.nav>ul>li {
display: inline;
padding: 15px 10px;
}
#products {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 200px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
#products li {
padding: 9px 0px;
}
#services {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 100px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
#services li {
padding: 9px 0px;
}
.nav>ul>li:hover {
background: red;
}
/*Please check Code Here.*/
.nav>ul>li:hover ul {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>BASIC HTML PAGE</title>
</head>
<body>
<div class="head">
<h1>BUSINESS NAME</h1>
<div id="contact">
<p><span>Mobile:</span>+918050000824</p>
<p><span>EMAIL:</span>garg.ishu#gmail.com</p>
</div>
</div>
<div class="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li class="productshome">PRODUCTS</li>
<ul id="products">
<li>PRODUCT-1</li>
<li>PRODUCT-2</li>
<li>PRODUCT-3</li>
<li>PRODUCT-4</li>
</ul>
<li id="serviceshome">SERVICES
<ul id="services">
<li>SERVICE-1</li>
<li>SERVICE-2</li>
<li>SERVICE-3</li>
<li>SERVICE-4</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</div>
</body>
</html>
Use !important in this style because your styles applied on id(which has highest priority in CSS) are not getting overridden by your style.
.nav>ul>li:hover ul {
display: block !important;
}
Also incase of products. the ul was not inside the li element.
body {
margin: 0;
padding: 0;
}
.head {
padding: 15px;
}
#contact span {
font-weight: bold;
}
#contact {
position: absolute;
top: 30px;
right: 10px;
line-height: 5px;
text-align: right;
}
.nav {
background: #000;
color: #fff;
overflow: auto;
padding: 15px 0px;
}
.nav>ul {
list-style-type: none;
padding: 0px 10px;
float: right;
margin: 0px;
}
.nav>ul>li {
display: inline;
padding: 15px 10px;
}
#products {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 200px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
#products li {
padding: 9px 0px;
}
#services {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 100px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
#services li {
padding: 9px 0px;
}
.nav>ul>li:hover {
background: red;
}
/*Please check Code Here.*/
.nav>ul>li:hover ul {
display: block !important;
}
<!DOCTYPE html>
<html>
<head>
<title>BASIC HTML PAGE</title>
</head>
<body>
<div class="head">
<h1>BUSINESS NAME</h1>
<div id="contact">
<p><span>Mobile:</span>+918050000824</p>
<p><span>EMAIL:</span>garg.ishu#gmail.com</p>
</div>
</div>
<div class="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li class="productshome">PRODUCTS
<ul id="products">
<li>PRODUCT-1</li>
<li>PRODUCT-2</li>
<li>PRODUCT-3</li>
<li>PRODUCT-4</li>
</ul>
</li>
<li id="serviceshome">SERVICES
<ul id="services">
<li>SERVICE-1</li>
<li>SERVICE-2</li>
<li>SERVICE-3</li>
<li>SERVICE-4</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</div>
</body>
</html>
OR
Change your id to class in case of products and services and your code will work without important as well.
body {
margin: 0;
padding: 0;
}
.head {
padding: 15px;
}
#contact span {
font-weight: bold;
}
#contact {
position: absolute;
top: 30px;
right: 10px;
line-height: 5px;
text-align: right;
}
.nav {
background: #000;
color: #fff;
overflow: auto;
padding: 15px 0px;
}
.nav>ul {
list-style-type: none;
padding: 0px 10px;
float: right;
margin: 0px;
}
.nav>ul>li {
display: inline;
padding: 15px 10px;
}
.products {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 200px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
.products li {
padding: 9px 0px;
}
.services {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 100px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
display: none;
}
.services li {
padding: 9px 0px;
}
.nav>ul>li:hover {
background: red;
}
/*Please check Code Here.*/
.nav>ul>li:hover ul {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>BASIC HTML PAGE</title>
</head>
<body>
<div class="head">
<h1>BUSINESS NAME</h1>
<div id="contact">
<p><span>Mobile:</span>+918050000824</p>
<p><span>EMAIL:</span>garg.ishu#gmail.com</p>
</div>
</div>
<div class="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li class="productshome">PRODUCTS
<ul class="products">
<li>PRODUCT-1</li>
<li>PRODUCT-2</li>
<li>PRODUCT-3</li>
<li>PRODUCT-4</li>
</ul>
</li>
<li id="serviceshome">SERVICES
<ul class="services">
<li>SERVICE-1</li>
<li>SERVICE-2</li>
<li>SERVICE-3</li>
<li>SERVICE-4</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</div>
</body>
</html>
This is an issue of specificity: you set the display: none; on an id selector, which has very high specificity, but set display: block; on a very low specificity selector: the descendant selector. The id will override that selector no matter where they show up in the cascade. Consider abstracting your display:none to only be a descendant selector (removing that property from #products, etc.), and it should work fine:
.nav>ul>li ul{
display: none;
}
Some helpful reading:
https://www.w3schools.com/css/css_combinators.asp
https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
Navigation Menu with dropdown sub-menus
body {
margin: 0;
padding: 0;
}
.head {
padding: 15px;
}
#contact span {
font-weight: bold;
}
#contact {
position: absolute;
top: 30px;
right: 10px;
line-height: 5px;
text-align: right;
}
.nav {
background: #000;
color: #fff;
overflow: auto;
padding: 15px 0px;
}
.nav>ul {
list-style-type: none;
padding: 0px 10px;
float: right;
margin: 0px;
}
.nav>ul>li {
display: inline;
padding: 15px 10px;
}
.products {
list-style-type: none;
width: 100px;
height: 150px;
position: absolute;
top: 165px;
right: 206px;
background-color: #f9f9f9;
margin: 0px;
padding: 10px 10px;
text-align: center;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
display: none;
}
.products li {
color: black;
padding: 9px 0px;
background-color: white;
}
.products li:hover {
background-color: #ddd;
}
.services {
list-style-type: none;
width: 100px;
height: 147px;
position: absolute;
top: 165px;
right: 85px;
background-color: #f9f9f9;
margin: 0px;
padding: 10px 10px;
text-align: center;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
display: none;
}
.services li {
color: black;
padding: 9px 0px;
background-color: white;
}
.products li:hover {
background-color: #ddd;
}
.nav>ul>li:hover {
background: red;
}
/*Please check Code Here.*/
.nav>ul>li:hover ul {
display: block;
}
I would remove the display: none from the services and products css because IDs have high specificity and will override other rules. While !important might temporarily solve this issue, I would not rely on !important as it could cause more issues later on.
You can declare a non-hovered rule with display: block alongside your current hovered rule.
<!DOCTYPE html>
<html>
<head>
<title>BASIC HTML PAGE</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.head {
padding: 15px;
}
#contact span {
font-weight: bold;
}
#contact {
position: absolute;
top: 30px;
right: 10px;
line-height: 5px;
text-align: right;
}
.nav {
background: #000;
color: #fff;
overflow: auto;
padding: 15px 0px;
}
.nav>ul {
list-style-type: none;
padding: 0px 10px;
float: right;
margin: 0px;
}
.nav>ul>li {
display: inline;
padding: 15px 10px;
}
#products {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 200px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
}
#products li {
padding: 9px 0px;
}
#services {
list-style-type: none;
width: 100px;
height: 140px;
position: absolute;
top: 150px;
right: 100px;
background: red;
margin: 0px;
padding: 10px 10px;
text-align: center;
}
#services li {
padding: 9px 0px;
}
.nav>ul>li:hover {
background: red;
}
/*Please check Code Here.*/
.nav>ul>li ul {
display: none;
}
.nav>ul>li:hover ul {
display: block;
}
</style>
</head>
<body>
<div class="head">
<h1>BUSINESS NAME</h1>
<div id="contact">
<p><span>Mobile:</span>+918050000824</p>
<p><span>EMAIL:</span>garg.ishu#gmail.com</p>
</div>
</div>
<div class="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li class="productshome">PRODUCTS
<ul id="products">
<li>PRODUCT-1</li>
<li>PRODUCT-2</li>
<li>PRODUCT-3</li>
<li>PRODUCT-4</li>
</ul>
</li>
<li id="serviceshome">SERVICES
<ul id="services">
<li>SERVICE-1</li>
<li>SERVICE-2</li>
<li>SERVICE-3</li>
<li>SERVICE-4</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</div>
</body>
</html>
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>
I have a navigation at the bottom of a page. Everything works fine and how I want it to except for one small bug and I can't seem to work out a solution...
When the page name is long and you view it on an iPad size screen, the name goes onto two lines - which is fine - how ever I would like the adjacent button to match the height (so they both stay the same height) and to both stay horizontally aligned to the centre.
Ive tried a few different things like display table and table cell, flex etc. but I can't seem to work out a solution that works properly.
Any suggestions on how I can do this...?
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
i used display:flex; on .footerNav and added margin to classes left and right.
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
display:flex;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
margin-right: 1%;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
margin-left: 1%;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
You can also use display: table; and display: table-cell; to do that if you need to support really old browsers (http://caniuse.com/#search=flex). However i would recomment using flexbox as GvM pointed out.
There is an interesting article about serveral ways to do what you want to do: https://css-tricks.com/fluid-width-equal-height-columns/
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
display: table;
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
display: table-cell;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
display: table-cell;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<div style="display: table-cell; width: 2%;"></div>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
</nav>
</div>
I am new to this. On my website, when the window is resized or is viewed on a different computer screen, the navigation bar (which is made up of rectangles and triangles) and text moves around and parts disappear. Do the sizes need to be in percentages? If so I am unsure of which parts I need to change.
To view it, please follow this link to my website on Codecademy and click on the full screen button.
body {
background-image: url('http://www.rgbstock.com/cache1u7YbL/users/x/xy/xymonau/300/nXWyMYC.jpg')
}
#background {
background-color: white;
height: 100%;
width: 75%;
position: relative;
top: 100px;
margin-left: auto;
margin-right: auto;
}
#header {
word-wrap: break-word;
border: 1px solid black;
height: 30%;
width: 60%;
position: relative;
bottom: 90px;
margin-left: auto;
margin-right: auto;
}
.photocontainer {
border: transparent;
height: 55%;
width: 65%;
position: relative;
bottom: 60px;
margin-left: auto;
margin-right: auto;
}
.photocontainer img {
width:100%;
height:100%;
}
.navcontainer {
border: 1px solid black;
height: 10%;
width: 99%;
position: relative;
bottom: 70px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
.navcontainer .navbar .navigation li {
list-style: none;
display: block;
float: left;
margin: 1em;
text-align: center;
position: relative;
left: 15%;
}
.navcontainer .navbar .navigation li a {
font-family: quicksand;
text-decoration: none;
text-transform: uppercase;
display: block;
width: 110%;
color: #000000;
font-size: 20px;
vertical-align: middle;
line-height: 31px;
}
.navigation li a:hover {
margin-top: 2px;
}
.navbar {
margin: 0 auto;
width: 90%;
position: relative;
bottom: 42px;
}
.navcontainer .navbar .rectangle {
background: #f1e5cd;
height: 62px;
position: relative;
-moz-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
z-index: 500; /* the stack order: foreground */
margin: 3em 0;
}
.navcontainer .navbar .l-triangle-top {
border-color: #e7dbc3 transparent transparent;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: left;
top: 1px;
left: -50px;
}
.navcontainer .navbar .l-triangle-bottom {
border-color: transparent transparent #e7dbc3;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: left;
top: -40px;
left: -150px;
}
.navcontainer .navbar .r-triangle-top {
border-color: #e7dbc3 transparent transparent;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: right;
right: -45px;
top: -107px;
}
.navcontainer .navbar .r-triangle-bottom {
border-color: transparent transparent #e7dbc3;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: relative;
float: right;
top: -149px;
right: -145px;
}
<div id="background">
<div id="header"></div>
<div class="navcontainer">
<div class="navbar">
<!-- the left side of the fork effect -->
<div class="l-triangle-top"></div>
<div class="l-triangle-bottom"></div>
<!-- the ribbon body -->
<div class="rectangle">
<!-- the navigation links -->
<ul class="navigation">
<li>Home</li>
<li>About</li>
<li>Menu</li>
<li>Order</li>
<li>Contact</li>
</ul>
<!-- end the ribbon body -->
</div>
<!-- the right side of the fork effect -->
<div class="r-triangle-top"></div>
<div class="r-triangle-bottom"></div>
<!-- end container -->
</div>
</div>
<div class="photocontainer"></div>
Read this article "http://www.w3schools.com/css/css_navbar.asp"
Your code is a bit confused.
Hope this helps.
Here you have a basic example:
ul {
list-style-type: none;
margin: 0;
overflow: hidden;
padding: 0;
}
li {
float: left;
}
a {
background-color: #dddddd;
display: block;
width: 60px;
}
You can find the solution in my fiddle, including absolutely positioned triangles. For simplification purposes I removed your header.
http://jsfiddle.net/L74gdm7j/2/
body {
background-image: url('http://www.rgbstock.com/cache1u7YbL/users/x/xy/xymonau/300/nXWyMYC.jpg')
}
#background {
background-color: white;
height: 100%;
width: 75%;
position: relative;
top: 100px;
margin-left: auto;
margin-right: auto;
}
.photocontainer {
border: transparent;
height: 55%;
width: 65%;
position: relative;
bottom: 60px;
margin-left: auto;
margin-right: auto;
}
.photocontainer img {
width:100%;
height:100%;
}
.navcontainer {
height: 10%;
width: 99%;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
.navcontainer .navbar .navigation {
text-align: center;
margin: 0;
padding: 0;
}
.navcontainer .navbar .navigation li {
list-style: none;
display: inline-block;
margin: 1em;
text-align: center;
}
.navcontainer .navbar .navigation li a {
font-family: quicksand;
text-decoration: none;
text-transform: uppercase;
color: #000;
font-size: 20px;
line-height: 31px;
transition-duration: 0.2s;
display: inline-block;
position: relative;
}
.navigation li a:hover {
transform: translateY(10px);
}
.navbar {
margin: 0 auto;
width: 90%;
position: relative;
bottom: 42px;
}
.navcontainer .navbar .rectangle {
background: #f1e5cd;
height: 62px;
position: relative;
-moz-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.55);
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.55);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
z-index: 500;
/* the stack order: foreground */
margin: 3em 0;
}
.navcontainer .navbar .l-triangle-top {
border-color: #e7dbc3 transparent transparent;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: absolute;
top: 0;
left: -38px;
}
.navcontainer .navbar .l-triangle-bottom {
border-color: transparent transparent #e7dbc3;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: absolute;
top: -38px;
left: -38px;
}
.navcontainer .navbar .r-triangle-top {
border-color: #e7dbc3 transparent transparent;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: absolute;
right: -38px;
top: 0;
}
.navcontainer .navbar .r-triangle-bottom {
border-color: transparent transparent #e7dbc3;
border-style:solid;
border-width:50px;
height:0px;
width:0px;
position: absolute;
top: -38px;
right: -38px;
}
<body>
<div id="background">
<div class="navcontainer">
<div class="navbar">
<!-- the left side of the fork effect -->
<div class="l-triangle-top"></div>
<div class="l-triangle-bottom"></div>
<!-- the ribbon body -->
<div class="rectangle">
<!-- the navigation links -->
<ul class="navigation">
<li>Home
</li>
<li>About
</li>
<li>Menu
</li>
<li>Order
</li>
<li>Contact
</li>
</ul>
<!-- end the ribbon body -->
</div>
<!-- the right side of the fork effect -->
<div class="r-triangle-top"></div>
<div class="r-triangle-bottom"></div>
<!-- end container -->
</div>
</div>
<div class="photocontainer"></div>
</div>
</body>