I am looking to use navigation pills on my website, but they are resulting in a background leak. See the effect on this website: http://oleb.net/blog/2011/12/tutorial-how-to-sort-and-group-uitableview-by-date/. Hover over the pills multiple times to see the issue. You can see the outline of the pills appear.
Here is the code that I tried:
.navigation-main {
border-top: 1px solid rgba(0,0,0,0.1);
padding-top: 5px;
clear: both;
display: block;
font: 700 13px/1.3076923076 Lato, sans-serif;
letter-spacing: .05em;
text-transform: uppercase;
width: 100%;
}
.navigation-main .menu {
max-width: 1272px;
margin: 0 auto;
}
.navigation-main ul {
list-style: none;
margin: 0;
padding-left: 0;
text-align: center;
}
.navigation-main li {
display: inline-block;
position: relative;
width: 100px;
}
.navigation-main li:after {
content: none;
display: block;
font-size: 11px;
margin-top: -4px;
vertical-align: middle;
}
.navigation-main li:last-child:after {
content: none;
}
.navigation-main a {
display: block;
line-height: 2.6153846153;
padding: 0 10px;
text-decoration: none;
white-space: nowrap;
}
.navigation-main ul ul {
background-color: #000;
display: none;
float: left;
position: absolute;
top: 2.6153846153em;
left: 0;
text-align: left;
z-index: 99999;
}
.navigation-main li li {
display: block;
}
.navigation-main li li:after {
content: "";
display: block;
margin: 0;
}
.navigation-main ul ul ul {
left: 100%;
top: 0;
}
.navigation-main ul ul a {
color: #fff;
line-height: 1.3076923076;
padding: .6153846153em 10px .6923076923em;
white-space: normal;
width: 170px;
}
.navigation-main ul ul a:hover {
background-color: #333;
color: #fff;
}
.navigation-main ul li:hover > ul {
display: block;
}
/* This is where the pill happens */
.navigation-main a:hover,
.navigation-main li.current_page_item > a,
.navigation-main li.current-menu-item > a {
border-radius: 4px;
color: #FFFFFF;
background-color: #000;
}
How do I stop the outline from appearing? Thanks!
Edit:
Code tried:
.navigation-main li {
display: inline-block;
position: relative;
border-radius: 6px;
width: 100px;
.navigation-main a:hover,
.navigation-main li.current_page_item > a,
.navigation-main li.current-menu-item > a {
border-radius: 4px;
color: #FFFFFF;
background-color: #000;
background-clip: padding-box;
}
Try adding this to your css:
background-clip: padding-box;
Add it to any item using border-radius.
Here is exactly what you need to write change for your example. Tried and verified.
body > header nav li a:hover {
color: white;
background-color: #0a6abf;
background-clip: padding-box;
}
with background-clip
without background-clip
Related
It is a wordpress site and this is from my style.css :
.sf-menu, .sf-menu * { margin: 0; padding: 0; list-style: none; }
.sf-menu li { position: relative }
.sf-menu ul { position: absolute; display: none; top: 100%; left: 0; z-index: 99; }
.sf-menu > li { float: left }
.sf-menu li:hover > ul, .sf-menu li.sfHover > ul { display: block }
.sf-menu a { display: block; position: relative; }
.sf-menu ul ul { top: 0; left: 100%; }
.sf-arrows .sf-with-ul:after { content: "\f347"; display: inline-block; -webkit-font-smoothing: antialiased; font: normal 12px/16px 'dashicons'; vertical-align: top; margin: 5px 0px 0 4px; }
.sf-arrows ul .sf-with-ul:after { content: "\f345"; display: inline-block; -webkit-font-smoothing: antialiased; font: normal 12px/22px 'dashicons'; float: right; vertical-align: top; margin: 2px 0 0 4px; }
.sf-arrows ul li > .sf-with-ul:focus:after, .sf-arrows ul li:hover > .sf-with-ul:after, .sf-arrows ul .sfHover > .sf-with-ul:after { border-left-color: white }
.navbar-toggle { display: none; position: absolute; left: auto; top: 5px; padding: 14px 13px; border-radius: 2px; background: rgba(0, 0, 0, 0.33); }
.navbar-toggle .icon-bar { display: block; width: 25px; height: 2px; border-radius: 1px; background: #fff; }
.navbar-toggle .icon-bar + .icon-bar { margin-top: 4px }
the menu block on the site wont expand.(the menu block only appears when page is in moblie-view mode.)
how should i fix this ?
in this cases make sure you have installed the theme correctly.
that was the mistake i've made.
I am working on a new wordpress site website and running into a CSS problem with the dropdown menus. Currently they are left-aligned to the main menu or parent menu item. My preference is for them to be centered on the main menu or parent menu item.
Here is a link to the site in development: http://centraltexasdistrict.com/welcome/
Here is a link to an image, which gives an idea of what I'm looking for or trying to achieve: http://centraltexasdistrict.com/wp-content/uploads/CTD-menu.jpg
Here is the current css I'm working with:
.menu-main-container {
margin-left: auto;
margin-right: auto;
width: 690px;
padding: 0 0 0 20px;
height: 35px;
z-index: 10;
line-height: 35px;
}
.menu-main-menu-container ul li ul{ text-align:center; }
.main-navigation {
clear: both;
margin: 0 auto;
max-width: 1080px;
min-height: 36px;
position: relative;
}
#navbar {
display: block;
height: 36px;
width: 100%;
margin-top: -27px;
z-index: 10;
position: absolute;
}
#site-navigation {
padding: 0px;
height: 30px;
z-index: 10;
line-height: 30px;
float: left;
}
ul.nav-menu,
div.nav-menu > ul {
margin: 0;
padding: 0px;
}
.nav-menu li {
display: inline-block;
position: relative;
}
.nav-menu li a {
display: block;
font-family: 'Lato', sans-serif;
line-height: 30px;
color: #aaaaaa;
font-weight: 400;
text-align: center;
text-transform:uppercase;
text-decoration: none;
letter-spacing: 1px;
float: left;
font-size: 12px;
padding: 30px 7px 0px 7px;
margin-bottom: 5px;
}
.nav-menu li:hover > a,
.nav-menu li a:hover,
.nav-menu li:focus > a,
.nav-menu li a:focus {
color: #ffffff;
background-color: #353535;
}
.nav-menu .sub-menu,
.nav-menu .children {
background-color: #e07726;
padding: 0px;
position: absolute;
z-index: 99999;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
margin-top: 65px;
}
.nav-menu .sub-menu ul,
.nav-menu .children ul {
border-left: 0;
left: 100%;
top: 0;
}
.sub-menu {
text-align: center;
width: 100%;
left: auto;
}
.sub-menu li {
display: inline-block;
width: auto;
padding: 0px;
}
.sub-menu li a {
display: block;
height: 24px;
font-family: 'Lato', sans-serif;
line-height: 24px;
font-weight: 400;
text-align: left;
text-decoration: none;
text-transform: none;
letter-spacing: 1px;
float: left;
font-size: 11px;
padding: 2px 10px 2px 10px;
color: #ffffff;
white-space: nowrap;
}
.sub-menu li:hover > a,
.sub-menu li a:hover,
.sub-menu li:focus > a,
.sub-menu li a:focus {
background-image: none;
color: #ac5411;
background-color: transparent;
}
ul.nav-menu ul a,
.nav-menu ul ul a {
color: #fff;
margin: 0;
}
ul.nav-menu li:hover > ul,
.nav-menu ul li:hover > ul,
ul.nav-menu .focus > ul,
.nav-menu .focus > ul {
clip: inherit;
overflow: inherit;
height: inherit;
width: inherit;
}
.nav-menu .current_page_item > a,
.nav-menu .current_page_ancestor > a,
.nav-menu .current-menu-item > a,
.nav-menu .current-menu-ancestor > a {
color: /* #333333 */;
}
A quick solution could be to give the submenu a specified width:
ul.nav-menu li:hover > ul, .nav-menu ul li:hover > ul, ul.nav-menu .focus > ul, .nav-menu .focus > ul {
clip: inherit;
overflow: inherit;
height: inherit;
width: 200px; /* width for the submenu */
left: 50%; /* position it 50% to the left */
margin-left: -100px; /* negative margin half of with to center it */
}
Or use translate if you dont want to have a specified width (not for all old browsers and you may need some prefixes):
ul.nav-menu li:hover > ul, .nav-menu ul li:hover > ul, ul.nav-menu .focus > ul, .nav-menu .focus > ul {
clip: inherit;
overflow: inherit;
height: inherit;
transform: translate(-50%, 0);
left: 50%;
}
.menu-main-menu-container ul li ul{
text-align:center;
}
Add the above code in your stylesheet to center drop down list of menu bar
I'm looking to make a dropdown menu that shows up inside/on top of the parent menu. I would like to do this in pure css. I have made a quick example of what I am looking for(in Photoshop). Here is a link. Here is what I have now, but this makes a normal dropdown menu and not one that stays in the parent container.
CSS:
.titlebox ul {
text-align: center;
font-size: 15px;
font-family: arial,sans-serif;
line-height: 32px;
margin: 0;
width: 100%;
background: #555;
list-style: none;
border-radius: 2px !important;
transition: all 0.15s ease;
}
.titlebox ul:hover {background: #666;}
.titlebox ul:active {background: #444;}
.titlebox ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 32px !important;
}
.titlebox ul li:hover {
background: #666;
}
.titlebox ul li:hover ul {
display: inline;
opacity: 1;
visibility: visible;
}
.titlebox ul li ul {
padding: 0;
position: absolute;
top: 0px;
right: 0px;
display: none;
opacity: 0;
visibility: hidden;
}
.titlebox ul li ul li {
display: inline;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
.titlebox ul li ul li:hover {background: #666;}
HTML(Quick):
<ul>
<li>Hi<br/>
<ul>
<li>Google<br/></li>
<li>HOLA<br/></li>
<li>HALO<br/></li>
</ul></li>
</ul>
Any and all help is appreciated! I know this might be kinda confusing but I don't know how else to explain it. If you have any questions, feel free to ask!
Thanks,
Usama Khan
EDIT 1: Here's the link to the JSFiddle.
i think this is your looking for .if not ,can you tell me where i am wrong.
ul {
text-align: center;
font-size: 15px;
font-family: arial, sans-serif;
line-height: 32px;
margin: 0;
padding: 0;
width: 300px;
background: #555;
list-style: none;
border-radius: 2px !important;
transition: all 0.15s ease;
}
ul:hover {
background: #666;
}
ul:active {
background: #444;
}
ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 32px !important;
}
ul li:hover {
background: #666;
}
ul li:hover ul {
display: inline;
opacity: 1;
visibility: visible;
margin-left:10px;
}
ul li ul {
padding: 0;
position: absolute;
top: 0px;
right: 0px;
display: none;
opacity: 0;
visibility: hidden;
}
ul li ul li {
display: inline;
color: #fff;
text-shadow: 0 -1px 0 #000;
float: left;
width: 33%;
}
ul li ul li:hover a{
color: white;
}
ul li ul li:hover {
background: #777;
}
<body>
<ul>
<li>Hi
<ul>
<li>Google1</li>
<li>Google2</li>
<li>Google3</li>
</ul>
</li>
</ul>
</body>
The HTML
I removed the /br from the html, because it was forcing the navigation menu to drop down.
<body>
<ul>
<li>Hi
<ul>
<li>HOLA</li>
<li>HALO</li>
</ul>
</li>
</ul>
</body>
The CSS
Read the comments in the css for all changes / explanation (ask if there is something you do not understand). I also removed a lot of unnecessary css from your code (and some of it probably still is).
ul {
text-align: center;
font-size: 15px;
font-family: arial, sans-serif;
line-height: 32px;
margin: 0 auto;/*center nav-menu*/
padding: 0;
width: 300px;
background: #555;
list-style: none;
border-radius: 2px;
}
/*unnecessary now
ul:hover {
background: #666;*/
}
ul:active {
background: #444;
}
ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 100%;
}
/*unnecessary now
ul li:hover {
background: #666;
}*/
/*hide ul and making it the same dimensions as its parent*/
ul li ul {
padding: 0;
position: absolute;
left: 0px;
right: 0px;
top:0px;
bottom: 0px;
display: none;
}
/*make submenu appear on hover of ul*/
ul li:hover ul {
display: block;
}
/*style the subnavigation-list*/
ul li ul li {
display: block;
width: 50%;/*accomidates for 2 list items, adding more will drop them below*/
float: left;
}
/*style your buttons*/
ul li ul li a{
text-decoration: none;
color: white;
text-shadow: 0 -1px 0 #000;
display: block;
height: 100%;
width: 100%;
background-color: #555;
box-shadow: 0px 0px 1px 1px white inset;
}
/*style button on hover*/
ul li ul li a:hover{
background-color: #999;
}
JSFiddle
I am having an issue with a sub menu. You can see at http://responsiveradio.radiobrandbuilders.com by hovering over the Home link.
The padding does not show up for the sub menu li a items but as soon as you hover over them the padding works.
I'm sure it is something simple I am overlooking but any help would be appreciated.
nav {
height: 60px;
}
nav ul {
list-style: none;
margin-top: 19px;
padding: 0;
}
nav li {
display: inline-block;
margin: 0;
position: relative;
}
nav li a {
color: #000;
font-size: 16px;
font-weight: 500;
padding: 15px;
text-transform: uppercase;
}
nav li:last-child {
margin-right: 0;
}
nav li a:hover {
color: #fff;
cursor: pointer;
}
.sub-menu {
display: none;
left: 0;
padding: 0;
position: absolute;
top: 10px;
width: 200px;
}
.sub-menu li {
display: block;
margin: 0;
padding: 0;
}
.sub-menu li a {
color: #fff;
width: 100%;
}
.sub-menu li a:hover {
background: #fff;
color: #000;
}
Changes in your css to be made... A tag is inline tag ...so you have to make is display block.
nav li a {
color: #000;
font-size: 16px;
font-weight: 500;
padding: 15px;
text-transform: uppercase;
display: block; /*changes done */
}
nav ul {
list-style: none;
padding: 0;
margin-top: 0; /*changes done */
}
.sub-menu{
display: none;
left: 0;
padding: 0;
position: absolute;
top: 52px; /*changes done */
width: 200px;
}
in css
.sub-menu li{
padding:15px;
}
In your css you set padding:0px;
modify your style like
.sub-menu li a {
color: #fff;
width: 100%;
display: inline-block;
}
.sub-menu li a{padding:0}
add this style and refresh your page.
I did the job by make the submenu functioning, the problem is I can't get the submenu width wider than its parent.
when i hover, its messed up as you can see in fiddle links i provided below
please take a look at this http://jsfiddle.net/wR5L5/
.navigation {
height: 35px;
background: #333;
}
.navigation ul {
margin: 0;
padding: 0;
}
.navigation ul li {
position: relative;
display: inline;
}
.navigation ul li a {
text-transform: uppercase;
color: #fff;
font-weight: 700;
line-height: 35px;
padding: 6px 8px;
text-shadow: 0px 0px 1px #ff170f;
}
.navigation ul li a:hover {
text-decoration: none;
color: #FF3E36;
border-bottom: 2px solid #FF3E36;
}
.navigation ul li:hover ul {
left: 0;
}
.navigation ul .sub {
position: absolute;
z-index: 9999;
left: -9999px;
font-size: 13px;
}
.navigation ul .sub li {
padding-top: -4px;
float: none;
background: #fff;
}
.navigation ul .sub li a {
text-shadow: none;
color: #333;
}
.navigation ul .sub li a:hover {
color: #ff3e36;
border-bottom: none;
text-shadow: none;
}
.navigation ul .sub li:hover {
background: #333;
}
there is a flexible menu .sub class http://jsfiddle.net/wR5L5/12/
.navigation {
height: 35px;
background: #333;
}
.navigation ul {
margin: 0;
position: relative;
padding: 0;
}
.navigation ul li {
display: inline;
position: relative;
}
.navigation ul li a {
text-transform: uppercase;
color: #fff;
font-weight: 700;
line-height: 35px;
padding: 6px 8px;
text-shadow: 0px 0px 1px #ff170f;
}
.navigation ul li a:hover {
text-decoration: none;
color: #FF3E36;
border-bottom: 2px solid #FF3E36;
}
.navigation ul li:hover ul {
left: 0;
}
.navigation ul .sub {
position: absolute;
z-index: 9999;
left: -9999px;
float: left;
width: auto;
min-width: 100%;
background: #999;
font-size: 13px;
}
.navigation ul .sub li {
padding-top: -4px;
float: none;
white-space: nowrap;
clear: both;
background: #fff;
}
.navigation ul .sub li a {
text-shadow: none;
color: #333;
display: block;
float: none;
width: 100%;
}
.navigation ul .sub li a:hover {
color: #ff3e36;
border-bottom: none;
text-shadow: none;
}
.navigation ul .sub li:hover {
background: #333;
}
Give width to the sub menu to get submenu wider than main menu.
.navigation ul .sub {
position: absolute;
z-index: 9999;
left: -9999px;
width: 150px;
font-size: 13px;
}