I've tried to padding-top on hover element ul#top li a but it fails to excute the code, maybe the inline-block display is bothering the padding to display but I dont know any other display to help him be inline and able him padding-top.
Incase my target is not understandable, I'm trying to padd "a" tag on hover to the top (about 5px padding).
Here is my CSS Code:
ul#top{
list-style: none;
}
ul#top li{
display: inline-block;
padding-right: 30px;
}
ul#top li a{
color: white;
text-decoration: none;
font-family: "Comic Sans MS", cursive, sans-serif;
-webkit-transition: color 0.5s ease-out;
-moz-transition: color 0.5s ease-out;
-o-transition: color 0.5s ease-out;
transition: color 0.5s ease-out;
}
ul#top li a:hover{
padding-top: 10px;
color: green;
}
My HTML:
<div class="header">
<div class="menu">
<ul id="top">
<li>Home</li>
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div>
</div>
How to enable padding-top in inline-block display? (The inline-block might not be the problem, but I think it is)
You can add bottom: 10px instead with position: relative. Also add padding-bottom for an issue on hover:
ul#top {
list-style: none;
}
ul#top li {
display: inline-block;
padding-right: 30px;
}
ul#top li a {
color: white;
text-decoration: none;
font-family:"Comic Sans MS", cursive, sans-serif;
-webkit-transition: color 0.5s ease-out;
-moz-transition: color 0.5s ease-out;
-o-transition: color 0.5s ease-out;
transition: color 0.5s ease-out;
}
ul#top li:hover a {
position: relative;
padding-bottom: 10px;/*Add padding bottom*/
color: green;
bottom: 10px;/*Add bottom 10px*/
}
body {
background: red;
}
<div class="header">
<div class="menu">
<ul id="top">
<li>Home
</li>
<li>test
</li>
<li>test
</li>
<li>test
</li>
<li>test
</li>
</ul>
</div>
</div>
Related
My page no longer applies the :hover effect to my .tabs li element, but I can't for the life of me figure out why. I commented out my jQuery script and it still won't work.
Here's a JSFiddle: https://jsfiddle.net/qpmg4wzq/
<div id="tabs-container">
<ul class="tabs">
<li class="tab current" data-tab="tab-1">tab 1</li>
<li class="tab" data-tab="tab-2">tab 2</li>
<li class="tab" data-tab="tab-3">tab 3</li>
<li class="tab" data-tab="tab-4">tab 4</li>
</ul>
</div>
#tabs-container {
float: left;
width: 100%;
overflow: hidden;
}
.tabs {
padding: 0px;
list-style: none;
clear: left;
float: left;
left: 50%;
}
.tabs li {
display: block;
float: left;
right: 50%;
margin: 0;
padding: 10px 20px 5px 20px;
cursor: pointer;
font-size: 1.1em;
line-height: 2em;
-webkit-transition: color .2s linear;
-moz-transition: color .2s linear;
-ms-transition: color .2s linear;
-o-transition: color .2s linear;
transition: color .2s linear;
-webkit-transition: background .2s linear;
-moz-transition: background .2s linear;
-ms-transition: background .2s linear;
-o-transition: background .2s linear;
transition: background .2s linear;
}
.tabs li:hover {
background: #88abc2!important;
}
.tabs li.current {
background: #d0e0eb;
color: #49708a;
}
.tab-content {
display: none;
padding: 15px;
line-height: 1.4;
}
.tab-content.current {
display: inherit;
}
Thanks.
Your .tab-content is overlapping the .tabs-container so any :hover action you make is actually registering as a hover on the .tab-content element.
A couple of options to solve this
Move the tab-content down using margin-top
.tab-content.current {
display: inherit;
margin-top: 60px;
}
Remove float: left from #tabs-container
I have a ul list with float:right for li.
I want to set this to center of page.
margin and left doesnt work well.
I want when mouse is over a link ,keep position of other link and dont move forward.
My css code is this:
#menu2 li a {
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#menu2 li a:hover {
border: none;
font-size: 30px;
}
<!--===============================================================<!--===============================================================--> --> ul,
li {
display: inline-block;
}
#menu2 ul {
list-style-type: none;
background-color: #003;
text-align: center;
}
#menu2 li {
float: left;
list-style-type: none;
padding: 15px 15px;
}
#menu2 {
min-width: 800px;
margin-top: 15%;
right: 65% !important;
}
#menu2 li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
background-color: #093;
transition: all 0.5s ease 0s;
font-size: 18px;
min-width: 95px;
border-radius: 50px;
}
<div align="center" style="height:100%;width:100%;">
<div class="menu" id="menu2" align="center">
<ul>
<li>Brands</li>
<li> Contact </li>
<li> Price List </li>
<li> About </li>
<li> Home </li>
</ul>
</div>
</div>
How can I solve this???
I use a:after but doesnt work.
I have added to your CSS, I Changed the hover text size to 25px and your button width to 135px and added in a whitespace:nowrap to the anchor tags.
what was happening is when you hover the text would grow and wrap because it could not fit into your containers, so i turned wrap off and also made the button containers width bigger to fit when enlarged
I hope this is what you are after as the buttons no longer move around the page when hovered on.
EDIT: Added CSS to your ul tag = float:left; so your buttons sit inside and achieve the dark blue background.
CSS
#menu2 li a {
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#menu2 li a:hover {
border:none;
font-size:25px; /*Changed by Steve */
}
<!-- ===============================================================
<!--=============================================================== -->
-->
ul,li
{
display:inline-block;
}
#menu2 ul
{
list-style-type: none;
background-color: #003;
text-align:center;
float:left;
}
#menu2 li {
float: left;
list-style-type:none;
padding:15px 15px;
}
#menu2
{
min-width:800px;
margin-top:15%;
right:65% !important;
}
#menu2 li a {
display: table-cell;
vertical-align:middle;
color: white;
text-align: center;
text-decoration: none;
background-color:#093;
transition: all 0.5s ease 0s;
font-size:18px;
min-width:95px;
width:135px; /*CHANGED by Steve*/
height:48.8px;
border-radius: 50px;
white-space:nowrap; /*ADDED by Steve */
}
By replacing the li with div and write CSS style with the following attributes and change CSS Codes for div the problem was solved.
Thanks all
<div align="center" style="height:100%;width:100%;">
<div class="menu" id="menu2" align="center" >
<div style="z-index:18;position:absolute;margin-right:25px;text-align:center;vertical-align:middle;" align="center" >Brands</div>
<div style="z-index:17;position:absolute;margin-right:155px;"> Contact </div>
<div style="z-index:16;position:absolute;margin-right:265px;"> Price List </div>
<div style="z-index:15;position:absolute;margin-right:405px;"> About </div>
<div style="z-index:14;position:absolute;margin-right:520px;"> Home </div>
</div>
</div>
I am creating a demo for my homework.
My navigation is not displaying correctly. I have been trying to fix the problem in many ways but none of them work.
demo
here is my demo
<body>
<div class="container">
<div class="content">
<div id="menu">
<ul class="parent-menu">
<li>
Home & Kitchen
<ul>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>
Electronics
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>
Clothing
<ul>
<li>item</li>
<li>item</li>
<
</ul>
</li>
<li>
Cars & Motorbikes
<ul>
<li>item</li>
<li>item</li>
<
</ul>
</li>
<li>
Books
<ul>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>
Support
<ul>
<li>
Contact Us
</li>
<li>
Forum
</li>
<li>Deliveries</li>
<li>T&C</li>
</ul>
</li>
</ul>
</div>
<!-----------Shorcut Panel Content--------->
<div class="shortcutpanel">
<div class="usergroup">
</div>
</div>
</div>
</body>
Here is my CSS code.
/* Basic Style */
html, body{
height:100%;
}
body {
background-color: grey;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
background-size:cover;
}
/*Global Setting*/
.hover{
float:left;
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
overflow: hidden;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: color, background-color;
transition-property: color, background-color;
}
.hover:active, .hover:hover, .hover:focus{
background-color: rgba(32, 152, 209, 0.5);
}
.container{
height:100%;
width:100%;
}
.content{
position:fixed;
top:10%;
left:0%;
height:90%;
width:100%;
}
/* NAVIGATION*/
p, ul, li, div, nav { padding:0; margin:0; }
#menu {
overflow: hidden;
position:fixed ;
left:0%;
top:20%;
z-index:999; }
.parent-menu {
background-color: #0c8fff;
width:180px; }
#menu ul {
list-style-type:none;
}
#menu ul li a {
padding:10px 15px;
display:block;
color:#fff;
text-decoration:none;
}
#menu ul li a:hover {
background-color:#007ee9;
}
#menu ul li:hover > ul {
left: 200px;
-webkit-transition: left 200ms ease-in;
-moz-transition: left 200ms ease-in;
-ms-transition: left 200ms ease-in;
transition: left 200ms ease-in;
}
#menu ul li > ul {
position: absolute;
background-color: #333;
top: 0;
left: -200px;
min-width: 200px;
z-index: 999;
height: 100%;
-webkit-transition: left 200ms ease-in;
-moz-transition: left 200ms ease-in;
-ms-transition: left 200ms ease-in;
transition: left 200ms ease-in;
}
#menu ul li > ul li a:hover {
background-color:#2e2e2e;
}
#menu ul li a:focus + ul {
left: 200px;
-webkit-transition: left 200ms ease-in;
-moz-transition: left 200ms ease-in;
-ms-transition: left 200ms ease-in;
transition: left 200ms ease-in;
}
/* Shortcut Panel Content */
.shortcutpanel{
position:relative;
left:10%;
top:5%;
height:90%;
width:30%;
float:left;
margin:0;
padding:0;
background-color:rgba(255,240,240,0.1);
}
Here this Demo,its the navigation effect that i want.
But however in my first demo.When you hover over the navi menu, the 2nd level menu will come out but display incorrectly. I don't know how to solve this.
Thanks for helps guys
If i get your question right.. U can do that by width animation..
And change :focus to :hover + ul
DEMO FIDDLE
#menu ul li:hover > ul {
left: 200px;
width: 200px;
}
#menu ul li > ul {
width: 0px;
}
#menu ul li a:hover + ul {
width: 200px;
-webkit-transition: width 300ms ease-in;
-moz-transition: width 300ms ease-in;
-ms-transition: width 300ms ease-in;
transition: width 300ms ease-in;
}
Hope it helps..
I'm trying to get rid of the flickering I'm getting after I added negative top margin (so that it would be visible above my navbar) to my < li > item. Here's the JSFiddle's link: http://fiddle.jshell.net/xv6mk/.
And the code just in case.
HTML:
<ul>
<li>Main</li>
<li>Subpage 1</li>
<li>Subpage 2</li>
<li>Subpage 3</li>
<li>About</li>
</ul>
And CSS:
ul {
display: inline;
list-style: none;
}
li {
font-size: 16px;
display: inline-block;
margin-right: -6px;
padding: 16px;
cursor: pointer;
display:inline-block;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
li:hover {
background: white;
color: #74DF00;
border-top: 10px solid #525458;
margin-top: -10px;
}
I will really appreciate help :) .
EDIT: Adding this 2 lines to < li > item (not only hover) works like charm. Thank you :) .
border-top: 10px solid #848484;
margin-top: -10px;
The problem is the transition property, you are transitioning everything, try the following:
transition-property: color, border-top, background;
Just add the prefixes for cross browser support.
Fiddle: http://fiddle.jshell.net/xv6mk/3/
Problem
I created a drop-down menu done purely with CSS, using an absolute positioning method shown via a tutorial. Works great. In Safari, it's slow, laggy, and the links are spaced out.
This drop-down menu works perfectly in all browsers other than Safari.
Why?
<ul id="nav">
<li>
Home
<ul>
<li>About Us</li>
<li>Contact Us</li>
<li>Managed Services</li>
</ul>
</li>
<li>
Computer
<ul>
<li>Malware Removal</li>
<li>Diagnostic</li>
<li>Backup & Restore</li>
<li>Data Recovery</li>
<li>Phone Accessories</li>
</ul>
</li>
<li>
Security
<ul>
<li>Surveillance</li>
<li>Security Systems</li>
</ul>
</li>
<li>
Home Automation
<ul>
<li>HAI</li>
<li>RTI</li>
</ul>
</li>
<li>
Home Audio / Video
<ul>
<li>TV Installation</li>
<li>Wall Mounting</li>
<li>Sound Systems</li>
<li>Home Theater</li>
<li>Munitio Earphones</li>
</ul>
</li>
</ul>
CSS
/* Header */
#nav {
margin-left: 9%;
list-style: none;
font-weight: bold;
margin-bottom: 10px;
margin-top: 40px; /* Clear floats */
float: left;
width: 90%; /* Bring the nav above everything else--uncomment if needed.
position: relative;
*/
z-index: 5;
}
#nav li {
float: left;
margin-right: 2%;
}
#nav a {
display: block;
padding: 5px;
color: black;
background: none;
text-decoration: none;
font-size: 14px;
-webkit-transition: color 0.2s, text-shadow 0.3s;
-moz-transition: color 0.2s, text-shadow 0.3s;
-o-transition: color 0.2s, text-shadow 0.3s;
-ms-transition: color 0.2s, text-shadow 0.3s;
transition: color 0.2s, text-shadow 0.3s;
}
#nav a:hover {
color: white;
background: none;
text-decoration: none;
text-shadow: 0px 0px 3px #000;
}
/*---DROPDOWN ---*/
#nav ul {
z-index: 5;
background: none; /* Adding a background makes the dropdown work properly in IE7+. Make this as close to your page's background as possible (i.e. white page == white background). */
background: rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style: none;
width: 0px;
overflow: hidden;
color:white;
left: -9999px; /* Hide off-screen when not needed (this is more accessible than display: none;
*/
-webkit-transition: color 0.2s, text-shadow 0.3s;
-moz-transition: color 0.2s, text-shadow 0.3s;
-o-transition: color 0.2s, text-shadow 0.3s;
-ms-transition: color 0.2s, text-shadow 0.3s;
transition: color 0.2s, text-shadow 0.3s;
}
#nav ul li {
padding-top: 1px; /* Introducing a padding between the li and the a give the illusion spaced items */
color:white;
float: none;
}
#nav ul a {
white-space: nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#nav li:hover ul {
/* Display the dropdown on hover */
left: 0; /* Bring back on-screen when needed */
overflow: hidden;
width: 150px;
-webkit-transition: width 0.2s;
-moz-transition: width 0.2s;
-o-transition: width 0.2s;
-ms-transition: width 0.2s;
transition: width 0.2s;
}
#nav li:hover a {
/* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background: none;
margin-right: -10px;
text-decoration: none;
-webkit-transition: margin-right 1s;
-moz-transition: margin-right 1s;
-o-transition: margin-right 1s;
-ms-transition: margin-right 1s;
transition: margin-right 1s;
}
#nav li:hover ul a {
/* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration: none;
width: 120px;
}
#nav li:hover ul li a:hover {
/* Here we define the most explicit hover states--what happens when you hover each individual link. */
background: #333;
width: 150px;
}
Include the attribute onClick=”return true” inside the major <li> tags, like this:
<li onClick="return true">
Security
<ul>
<li>Surveillance</li>
<li>Security Systems</li>
</ul>
</li>
I hope this helps you.
Regards