How to center "position: relative"-navigation bar? - html

How can I center a navigation bar with the position property set to relative? It's for this website.
I've found several solutions for doing that, but that requires me to change the position of the navigation bar to absolute. I can't do that, since that ruins the entiry css style for the navigation bar!
body header .bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
height: 125px;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
body header .bottom-header ul {
position: relative;
top: 32%;
list-style-type: none;
margin: 0;
padding: 0;
}
body header .bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
body header .bottom-header .button {
transition: all .4s ease;
display: block;
float: left;
top: 40px;
margin: auto;
min-width: 13%;
max-width: 13%;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
margin-left: 0.4%;
margin-right: 0.4%;
cursor: pointer;
}
body header .bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
body header .bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<center>
<div class="bottom-header">
<ul>
<li class="button" id="top" style="margin-left: 1%;" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>
</center>
What I've done to center it (which really isn't a good solution) is, I change the margin on each side of the navigation bar depending on the total width of the page. Like you can see if you take a look at the css of the page i linked before. Thank you!

Make yout ul a relatively positioned inline-blockand use margin: 0 auto; on it to center it. And erase all width settings from the lielements / buttons, so they can have the width necessary for their text contents:
.bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
.bottom-header ul {
position: relative;
display: inline-block;
margin: 0 auto;
list-style-type: none;
padding: 0;
}
.bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
.bottom-header .button {
transition: all .4s ease;
display: block;
top: 40px;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
cursor: pointer;
}
.bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
.bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<div class="bottom-header">
<ul>
<li class="button" id="top" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>
In case you want the buttons aligned horzontally (i.e. other than in the code you posted), apple diplay: inline-block to the lielements, and maybe a fixed min-width setting:
.bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
.bottom-header ul {
position: relative;
display: inline-block;
margin: 0 auto;
list-style-type: none;
padding: 0;
}
.bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
.bottom-header .button {
transition: all .4s ease;
display: inline-block;
min-width: 90px;
top: 40px;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
cursor: pointer;
}
.bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
.bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<div class="bottom-header">
<ul>
<li class="button" id="top" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>

Related

Trouble with aligning elements

I came across this issue where I cannot get mine top-box to organize the elements correctly. I've tried everything that I know off and cannot get it to work. I need to have my text 100% in middle and logo just to left but every time I try to do that the text moves to right and its offset. And the Navigation bar to be under the logo and text and that is centered like 100% of time every time I try.
I have a main div as a container, this top-box is a child.
<div class="top-box">
<div class="logo">
<a href="#">
<img src="Assets/Images/WebsiteLogo.png" alt="">
</a>
</div>
<div class="webname">
<a href="#">
<h1>Universal Web Designs</h1>
</a>
</div>
<div class="navigationbar">
<ul>
<li>Home</li>
<li>Designs</li>
<li>About Me</li>
<li>Contact</li>
</ul>
</div>
</div>
Some CSS not all
.top-box {
display: flex;
width: 90%;
padding: 0;
margin: 0.5rem 0 0 0;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
background: rgba(0, 0, 0, 0.75);
border-top: solid white 1px;
border-right: solid white 1px;
border-left: solid white 1px;
}
.logo {
margin: 0;
padding: 0;
border: solid 1px red;
/* background: rgba(255, 255, 255, 1); */
/* border-radius: 5rem; */
}
.logo img {
width: 5rem;
margin: 0;
/* background: rgba(255, 255, 255, 1); */
/* border-radius: 5rem; */
}
.webname {
}
.webname a {
text-decoration: none;
}
.webname h1 {
padding: 0;
margin: 0;
font-size: 3.5rem;
color: rgba(26, 184, 212, 1);
text-shadow: 4px 2px 10px gray;
border: solid 1px red;
}
.webname h1:hover {
color: gray;
text-shadow: 4px 2px 10px rgb(26, 184, 212);
}
.navigationbar {
width: 100%;
text-align: center;
padding: 0;
margin: 0.2rem 0 0 0;
border: solid 1px red;
/* border-top: solid rgba(255, 255, 255, 0.1) 1px; */
}
.navigationbar ul {
list-style-type: none;
}
.navigationbar li{
display: inline;
text-transform: uppercase;
padding: 0;
margin: 0 2rem;
}
.navigationbar a {
text-decoration: none;
font-size: 1.2rem;
color: white;
text-shadow: 2px rgb(26, 184, 212);
}
.navigationbar a:hover {
color: #dc3545;
text-decoration: underline;
}
Thanks
Solution to you question with CSS grid:
.top-box {
width: 90%;
padding: 0;
margin: 0.5rem 0 0 0;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
background: rgba(0, 0, 0, 0.75);
border-top: solid white 1px;
border-right: solid white 1px;
border-left: solid white 1px;
}
.grid {
display: grid;
grid-template-columns: 1fr 555px 1fr;
}
.logo {
margin: 0;
padding: 0;
border: solid 1px red;
/* background: rgba(255, 255, 255, 1); */
/* border-radius: 5rem; */
}
.logo img {
width: 5rem;
margin: 0;
/* background: rgba(255, 255, 255, 1); */
/* border-radius: 5rem; */
}
.webname {
margin: 0 auto;
}
.webname a {
text-decoration: none;
}
.webname h1 {
padding: 0;
margin: 0;
font-size: 3.5rem;
color: rgba(26, 184, 212, 1);
text-shadow: 4px 2px 10px gray;
/* border: solid 1px red; */
}
.webname h1:hover {
color: gray;
text-shadow: 4px 2px 10px rgb(26, 184, 212);
}
.navigationbar {
width: 100%;
text-align: center;
padding: 0;
margin: 0.2rem 0 0 0;
border: solid 1px red;
/* border-top: solid rgba(255, 255, 255, 0.1) 1px; */
}
.navigationbar ul {
list-style-type: none;
}
.navigationbar li{
display: inline;
text-transform: uppercase;
padding: 0;
margin: 0 2rem;
}
.navigationbar a {
text-decoration: none;
font-size: 1.2rem;
color: white;
text-shadow: 2px rgb(26, 184, 212);
}
.navigationbar a:hover {
color: #dc3545;
text-decoration: underline;
}
.logo {
width: 40px;
height:40px;
margin-left: auto;
margin-right: 10px;
align-self: center;
}
<div class="top-box">
<div class="grid">
<div class="logo">
<a href="#">
<img src="Assets/Images/WebsiteLogo.png" alt="">
</a>
</div>
<div class="webname">
<a href="#">
<h1>Universal Web Designs</h1>
</a>
</div>
</div>
<div class="navigationbar">
<ul>
<li>Home</li>
<li>Designs</li>
<li>About Me</li>
<li>Contact</li>
</ul>
</div>
</div>

How to get the :before tag to show on top of ul element?

I am creating a dropdown box for the account at the top right corner of the window.
I have added the code for the :before but does not seem to show above the element. The :before element is meant to be a triangle at the top of the ul container which points to where the dropdown has come from.
.DropDownContainer{
color: rgba(0, 0, 0, 0.87);
background-color: rgb(255, 255, 255);
transition: transform 250ms cubic-bezier(0.23, 1, 0.32, 1) 0ms, opacity 250ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
box-sizing: border-box;
font-family: Roboto, sans-serif;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 6px, rgba(0, 0, 0, 0.12) 0px 1px 4px;
border-radius: 2px;
position: fixed;
z-index: 2100;
opacity: 1;
transform: scale(1, 1);
transform-origin: left top;
max-height: 670px;
overflow-y: auto;
float: left;
text-align: left;
top: 55px;
right: 20px;
padding: 26px 0;
border-radius: 8px;
position: absolute;
top: calc(60px - 10px);
width: 210px;
list-style: none;
background-clip: padding-box;
padding-left:0;
}
.DropDownContainer:before{
content: '';
width: 0;
height: 0;
position: absolute;
top: -20px;
right: 120px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
}
.DropDownButton{
display: flex;
justify-content: left;
padding: 10px;
padding-left: 28px;
padding-right: 28px;
letter-spacing: 1px;
color: rgb(38, 38, 38);
}
.DropDownButton a{
text-decoration: none;
}
.DropDownButton img{
height: 20px;
width: 20px;
margin-right: 10px;
}
.DropDownButton:hover{
background-color: rgba(36, 36, 36, 0.071);
cursor: pointer;
}
(<ul className={classes.DropDownContainer}>
<li className={classes.DropDownButton} onClick={() => setShowDropDown(false)}>Profile</li>
<li className={classes.DropDownButton}>Edit Profile</li>
<li className={classes.DropDownButton}>My Hub</li>
<li className={classes.DropDownButton} >My Favourites</li>
<li className={classes.DropDownButton} >My Must Reads</li>
<li className={classes.DropDownButton}>Account Settings</li>
<li className={classes.DropDownButton} >Sign Out</li>
</ul>)
It is meant to be a triangle at the top of the ul container.
You should write two colons not only a colon for ' before '. I mean your code should be as such :
.DropDownContainer::before {
content: '';
width: 0;
height: 0;
position: absolute;
top: -20px;
right: 120px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
}

I'm trying to add some <li> element, but the lists never appear

I am trying to make a to do list app. I just finished input part, but I have a trouble with make a list. In my code, After the the part can not appear, there is no text after the header. I have tried change the code <div>...</div> to <p>...</p>, but it still does not work. I want know whats wrong with my code.
body,
input,
button {
font-family: 'Orbitron', sans-serif;
}
header {
width: 100%;
height: 300px;
top: 0;
left: 0;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
position: fixed;
background-color: #25b99a;
outline: none;
padding: 15px;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
}
header input {
width: 100%;
height: 75px;
top: 200;
float: left;
font-size: 20px;
font-weight: 400;
text-indent: 30px;
margin-top: 35px;
background: rgba(255, 255, 255, 0.3);
border-top-left-radius: 15px;
border-top-right-radius: 35.5px;
border-bottom-right-radius: 35.5px;
border-bottom-left-radius: 15px;
outline: none;
box-shadow: none;
border: 0;
-webkit-appearance: none;
-moz-appearance: none;
position: sticky;
}
header button {
width: 75px;
height: 75px;
position: absolute;
top: 137px;
right: 15px;
z-index: 2;
border-radius: 35.5px;
background: #fff;
border: 0px;
box-shadow: none;
outline: none;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
}
header input::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input:-moz-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input::-moz-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input:-ms-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header button svg {
width: 26px;
height: 26px;
position: absolute;
top: 50%;
left: 50%;
margin: -13px 0 0 -13px;
}
header button svg .addIcon {
fill: #25b99a;
}
p {
font-size: 300%;
color: rgba(255, 255, 255);
}
.container {
width: 100%;
float: left;
padding: 20px;
}
ul.todo {
width: 100%;
float: left;
height: 50px;
background: #fff;
border-radius: 5px;
}
<header>
<p class="text-center" style="font-size:300%;color:rgba(255,255,255);">To Do List</p>
<input type="text" placeholder="What is your plan " id="plan">
<button id="add">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"><g><path class="addIcon" d="M16,8c0,0.5-0.5,1-1,1H9v6c0,0.5-0.5,1-1,1s-1-0.5-1-1V9H1C0.5,9,0,8.5,0,8s0.5-1,1-1h6V1c0-0.5,0.5-1,1-1s1,0.5,1,1v6h6C15.5,7,16,7.5,16,8z"/></g></svg>
</button>
</header>
<div class="container">
<ul class="todo">
<li>hahahaha</li>
<li>hahahaha</li>
<li>hahahaha</li>
</ul>
</div>
I believe the position:fixed in your header is blocking the list, so you can play with the different positions to get the one you want like below.
body,input,button{
font-family: 'Orbitron', sans-serif;
}
header{
width:100%;
height:300px;
top:0;
left:0;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
position:relative;
background-color:#25b99a;
outline: none;
padding:15px;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
}
header input{
width: 100%;
height:75px;
top: 200;
float:left;
font-size: 20px;
font-weight: 400;
text-indent: 30px;
margin-top: 35px;
background: rgba(255,255,255,0.3);
border-top-left-radius: 15px;
border-top-right-radius: 35.5px;
border-bottom-right-radius:35.5px;
border-bottom-left-radius:15px;
outline: none;
box-shadow: none;
border:0;
-webkit-appearance:none;
-moz-appearance:none;
position: sticky;
}
<body>
<header>
<p class="text-center" style="font-size:300%;color:rgba(255,255,255);">To Do List</p>
<input type="text" placeholder="What is your plan " id="plan">
<button id="add">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"><g><path class="addIcon" d="M16,8c0,0.5-0.5,1-1,1H9v6c0,0.5-0.5,1-1,1s-1-0.5-1-1V9H1C0.5,9,0,8.5,0,8s0.5-1,1-1h6V1c0-0.5,0.5-1,1-1s1,0.5,1,1v6h6C15.5,7,16,7.5,16,8z"/></g></svg>
</button>
</header>
<div class="container">
<ul class="todo">
<li>hahahaha</li>
<li>hahahaha</li>
<li>hahahaha</li>
</ul>
</div>
<script src="js/index.js"></script>
</body>
The header has position: fixed. That means, that the header is not in the regular static layout flow anymore. The .container is now behind the header.
header {
box-sizing: border-box;
height: 300px;
...
}
header + .container {
padding-top: 300px;
}
will fix this.
body,
input,
button {
font-family: 'Orbitron', sans-serif;
}
header {
width: 100%;
height: 300px;
top: 0;
left: 0;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
position: fixed;
background-color: #25b99a;
outline: none;
padding: 15px;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
box-sizing: border-box;
}
header input {
width: 100%;
height: 75px;
top: 200;
float: left;
font-size: 20px;
font-weight: 400;
text-indent: 30px;
margin-top: 35px;
background: rgba(255, 255, 255, 0.3);
border-top-left-radius: 15px;
border-top-right-radius: 35.5px;
border-bottom-right-radius: 35.5px;
border-bottom-left-radius: 15px;
outline: none;
box-shadow: none;
border: 0;
-webkit-appearance: none;
-moz-appearance: none;
position: sticky;
}
header button {
width: 75px;
height: 75px;
position: absolute;
top: 137px;
right: 15px;
z-index: 2;
border-radius: 35.5px;
background: #fff;
border: 0px;
box-shadow: none;
outline: none;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
}
header input::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input:-moz-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input::-moz-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header input:-ms-input-placeholder {
color: rgba(255, 255, 255, 0.75);
}
header button svg {
width: 26px;
height: 26px;
position: absolute;
top: 50%;
left: 50%;
margin: -13px 0 0 -13px;
}
header button svg .addIcon {
fill: #25b99a;
}
p {
font-size: 300%;
color: rgba(255, 255, 255);
}
.container {
width: 100%;
float: left;
padding: 20px;
}
ul.todo {
width: 100%;
float: left;
height: 50px;
background: #fff;
border-radius: 5px;
}
header+.container {
padding-top: 300px;
}
<header>
<p class="text-center" style="font-size:300%;color:rgba(255,255,255);">To Do List</p>
<input type="text" placeholder="What is your plan " id="plan">
<button id="add">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"><g><path class="addIcon" d="M16,8c0,0.5-0.5,1-1,1H9v6c0,0.5-0.5,1-1,1s-1-0.5-1-1V9H1C0.5,9,0,8.5,0,8s0.5-1,1-1h6V1c0-0.5,0.5-1,1-1s1,0.5,1,1v6h6C15.5,7,16,7.5,16,8z"/></g></svg>
</button>
</header>
<div class="container">
<ul class="todo">
<li>hahahaha</li>
<li>hahahaha</li>
<li>hahahaha</li>
</ul>
</div>

Adjust gap between menu

I'm trying to adjust the spacing(gap) between menu so it'll fit with the navbar.By changing margin doesn't seems to do it. Anyone have idea on how to fix this ? Is it possible to re-position each menu individually ?
Here's the demo
#navbar {
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
#menu {
display: inline-block;
margin: 65px 50px 0px 100px;
position: relative;
float: left;
width: 100px;
padding: 0 10px;
border-radius: 8px;
box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15);
background: #8495F5;
}
#menu,
#menu ul {
list-style: none;
}
#menu: li {
float: left;
position: relative;
border-right: 1px solid rgba(0, 0, 0, .1);
box-shadow: 1px 0 0 rgba(255, 255, 255, .25);
perspective: 1000px;
}
#menu: li:first-child {
border-left: 1px solid rgba(255, 255, 255, .25);
box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25);
}
#menu a {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75, 75, 75, 1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu: li:hover>a {
background: #333;
color: rgba(0, 223, 252, 1);
text-shadow: none;
}
#menu li ul {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu li:hover ul {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0, 0, 0, .5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
#menu li li a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
}
#menu li li a:hover {
color: rgba(0, 223, 252, 1);
border-top: dotted 1px rgba(255, 255, 255, .15);
border-bottom: dotted 1px rgba(255, 255, 255, .15);
background: rgba(0, 223, 252, .02);
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="home" href="#">Home</a></li>
</ul>
<ul id="menu">
<li><a class="register" href="#">Register</a></li>
</ul>
<ul id="menu">
<li><a class="guide" href="#">Guide</a>
<ul>
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</ul>
<ul id="menu">
<li><a class="download" href="#">Download</a>
<ul>
<li>Patch Download</li>
</ul>
</ul>
</div>
</div>
I am guessing you want something like this?
The last lines in the CSS will control each LI position.
SOURCE:
#navbar{
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
ul#menu {
display: inline-block;
margin: 65px 0 0px 195px;
position: relative;
width: 800px;
list-style-type:none;
}
ul#menu, ul#menu-sub {
list-style-type: none;
}
ul#menu > li {
padding: 0 10px;
box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.15);
background: #8495F5;
width: 100px;
float: left;
position: relative;
display: inline-block;
border-right: 1px solid rgba(0,0,0,.1);
box-shadow: 1px 0 0 rgba(255,255,255,.25);
border-radius: 8px;
}
#menu li:first-child {
border-left: 1px solid rgba(255,255,255,.25);
box-shadow: -1px 0 0 rgba(0,0,0,.1), 1px 0 0 rgba(255,255,255,.25);
}
#menu a.menu-top {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75,75,75,1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255,255,255,.9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu-sub {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu-sub a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
padding: 10px;
display:block;
}
#menu-sub a:hover {
color: rgba(0,223,252,1);
border-top: dotted 1px rgba(255,255,255,.15);
border-bottom: dotted 1px rgba(255,255,255,.15);
background: rgba(0,223,252,.02);
}
#menu-sub li:hover > a {
background: #333;
color: rgba(0,223,252,1);
text-shadow: none;
}
#menu li:hover #menu-sub {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0,0,0,.5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
/* controlling each li's position */
ul#menu li:nth-child(1) { /*first */
margin-right: 3%
}
ul#menu li:nth-child(2) { /*first */
margin-right: 200px;
}
ul#menu li:nth-child(3) { /*first */
margin-right: 3%
}
ul#menu li:nth-child(4) { /*first */
margin-right: 0;
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="menu-top home" href="#">Home</a></li>
<li><a class="menu-top register" href="#">Register</a></li>
<li>
<a class="menu-top guide" href="#">Guide</a>
<ul id="menu-sub">
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</li>
<li>
<a class="menu-top download" href="#">Download</a>
<ul id="menu-sub">
<li>Patch Download</li>
</ul>
</li>
</ul>
</div>
</div>
View Pen: Adjust gap between menu
Changed margin for #menu
#menu {
margin: 65px 0 0px 20px;
}
#navbar {
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
#menu {
display: inline-block;
margin: 65px 0 0px 20px;
position: relative;
float: left;
width: 100px;
padding: 0 10px;
border-radius: 8px;
box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15);
background: #8495F5;
}
#menu,
#menu ul {
list-style: none;
}
#menu: li {
float: left;
position: relative;
border-right: 1px solid rgba(0, 0, 0, .1);
box-shadow: 1px 0 0 rgba(255, 255, 255, .25);
perspective: 1000px;
}
#menu: li:first-child {
border-left: 1px solid rgba(255, 255, 255, .25);
box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25);
}
#menu a {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75, 75, 75, 1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu: li:hover>a {
background: #333;
color: rgba(0, 223, 252, 1);
text-shadow: none;
}
#menu li ul {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu li:hover ul {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0, 0, 0, .5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
#menu li li a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
}
#menu li li a:hover {
color: rgba(0, 223, 252, 1);
border-top: dotted 1px rgba(255, 255, 255, .15);
border-bottom: dotted 1px rgba(255, 255, 255, .15);
background: rgba(0, 223, 252, .02);
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="home" href="#">Home</a></li>
</ul>
<ul id="menu">
<li><a class="register" href="#">Register</a></li>
</ul>
<ul id="menu">
<li><a class="guide" href="#">Guide</a>
<ul>
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</ul>
<ul id="menu">
<li><a class="download" href="#">Download</a>
<ul>
<li>Patch Download</li>
</ul>
</ul>
</div>
</div>

How can I use the same CSS for 2 divs?

I have the 2 divs that I want styled the same. One is called #popover, the other is called #recordViewPopover. Here is my CSS for popover. How can I make #recordViewPopover use the same CSS as #popover?
#popover {
-webkit-border-radius: 4px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-transition: opacity 0.25s linear;
-moz-border-radius: 4px;
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-transition: opacity 0.25s linear;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
transition: opacity 0.25s linear;
border: 3px solid black;
border-radius: 4px;
background-color: white;
color: black;
cursor: auto;
display: none;
font-weight: normal;
line-height: 1;
position: absolute;
right: 22px;
z-index: 5000000;
}
#popover > .popover_triangle
{
border-top: 16px solid rgba(0,0,0,0);
border-left: 16px solid rgba(0,0,0,0);
border-right: 16px solid rgba(0,0,0,0);
border-bottom: 16px solid black;
font-size: 0px;
line-height: 0%;
position: absolute;
top: -34px;
left:150px;
width: 0px;
}
#popover > .header
{
background: #222;
background: -moz-linear-gradient(top, #333 0%, #111 100%);
background-image: -webkit-gradient(
linear,
left top,
left bottom,
from(rgba(255, 255, 255, 0.55)),
color-stop(0.2, rgba(255, 255, 255, 0.35)),
color-stop(0.5, rgba(255, 255, 255, 0.1)),
color-stop(0.5, transparent),
to(transparent));
color: white;
font-weight: bold;
height: 27px;
line-height: 25px;
margin: 0;
padding: 3px;
text-shadow: rgba(0, 0, 0, 1) 0 -1px 0;
text-align: center;
}
#popover > .content
{
font-size: 12px;
max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
width: 190px;
}
#popover > .content ul
{
list-style: none;
margin: 0;
padding: 0;
}
#popover > .content ul li
{
border-bottom: #ccc 1px solid;
line-height: 25px;
}
#popover > .content ul li.item:hover
{
border-bottom: #1443be 1px solid;
}
#popover > .content ul li h6
{
background: #f3f3f3;
display: block;
color: #000;
font-size: 13px;
padding: 0 10px;
text-shadow: rgba(255, 255, 255, 1) 0 -1px 0;
}
#popover > .content ul li a
{
display: block;
padding: 0 14px;
}
#popover > .content ul li a:link,
#popover > .content ul li a:visited
{
text-decoration:none;color:#333;
}
#popover > .content ul li a:focus,
#popover > .content ul li a:hover
{
background: #5396e3 url('../images/arrow-small.png') 97% center no-repeat;
color: #fff;
text-decoration: none;
text-shadow: rgba(0, 0, 0, .55) 0 -1px 0;
}
Here are my divs
<div id='popover'>
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>OBJECT VIEW</h6></li>
<li class='item'><a onclick=\"$(document).trigger('objectViewFiltersEnabled', [ !filtersEnabled ]);\">Filters</a></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li><h6>OBJECT</h6></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li class='item'><a href=\"#\" >Documentation</a></li>
</ul>
</div>
</div>
<div id='recordViewPopover'>
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>Information</h6></li>
<li class='item'><a href='#' >Change Logs</a></li>
<li><h6>Actions</h6></li>
<li class='item'><a href='#' >Assign</a></li>
<li class='item'><a href='#' >Share</a></li>
<li class='item'><a href='#' >Convert</a></li>
<li class='item'><a href='#' >Copy</a></li>
<li class='item'><a href='#' >Clone</a></li>
<li class='item'><a href='#' >Merge</a></li>
<li class='item'><a href='#' >Refresh</a></li>
<li class='item'><a href='#' >Delete</a></li>
</ul>
</div>
</div>
You would assign them both the same class. To do this you would have:
<div id='popover' class='someName'>
<div id='recordViewPopover' class='someName'>
and your CSS would be declared:
.someName {
//Add styles here
}
You could group multiple selectors:
#popover > .popover_triangle,
#recordViewPopover > .popover_triangle {
Or give the elements a class, and use a class selector where you have the id selector.
.popover > .popover_triangle {
#popover, #recordViewPopover {
...
}
Oh, and also
#popover > .popover_triangle,
#recordViewPopover > .popover_triangle {
...
}
But if you expect to have more divs like these two, it would indeed be better to define a class for them.