I'm working on a new design for my website to see what I like (touch and feel).
My top navigation bar is great so far, except for this issue.
When you hover over the links with just text, everything is fine.
Top-padding is added to make it look like the navigation tabs "move"/"grow".
However, when I hover over a navigation link with one of my images (Paypal, Twitter, YouTube) in it, the top-padding is applied, but it affects the position of the main parent element. This is in the latest version of Chrome and Firefox for Windows 7.
BODY is not the affected parent, but #main (as defined in my CSS) "moves"/"grows" as well.
The URL is http://rickyyoder.x10.mx/new/ and here is the code:
#main{
width:94%;
max-width:880px;
margin:12px auto;
background:#fff;
box-shadow:1px 1px 4px #000;
border-radius:4px;
padding:2px 2px 8px 2px;
}
#nav{
position:relative;
top:-0.8em;
background:#fff;
border-radius:4px;
padding:2px;
display:inline-block;
}
#nav a{
color:#000;
display:inline-block;
padding:1px 1em 1px 1em;
border-radius:0 0 4px 4px;
box-shadow:0px 2px 2px -2px #fff inset, 0px -4px 16px -6px #aaa inset;
-webkit-transition:background 0.5s, padding-top 0.25s;
-moz-transition:background 0.5s, padding-top 0.25s;
vertical-align:top;
}
#nav a:hover{
padding-top:4px;
background:#eee;
}
#nav a:hover img{
-webkit-transition:-webkit-filter 1.5s;
}
#nav a:hover img{
-webkit-filter:hue-rotate(360deg);
}
Is there any way I can avoid this, but still have a "moving"/"growing" effect on these links as well as the textual links?
Thanks in advance.
You can solve the problem adding height to the nav
#nav {
position: relative;
top: -0.8em;
background: #fff;
border-radius: 4px;
padding: 2px;
display: inline-block;
height: 50px;
}
Related
I am working on our restaurant web and I am trying something new for showing the menu. I use hover to show a bigger image when hovering over a thumbnail. I am satisfied with the layout and functionality but I am concerned about load time when all menu items are up.
The problem I see is that all pictures are loaded when the page are loaded and just made invisible until you hover the thumbnail. I don't want to use JS because I don't want real popups that can be blocked.
Is there any other way to get the same effect with puse css?
Page is here http://www.thejunctioncafe-paphos.com/menu_junction_cafe.html
The CSS
ul.enlarge{
list-style-type:none;
margin-left:0px;
width: 700px;
margin:auto;
}
ul.enlarge li{
display:inline-block;
position: relative;
z-index: 0; /
margin:10px 10px 0 10px;
}
ul.enlarge img{
background-color:#eae9d4;
padding: 6px;
-webkit-box-shadow: 0 0 6px rgba(132, 132, 132, .75);
-moz-box-shadow: 0 0 6px rgba(132, 132, 132, .75);
box-shadow: 0 0 6px rgba(132, 132, 132, .75);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
ul.enlarge span{
position:absolute;
left: -3999px;
background-color:#eae9d4;
padding: 10px;
font-family: 'Calibri', sans-serif;
font-size:.9em;
text-align: center;
color: #000;
-webkit-box-shadow: 0 0 20px rgba(0,0,0, .75));
-moz-box-shadow: 0 0 20px rgba(0,0,0, .75);
box-shadow: 0 0 20px rgba(0,0,0, .75);
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius:8px;
}
ul.enlarge li:hover{
z-index: 50;
cursor:pointer;
}
ul.enlarge span img{
padding:2px;
background:#ccc;
}
ul.enlarge li:hover span{
top: -350px; /*the distance from the bottom of the thumbnail to the top of the popup image*/
left: -20px; /*distance from the left of the thumbnail to the left of the popup image*/
}
ul.enlarge li:hover:nth-child(2) span{
left: -100px;
}
ul.enlarge li:hover:nth-child(3) span{
left: -200px;
}
ul.enlarge img, ul.enlarge span{
behavior: url(scripts/PIE.htc);
}
Popups are blocked when you use javascript to create the popup, not load the images. So just load the images with javascript after the page is complete. Then let your images popup as you have them now.
If you want to do it even better, load the image when the user hovers over a thumbnail in the pre-assumption he will click on it.
i suggest you leave it the way you have them because, as far as i can see, they are small images and will not affect the load time.
but with only CSS you could do something like this :
.menu-item:hover .more {
display:block;
background:url("http://www.thejunctioncafe-paphos.com/images/Breakfast-Roll.png") no-repeat scroll left top;
position:absolute;
height:100%;
width:100%;
top:0%;
}
.more {
display:none;
}
.menu-item {
width:200px;
height:200px;
}
<div class="menu-item">
<img src="http://www.thejunctioncafe-paphos.com/images/Breakfast-Roll_th.png" width="100" height="67" alt="Breakfast Roll">
<span class="more">MORE TEXT</span>
</div>
in this way the big image is loaded only after the :hover event on .menu-item and you can style it how you want. but you would have to write css ( background-image ) for all the .menu-items
I will refer to this screenshot in my explanation:
I have set up tabs like you see in the picture. I wanted the active tab (home in the picture) to have a 1px black line under it, so I used bottom-border. However, it's difficult to see but the pink-ish background extends for that entire row. I would like the pink to stop drawing at the bottom of a tab, excluding a border if there is one (so just 1px above the bottom).
.main_tabs{
width:100%;
display:inline-block;
background:#FFDEFD;
}
li.active a, li.active{
background:#fff;
color:#4c4c4c;
border-radius: 3px 3px 0px 0px;
border-bottom-color:#000000;
border-bottom-width:1px;
border-bottom-style:solid;
transition:all linear 0.4s;
}
Above is my CSS for main_tabs (which is responsible for that pink background) and the active tab. In main_tabs, I have tried playing around with background-size but it didn't change anything. I tried to fiddle with width and display, but it messed up my tabs entirely.
.main_tabs {
background: #FFDEFD;
list-style: none;
margin: 0;
padding: .25em .5em 0;
}
.main_tabs li {
display: inline-block;
}
.main_tabs a {
display: block;
text-decoration: none;
line-height: 2em;
padding: 0 .5em;
background: #DDD;
border-radius: 3px 3px 0px 0px;
border-bottom: 1px solid transparent;
transition: all linear 0.4s;
}
.main_tabs .active a {
background: #fff;
color: #4c4c4c;
border-bottom-color: black;
}
<ul class=main_tabs>
<li><a href=#>Non active</a></li>
<li class=active><a>Active</a></li>
</ul>
Your border is added in original height of <li> that why it appears like this.
Use css property box-sizing:border-box to merge it in original height.
li.active a, li.active{
background:#fff;
color:#4c4c4c;
box-sizing:border-box;
border-radius: 3px 3px 0px 0px;
border-bottom-color:#000000;
border-bottom-width:1px;
border-bottom-style:solid;
transition:all linear 0.4s;
}
I have one problem with my CSS code.
The problem is active link sliding down.
This is my DEMO page link from codepen .
If you check my DEMO page then you see blue border color active links. I want that links come on the al the images. But now 5,6,7 numbers picture active link blue border sliding down. What can i do here anyone can help me?
.slider-control-nav a {
display: inline-block;
width: 96px;
height: 71px;
float:left;
border-radius:3px;
-webkit-border-radius:3px;
-moz-border-radius:3px;
-o-border-radius:3px;
text-indent: -9999px;
margin-left:16px;
margin-top:5px;
}
.slider-control-nav a.active {
border:2px solid #3978f5;
opacity:1;
box-shadow:inset 0px 0px 10px 3px #777777;
-moz-box-shadow:inset 0px 0px 10px 3px #777777;
-webkit-box-shadow:inset 0px 0px 10px 3px #777777;
width: 97px;
height: 72px;
}
.imgtmb img {
width:97px;
height:auto;
border-radius:3px;
-webkit-border-radis:3px;
-o-border-radius:3px;
-moz-border-radius:3px;
}
.imgtmb {
float: left;
width: 97px;
height: 72px;
margin-left: 16px;
margin-top: 6px;
}
Move slider-control-nav section from within img_tb and place it above.
Increase .container's width to not force the images below
The full source can be viewed at:
www.anthonysusedcars.com
Chrome Status: Works!
Safari Status: Broken!
Firefox Status: Untested
Question:
What is causing this webpage to break within Safari, while Chrome renders it fine? Can anyone figure out a quick fix?
Note: there is a bug in Chrome, where if you hover over the left-most, non selected, nav tab, the whole page is thrown into disarray. Ignore this for now.
Supporting Details [Extra]
Google Chrome shows this page with an interesting effect that I stumble upon by accident with basic CSS3. The navigation tab pulls down while pulling the upper header and lower content downward with it, but the rest of the navigation tabs stay in place.
It threw me off when I looked at the site in Safari, expecting seamless webkit compatibility, to find a very broken page. I then read about Chrome's recent change to Blink. So, scrap the chanced-upon feature and go with something easier to replicate cross-browser, right?
Well... My boss likes the feature the way that it's seen in Chrome, and wants me to fix it up to work cross-browser. And that's that. I've failed to fix the issue thus far, so i'm turning to the experts!
I'm focusing here on simply Webkit - Blink compatibility. The solution to this problem needs to solve both the broken position, and keep the movement functionality.
HTML Markup [Simplified]
<!DOCTYPE html>
<html>
<head>
... Content ...
</head>
<body>
<div class="wrapper"><!-- begin wrapper -->
<div class="frame_anchor"><!-- begin frame anchor -->
<div class="header_frame"><!-- begin header frame -->
<div class="nav_bar"><!-- begin header nav bar -->
<a id="selected" href="index.php">
Home
</a>
<a href="car1.php">
Dodge Avenger
</a>
<a href="car2.php">
Jeep Grand Cherokee
</a>
<a href="car3.php">
Chevy Suburban
</a>
<a href="contact.php">
Contact Us
</a>
</div><!-- end head nav bar -->
</div><!-- end header frame -->
</div><!-- end frame anchor -->
<div class="body_center"><!-- begin body center -->
<div class="header"><!-- begin header -->
<div class="header_image"><!-- begin header image -->
<div class="header_title_strip"><!-- begin header title strip -->
<p class="title">
ANTHONY'S AUTO
</p>
<p class="subtitle">
USED CARS AT GREAT PRICES
</p>
<p class="contact_title">
Cell: (318) 332 2031
</p>
</div><!-- end header title strip -->
</div><!-- end header image -->
</div><!-- end header -->
<div class="body"><!-- begin body -->
<div class="body_head_spacer"><!-- begin spacer -->
</div><!-- end spacer -->
<div class="module_title">
<p>
ABOUT US
</p>
</div>
<div class="body_desc"><!-- begin body description -->
<p>
We sell nice, clean cars in good condition, ready for the highway.
</p>
</div><!-- end body description -->
... Content ...
<div class="footer"><!-- begin footer -->
... Content ...
</div><!-- end footer -->
</div><!-- end body center -->
</div><!-- end wrapper -->
</body>
</html>
CSS: [Gradients Removed]
#import url(http://fonts.googleapis.com/css?family=Orbitron:400,700);
body
{
font-family:Arial;
... cross-browser gradient bg ...
}
a:link, a:visited, a:active, a:hover
{
}
p
{
}
div
{
}
.wrapper
{
margin:0px;
padding:0px;
width:100%;
min-height:800px;
}
.body_center
{
overflow:hidden;
transition:min-height 1s;
... cross-browser gradient bg ...
width:800px;
min-height:800px;
margin-left:auto;
margin-right:auto;
-webkit-box-shadow: 7px 7px 5px #000;
-moz-box-shadow: 7px 7px 5px #000;
box-shadow: 0px 0px 80px 7px #000;
padding:0px 0px 0px 0px;
}
.header_image
{
-moz-transition:min-height 1s, background-size 1s;
transition:min-height 1s, background-size 1s;
z-index:2;
background-position:65% 0%;
background-size:100% 160%;
background-repeat:no-repeat;
background-image:url('images/head.png');
position:absolute;
max-height:300px;
min-height:300px;
width:800px;
margin-top:-250px;
-webkit-box-shadow: 0px 0px 30px #000;
-moz-box-shadow: 0px 0px 30px #000;
box-shadow: 0px 0px 30px #000;
}
.header_title_strip
{
z-index:2;
opacity:1;
position:absolute;
padding:0px;
width:100%;
height:100px;
... cross-browser gradient bg ...
transition:opacity 2s, height 2s;
-moz-transition:opacity 2s, height 2s;
}
.contact_title
{
float:right;
color:#ffbb28;
margin-right:20px;
font-family: 'Orbitron', sans-serif;
}
.header_title_strip:hover
{
opacity:1;
height:120px;
}
.title span
{
float:left;
display:block;
width:30px;
/* -webkit-transform:rotate(0deg); */
transition:/*-webkit-transform 0.1s,*/ color 0.5s, text-shadow 0.3s;
text-shadow: 4px 4px 4px #000;
}
.title span:hover
{
/* -webkit-transform:rotateY(180deg);
color:#2580be;
*/
text-shadow: 5px 5px 7px #000;
}
.space
{
float:left;
width:20px;
overflow:hidden;
opacity:0;
}
.title
{
position:absolute;
word-spacing:-8px;
top:-15px;
padding:0px 0px 0px 10px;
font-size:35px;
color:white;
font-family: 'Orbitron', sans-serif;
}
.subtitle
{
position:absolute;
margin:55px 0px 0px 10px;
font-size:18px;
color:#ffb400;
font-family: 'Orbitron', sans-serif;
}
.frame_anchor
{
width:800px;
height:20px;
margin-left:auto;
margin-right:auto;
}
.header_frame
{
-webkit-box-shadow: 0px 0px 30px #000;
-moz-box-shadow: 0px 0px 30px #000;
box-shadow: 0px 0px 30px #000;
transition:height 1s;
position:relative;
margin-left:-20px;
top:90px;
z-index:0;
padding:0px 20px 0px 20px;
width:800px;
height:250px;
... cross-browser gradient bg ...
opacity:.77;
}
.nav_bar
{
transition:margin 1s;
padding:210px 0px 0px 0px;
width:100%;
height:70px;
position:relative;
z-index:2;
}
.nav_bar a:link, .nav_bar a:active, .nav_bar a:visited
{
margin-top:0px;
-webkit-box-shadow: 0px 0px 5px #000;
-moz-box-shadow: 0px 0px 5px #000;
box-shadow: 0px 0px 5px #000;
float:left;
text-decoration:none;
color:black;
display:block;
height:30px;
font-weight:bold;
font-size:12px;
margin:0px 0px 0px 20px;
padding:15px 10px 0px 10px;
text-align:center;
... cross-browser gradient bg ...
border-style: inset;
border-width:0px;
opacity:1;
-moz-transition:opacity 0.1s, box-shadow 0.2s, margin-top 0.2s, padding-top 0.2s;
transition:opacity 0.1s, box-shadow 0.2s, margin-top 0.2s, padding-top 0.2s;
border-radius:0px 0px 5px 5px;
}
#selected
{
... cross-browser gradient bg ...
}
#selected:hover
{
padding-top:15px;
}
.nav_bar a:hover
{
padding-top:20px;
opacity:1;
-moz-box-shadow: 0px 0px 5px #000;
box-shadow: 0px -5px 20px #000;
}
.body_head_spacer
{
transition:min-height 1s;
min-height:105px;
}
.body_desc
{
-webkit-box-shadow: 250px -30px 70px -40px#000;
-moz-box-shadow: 250px -30px 70px -40px#000;
box-shadow: 250px -30px 70px -40px#000;
-moz-transition:min-height 1s;
transition:min-height 1s;
position:relative;
top:0px;
z-index:0;
padding:5px;
width:790px;
min-height:250px;
... cross-browser gradient bg ...
opacity:.77;
margin-top:0px;
}
.body_desc p
{
padding:5px;
margin:0px;
background-color:white;
min-height:20px;
text-align:center;
}
.body_module
{
-webkit-box-shadow: 250px -30px 70px -40px#000;
-moz-box-shadow: 250px -30px 70px -40px#000;
box-shadow: 250px -30px 70px -40px#000;
-moz-transition:min-height 1s;
transition:min-height 1s;
position:relative;
margin-top:0px;
top:0px;
z-index:0;
padding:5px 5px 5px 5px;
width:790px;
min-height:180px;
... cross-browser gradient bg ...
opacity:.77;
}
.footer
{
-webkit-box-shadow: 0px 0px 30px #000;
-moz-box-shadow: 0px 0px 30px #000;
box-shadow: 0px 0px 30px #000;
-moz-transition:min-height 1s;
transition:min-height 1s;
margin-top:30px;
top:0px;
z-index:0;
width:800px;
min-height:70px;
... cross-browser gradient bg ...
opacity:.77;
}
.footer p
{
padding:25px 10px 10px 10px;
min-height:20px;
text-align:center;
color:white;
}
.module_title p
{
margin:0px;
padding:10px 5px 5px 0px;
min-height:20px;
}
.module_title
{
-webkit-box-shadow: 0px 0px 30px #000;
-moz-box-shadow: 0px 0px 30px #000;
box-shadow: 0px 0px 30px #000;
font-family: 'Orbitron', sans-serif;
font-weight:bold;
color:#2454e5;
transition:height 1s;
position:relative;
z-index:0;
text-align:center;
margin-top:20px;
padding:5px 5px 5px 5px;
width:25%;
min-height:35px;
... cross-browser gradient bg ...
opacity:.77;
border-radius:0px 170px 0px 0px;
}
Ok, as Venom said above, I ended up being forced to removed the hover movement effect. THere seemed to be no other solution. Thanks!
So I have an image inside a div that is centered in an outer-wrapper. I have a horizontal menu at the top of the wrapper that displays 5 sub divs inline. I have added css for a drop down menu that appears when you hover over the first of the 5 inline sub divs. When the drop down menu appears, it causes the image to shift to the right and I can't for the life of me figure out how to correct it. As you can see I have played around with z-index but i'm not sure if I understand what is happening or not happening with z-index and how it is used correctly.
HTML:
<div class="wrapper">
<div id="topmenu">
<div id="home">Home
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
</div>
<div id="logo">
<img src="image.jpeg" />
</div>
</div>
CSS
.wrapper{
position:relative;
width:960px;
height:905px;
margin-top:5px;
margin-left:auto;
margin-right:auto;
/*text-align:left;
border:2px solid red;*/
background-color:#FFFFFF;
}
#topmenu{
position:relative;
border-bottom:2px solid #164207;
height:30px;
background-color:#ffffff;
z-index:3;
}
#logo{
position:relative;
border-bottom:2px solid #164207;
}
#logo img{
position:relative;
height:350px;
width:500px;
z-index:1;
}
#home{
display:inline-block;
float:left;
margin-top:5px;
margin-left:15px;
width:169px;
color:#164207;
font-family:serif;
font-weight:bold;
font-size:20px;
text-align:center;
border-right:2px solid #164207;
}
#home:hover .sub-menu {display:inline-block;}
.sub-menu {
overflow:hidden;
display: none;
width: 169px;
background-color: #164207;
color:#FFFFFF;
margin-top: 5px;
border: 1px solid #fff;
-webkit-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
-moz-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
}
.sub-menu li {
position:relative;
list-style-type: none;
display: block;
border-bottom: 1px solid #FFFFFF /*#eaeaea*/;
font-family:serif;
font-size: 12px;
height: 15px;
padding: 8px 0;
}
You need to add position: absolute; to .sub-menu to create a stacking context.
jsFiddle
#home{
display:block;
float:left;
margin-top:5px;
width:184px;
color:#164207;
font-family:serif;
font-weight:bold;
font-size:20px;
text-align:center;
border-right:2px solid #164207;
}
#home:hover .sub-menu {display:block;}
#course:hover .sub-menu{display:block;}
#leagues:hover .sub-menu{display:block;}
#events:hover .sub-menu{display:block;}
#about:hover .sub-menu{display:block;}
.sub-menu {
overflow:hidden;
display: none;
width: 182px;
background-color: #164207;
color:#FFFFFF;
/*padding: 10px 10px;
margin-left: 0px;*/
margin-top: 5px;
border: 1px solid #fff;
-webkit-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
-moz-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
position:absolute; /**************************** Important Bit*/
top:24px;
}
To re-adjust alignment- Remove margin-left:15px; from #home, #course, #leagues, #events, and #about and adjust widths on all of them. Then adjust the width of .sub-menu. See updated jsFiddle above for details and working model.
Example with navigation set up in <ul> unordered list </ul>. - Don't Need all the id's and resulting redundant CSS.