EDIT:
I found a solution myself. The width and height in my a element should be put in the li element instead. So these:
width: 7vw;
height: 7vw;
Into the li:)
I have been at it for a while and I just can't figure it out. Internet explorer and Firefox seem to display my menu correctly, but Chrome doesn't.
Here's the html:
<div id="navigationmenu">
<ul>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
And here's the CSS.
I have a lot of stuff there, but I posted it all. Maybe something is interfering??
#navigationmenu a {
display: block;
text-transform: uppercase;
text-decoration: none;
color: #a2a2a2;
font-size: 1.1vw;
line-height: 7vw;
text-align: center;
width: 7vw;
height: 7vw;
border: 1px #a2a2a2 solid;
background: #ffffff;
-moz-border-radius: 50%;
border-radius: 50%;
cursor: default;
margin-top: 0;
margin-bottom: 0;
margin-left: 2.1%;
margin-right: 2.1%;
transition-duration: 400ms;
transition-property: box-shadow;
transition-timing-function: ease;
-webkit-transition-duration: 400ms;
-webkit-transition-property: box-shadow;
-webkit-transition-timing-function: ease;
-o-transition-duration:400ms;
-o-transition-property: box-shadow;
-o-transition-timing-function: ease;
}
#navigationmenu a:hover{
background:#ffffff;
border: 1px #a2a2a2 solid;
-webkit-box-shadow: 0px 0px 5px 1px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 5px 1px rgba(0,0,0,0.75);
box-shadow: 0px 0px 5px 1px rgba(0,0,0,0.75);
}
#navigationmenu li {
display: inline;
float: left;
margin: 0;
padding: 0;
}
I have already tried putting the a element margin and padding to 0 and applying the left and right margins to the li elements instead, but this made the li elements go too far from each other in Firefox (in Chrome they were a little better, but not ok).
Use the following css to add margin between the li elements in you ul
Live example here:
http://jsbin.com/piyilafupe/1/
#navigationmenu ul li {
margin-right: 50px; /* ADD YOU DESIRED DISTANCE HERE */
}
Notes: if for any reason you need to remove the margin on the most right element you can add this
#navigationmenu ul li:last-child {
margin-right: none;
}
Apply the margin to the <li> elements instead of the <a>
You can get rid of the following code in #navigationmenu a
margin-left: 2.1%;
margin-right: 2.1%;
Instead do this
#navigationmenu li {
display: inline;
float: left;
margin-left: 2px;
margin-right: 2px;
padding: 0;
}
Related
My CSS Gallery specifications are not corresponding to my HTML5. The images are not following the hover tag and they are displaying on top of everything else. It will not stay fixed however when I change the positioning to fixed it disappear all together. CSS checker states validates all fine. I can not position it where I want on the page either. Any help would be appreciated. Thanks in advance
CSS CODE
#gallery {
bottom: -20px;
padding-right: 50px;
display: inline;
top: 200px;
z-index: 99999999;
}
#gallery ul {
list-style-type: none;
padding: 20px;
text-align: center;
position: fixed;
}
#gallery li {
display: inline;
padding-right: 20px;
}
#gallery img {
padding: 5px 5px 40px 5px;
background: white;
box-shadow: 4px 4px 8px -4px #000000;
-webkit-box-shadow: 4px 4px 8px -4px #000000;
-mox-box-shadow:4px 4px 8px -4px #000000;
}
#gallery:hover {
-webkit-transform:scale(5%);
-o-transform:scale(5%);
-moz-transform:scale(5%);
-ms-transform: scale(5%);
transform: scale(5%);
transition: 0.5s ease-in-out;
-webkit-transition:0.5s ease-in-out;
-o-transition:0.5s ease-in-out;
-mox-transition:0.5s ease-in-out;
-ms-transition: 0.5s ease-in-out;
}
I want to reduce the size of the drop down menus to the same as the buttons. Adjusting either the padding or margin would move the items out of place and close themselves when I try to hover over it. I'd like to know what is causing this. Here's the Fiddle
Any help would be great.
CSS:
.sort ul {
text-align: left;
display: inline;
margin: 0;
list-style: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
float:right;
}
.sort ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #FF5C00 url(http://i1350.photobucket.com/albums/p769/Stonecold_Stone/Games/SoManySales/Joint%20Supplement/alert-overlay_zpsf561d19b.png) repeat-x;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
color:#fff;
}
.sort ul li:hover {
background: #555;
color: #fff;
}
.sort ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
.sort ul li ul li {
background: #FFDFDF;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
z-index:9999;
}
.sort ul li ul li:hover { background: #666; }
.sort ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
.button, ul{ padding-left: 15px;}
.button {
list-style: none; cursor: pointer;
float: left; margin: 10px 10px;
background-color: #039fd3; color: #fff;
padding: 5px 10px;
font-size: 13px;
border-radius: 3px;
-webkit-transition:background-color 0.3s ease-in;
-moz-transition:background-color 0.3s ease-in;
-o-transition:background-color 0.3s ease-in;
transition:background-color 0.3s ease-in;
}
HTML:
<div class="sort"><ul>
<li>
Sort AXXX
<ul>
<li><a href='#'>SXXXX</a></li>
<li><a href='%#%'>AXXXx</a></li>
</ul>
</li>
<li>Sort BXXX
<ul>
<li><a href='%#%'>CXXXX</a></li>
</ul>
</li>
<li>Sort C
<ul>
<li><a href='%#%'>WSXXXX</a></li>
<li><a href='%#%'>SXXXX</a></li>
</ul>
</li>
</ul></div>
Following the op coding style, in order to adjust the width of the dropdown it is required to set a width value for the list items under .sort div. Also added paddings similar to the ones set to the blue buttons on the left.
.sort ul li{
width:70px;
padding-top:5px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
}
Also it is necesary to adjust the top relative position of the sub menu to always be below the the main menu,
.sort ul li ul{
top:100%;
}
To adjust the distance from the top of the menu to be the same as with the buttons, it is possible to tweak the top relative distance of the menu to achieve it.
The ul element containing the buttons is a block element and the list items within it are floated with a margin-top of 10px and padding-top of 5px so a total of 15px from the top. The ul element within div.sort is floated to the right and has a padding-top of 5px so with margin-top 10px (i.e. 15-5) should be aligned with the buttons.
.sort > ul{
margin-top:10px;
}
http://jsfiddle.net/fLSyE/
First is, if you want your buttons and drop down menu to have the same size, just set the width to be the same. Here is an example(from your code):
.sort ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 100px; /* set width of drop down menu to 100px */
-webkit-box-shadow: none;
/* SOME OTHER CODES FOLLOW */
}
.sort ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
width: 100px; /* also set the width of the menus to 100px */
position: relative;
padding: 15px 20px;
}
Hope it helps!
Please help, I am trying to simply add a border at the last element of my sub menu and text indent for the sub-menu elements, but for some reason it just applies everything on the top of the page, please take a look at the image below, it applies the changes on the top of the page for some reason and not on the elements it self!
for Live preview: http://leo.meeped.co.uk/
Thanks in advance.
Here is the HTML code:
<header>
<div id="wrapperHeader">
<div class="scrollable" id="headerContent">
<section class="headerLogo">
<img id="logoImage" src="assets/elements/logo.png" alt="LOAI Design Studio Logo"/>
</section>
<section id="headerMenu">
<nav id="MainMenu">
<ul class="MainMenu">
<li><a class="active" href="index.html">Home</a></li>
<li><a class="SubMenu" href="#">Portfolio</a>
<ul class="subMenu">
<li>Web Design</li>
<li>Visual Identity</li>
<li>Photography</li>
</ul>
</li>
<li>Testimonials</li>
<li>About Me</li>
<li>Get In Touch</li>
<li><a class="getStartedButton" href="get-started.html">Get Started</a></li>
</ul>
</nav>
</section>
</div>
</div>
</header>
Here's the CSS Code:
body{
line-height: 120%;
}
/*Additions*/
.scrollable{
overflow: auto;
-webkit-transition-property: top, bottom;
transition-property: top, bottom;
-webkit-transition-duration: .2s, .2s;
transition-duration: .2s, .2s;
-webkit-transition-timing-function: linear, linear;
transition-timing-function: linear, linear;
-webkit-overflow-scrolling: touch;
}
/*Pages Overall Styling*/ #Page{
position: relative;
padding-top: 0px;
z-index: 2;
-webkit-box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
-moz-box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
}
/*Content Containers Overall Styling*/.content{
width: 800px;
}
/*Header Containers Overall Styling*/#headerContent{
max-width: 100%;
height: 100%;
position: fixed;
margin: auto;
}
#wrapperHeader{
background-color: #2D3B53;
border-bottom: none;
width: 230px;
height: 100%;
position: fixed;
padding: 0px;
z-index: 1;
}
/*Main Header Elements*/
.headerLogo, #LogoImage{
display: none;
}
#headerMenu{
max-width: 230px;
float: none;
}
/*Main Menu*/
#MainMenu li{
padding: 0px;
float: none;
}
#MainMenu a{
color: #E0E5EE;
border-bottom: 1px solid #253145;
width: 100%;
line-height: 50px;
text-align: left;
text-indent: 20px;
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#MainMenu a:hover{
color: #B8C4D8;
background-color: #3D567B;
}
#MainMenu a.active{
display: none;
}
#MainMenu li a.getStartedButton{
color: #74ADB4;
}
#MainMenu li a.getStartedButton:hover{
background-color: #74ADB4;
color: #D4E6E8;
}
/*SubMenu*/
ul.subMenu{
background-color: #33435F;
border: 1px solid #DDDDDD;
display: none;
padding: 0;
position: relative;
top: 0; left: 0;
-webkit-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
-moz-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
}
.subMenu li{
width: 230px;
border-bottom:1px solid #DDDDDD;
}
/*Second Header Container & Elements (Hidden From Widescreen)*/
#SecondHeader{
background-color: #3D5273;
width: 100%;
line-height: 50px;
text-align: left;
display: inline-block;
}
.SecondHeader-button{
color: #FFFFFF;
background: #3D5273 url('../../assets/elements/nav-icon.png') no-repeat 10px center;
font-size: 15px;
font-weight: bold;
text-indent: 45px;
display: inline-block;
}
/*////////////////////////////*/
Use pseudo class :last-child like this:
nav ul li:last-child {
//style
}
Are subMenu and SubMenu the same thing? If so, you need to change that in your HTML. Maybe that's the answer to your problem?
For my website that I am making, I have this code:
.menu{
}
.menu a{
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
color: #d7d7d7;
font: bold 16px Arial,Helvetica,Sans-serif;
text-decoration: none;
border-radius: 10px;
background-color: #444;
padding: 5px 10px;
text-align: center;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
.menu a:hover{
border: double 6px #00F;
color: #00F;
background-color: #FFF;
font: bold 20px Arial,Helvetica,Sans-serif;
text-decoration: underline;
text-align: center;
}
.sidebar{
width:220px;
margin-top:8px;
margin-left:3px;
background-color:#CCC;
border-radius:10px;
padding:10px;
clear:left;
-moz-box-shadow: inset 0 0 5px 5px #888;
-webkit-box-shadow: inset 0 0 5px 5px #888;
box-shadow: inset 0 0 5px 5px #888;
}
.sidebar p{
text-align: center;
}
HTML code:
<div class="sidebar">
<b style="color:#666;">Menu</b>
<div class="menu">
<p>Profile</p>
<p>Friends</p>
<p>Community Service</p>
<p>Messages</p>
</div>
</div>
For some reason the only way I can position the anchors on top of each other like this is by putting them in paragraph tags, but I don't want that. Here is a picture of how all that code looks:
I want the menu to look like the Log In and Create an Account button, but there is no difference between the CSS, the only thing that could be differentiated between them is that the div containing them is positioned in a table. So I was wondering how I could achieve that same-width-and-height-as-the-ones-above-and-bellow-it kind of div. Also I tried putting it into a table and that only squashed it together and took out the round edges (CSS display: table in the .menu and display: table-cell in the anchor also does not work because it squashes it). Here is the rest of my code: http://pastebin.com/ZLS94ZvQ thanks for your help!
You should change your HTML in:
<div class="sidebar">
<b style="color:#666;">Menu</b>
<ul class="menu">
<li>Profile</li>
<li>Friends</li>
<li>Community Service</li>
<li>Messages</li>
</ul>
</div>
and your CSS in:
.menu{
list-style:none; /* remove style from <ul> but leave a 40px margin on the left */
margin-left:-40px; /* this remove the 40px margin on the left */
}
.menu li{
text-align: center;
margin: 10px 0; /* this adds 10px top and bottom of each <LI> element */
}
.menu a{
display: block;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
color: #d7d7d7;
font: bold 16px Arial,Helvetica,Sans-serif;
text-decoration: none;
border-radius: 10px;
background-color: #444;
padding: 5px 10px;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
.menu a:hover{
border: double 6px #00F;
color: #00F;
background-color: #FFF;
font: bold 20px Arial,Helvetica,Sans-serif;
text-decoration: underline;
text-align: center;
}
.sidebar{
width:220px;
margin-top:8px;
margin-left:3px;
background-color:#CCC;
border-radius:10px;
padding:10px;
clear:left;
-moz-box-shadow: inset 0 0 5px 5px #888;
-webkit-box-shadow: inset 0 0 5px 5px #888;
box-shadow: inset 0 0 5px 5px #888;
}
Using <ul> is better and semantically correct. For search engines it should be even better to wrap the <ul> with <nav>
You should consider using
<ul>
<li>Your link here</li>
<li>Your link here</li>
<li>Your link here</li>
<li>Your link here</li>
</ul>
to list your links. That is the most common way of doing it.
Then you can simply set your li tags to display: block; and set a width to stretch out the links so they are all even.
I want to underline my navigation menu but the problem is that I need it to be thicker so I am using bottom border instead so that I can set the width to 6px.
I can seem to figure out how to get the border to appear closer to the text. There seems to about a 10px gap between the text and the bottom-border at the moment and I don't want to have any.
I have tried to position another div and position it relative to each {li} with {bottom: 10px} but I can't seem to get it to work.
Here's what I have so
CODE
<div id="menu">
<ul>
<li>home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
CSS
#menu {
position: fixed;
left: 25%;
clear: both;
float: left;
font-size: 80px;
z-index: 500;
filter: alpha(opacity=75);
opacity: .75;
}
#menu ul{
text-decoration: none;
list-style-type: none;
margin: 0;
padding: 0;
line-height: 90px;
}
#menu ul li{
text-decoration: none;
list-style-type: none;
margin: 0;
}
#menu ul li a{
border-bottom: 6px solid #000;
text-decoration: none;
list-style-type: none;
color: #000;
}
#menu ul li a:hover{
}
You can use a mixture of line-height and margin to garner such an effect, like so:
#menu ul li a {
border-bottom: 6px solid #000000;
color: #000000;
display: block;
line-height: 50px;
list-style-type: none;
margin: 20px 0;
text-decoration: none;
}
Using display: inline-block; in combination with border-bottom could cause some weird behavior line breaks if longer links contain a line-break, see http://jsfiddle.net/PQZ9H/. Alternatively, you could use a combination of background-image and background-position which has the advantage of not touching the display value.
a {
text-decoration: none;
position: relative;
background-repeat: repeat-x;
background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==);
background-position: left 15px;
}
a:hover { background: none; }
A disadvantage is that you might have to define a background-position for every font-size you use.
Using this technique you could also remove the border from descenders like g or y adding
a span.descender { text-shadow: -1px 0px 0px white, 1px 0px 0px white, -2px 0px 0px white, 2px 0px 0px white, -3px 0px 0px white, 3px 0px 0px white; }
and
<span class="descender">A link with descenders like g or y</span>
See http://jsfiddle.net/25XNY/1
Try to this (origin russian http://artgorbunov.ru/bb/soviet/20120510/) article methods (background gradient and http://jsfiddle.net/d3WG6/)
<p>Зигварт считал <a><span>критерием истинности необходимость и общезначимость, для которых нет никакой опоры</span></a> в объективном мире.</p>
a { font-size: 50%; border-bottom: 1px dashed red; }
a > span { font-size: 200%; line-height: normal; }
Margin property can't change the border-bottom position, so
The height of the <a> element will define the position of the your border-bottom.
#menu > ul > li > a {
height: ;
}