Creatng a navigation bar with illusion of a following selector - html

I'm working on a project of mine and I've got a relatively interesting idea that would look pretty nice, only issue is, I can't really figure out how to pull it off.
here's the deal. I've got my navigation bar set up and it looks something like this
Now for illustration purposes i've margined the small arrow under it. As in now, it's only a lone <img> placed under the navbar and margin applied to it to make it look like it's under it.
Basically what I'm trying to accomplish is, whenever you hover over a certain part of the navigation bar, the arrow will move under it. For sake of simplicity and readability of this post, let's not discuss any animations and smoothness, literally all I want is for the arrow to disappear from the original position and re-appear under the desired (hovered-over) location.
Any suggestions what would be the best (and easiest) way to pull this off?
Ideally I'd prefer usage of HTML/CSS only.
Probably only solution I came to so far is creating a separate arrow for each item inside the navigation bar.
Set it to
.nav img {
display: inline-block;
visbility: hidden;
}
And then create
.nav img:hover {
visiblity: visible;
}
Now there's multiple issues with this.
1) This would mean, people would need to hover on the arrows under it, intead of the actual navbar items for them to appear.
2) I would need to manually margin each and every arrow for them to fit under every single menu item.
3) While this would work on my screen, if you switch to any different resolution, the margin would be off for them.
I'm interested to hear, if you guys have any suggestions.
EDIT: I actually figured out a solution, that I can simply create a dropdown menu (another ul) and just put image there. Though if you still have any more intuitive and better working solutions, I'll be happy to view them.

If I understand your question correctly you can achieve this by doing the following without any images. I have added the class of active and given this a unique color to show what page you are currently viewing and then the hover effect will follow in a different color. The selector will be a psuedo element with pure css triangle and will show on hover.
Here is a fiddle to show you this in action Fiddle
And the markup:
<nav>
<ul>
<li><a class="active" href="#">Link</a></li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</nav>
and the css like this:
nav{
text-align: center;
background: #000;
}
nav ul{
list-style-type: none;
padding: 0;
margin:0;
}
nav li{
display:inline-block;
position: relative
}
nav li a{
color: #fff;
padding: 10px;
display: inline-block;
text-decoration: none;
}
nav li a:before{
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid rgba(200,200,200,1);
position: absolute;
bottom:-20px;
left:0;right: 0;
margin: 0 auto;
content:'';
opacity: 0;
-ms-transition: opacity 300ms ease-in-out;
-moz-transition: opacity 300ms ease-in-out;
-webkit-transition: opacity 300ms ease-in-out;
-o-transition: opacity 300ms ease-in-out;
transition: opacity 300ms ease-in-out;
}
nav li a.active:before{
opacity: 1;
border-top: 20px solid red;
}
nav li a:hover:before{
opacity: 1;
}

Related

pointer-events + opacity on hover css

I'm building a site where a seperate div is on top of another. When you hover over the top div I want it to disapear while you hover over it and you should be able to click it.
I at first thought that
opacity: 0;
and
pointer-evets: none;
would do the trick, however, with only opcaity 0; you can't click though the div, and with the pointer-events: none; it doesn't fade.
Anyone got a solution to this?
If a div is on top of another div, it will catch all of the events, even if it's at opacity:0.
You could try visibility:hidden instead, since AFAIR this actually removes a div from the layout.
EDIT: "remove from the layout" was a poor choice of words. The commenters are of course right, it's still there.
You can try like this:
$(function () {
$(".parent").click(function () {
alert("I am in Parent");
});
$(".child").click(function (e) {
alert("I am in Child");
});
});
* {font-family: 'Segoe UI';}
.parent {border: 1px solid #ccc; position: relative; padding: 50px;}
.parent .child {border: 1px solid #ccf; padding: 15px; position: absolute; left: 10px; top: 10px; -webkit-transition: all 0.5s linear; -o-transition: all 0.5s linear; transition: all 0.5s linear;}
.child:hover {opacity: 0;}
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<div class="parent">
<div class="child"></div>
</div>
<p>Please try clicking on both the boxes. One is parent and the other is child. The child will be clickable even though it is hidden.</p>
Please try clicking on both the boxes. One is parent and the other is child. The child will be clickable even though it is hidden.
Try opacity: 0.001;.
It visually brings the exact same result than opacity:0; and has helped me short out similar situations where pointer-events: none; didn't work either.

Hiding an element after transition using CSS only

I have been trying to design a login form and the button requires a little transition effect. There is one complexity though.
Background: I originally copied this idea from here: original form.
Notice how there is no padding (left and right) on the main container, now in my demo it was critical to have padding left and this creates a problem (will explain further).
Now here's my demo:
My version of login form (don't be scared of the 108 lines of CSS code; I'll paste the code that pertains to my problem below).
So the code that's relevant to this problem is as follows.
The HTML code:
<button class="login-button"><span>SEND</span></button>
The CSS code:
.login-button{
width: 100%;
outline: none;
border:none;
cursor: pointer;
padding: 0;
margin:0;
transition:.3s;
}
.login-input , .login-button{
height: 50px;
line-height: 40px;
transition:.3s;
}
.login-button span{
display: block;
background:red;
height: 100%;
width: 100%;
left: 0;
transition:.3s;
position: relative;
}
.login-button span:before{
content: 'ok';
position: absolute;
left: 100%;
display: block;
}
.login-button:hover span:before{
content: 'OK To go now';
position: absolute;
/*left: 0%;*/
text-align: center;
display: block;
width: 100%;
height: 100%;
}
Now if I go to the CSS styling for the main container:
I.E.
.main-login{
min-width: 200px;
max-width: 400px;
background: #533e69;
margin: 100px auto;
text-align: center;
overflow: hidden;
box-shadow: 1px 1px 10px rgba(0,0,0,.2);
padding: 0 20px;
}
and take off the padding, then the problem is solved and the transition looks perfect.
The problem
My requirements are such that I need that padding, so now what happens is when you hover over the button and the span element moves left:-100%, it's still visible in the main container.
Proposed solution
I would like it if this problem can be solved in CSS only as I don't really like cluttering my doc's with JS. So how about this.
I am new to CSS, so my solution may be less elegant:
When hovered over the button, the span overs left:-100% and than if the span can be set to display:none. Sounds simple, but my limited knowledge of CSS has got me stuck here.
You need to set the background to be transparent. It's not possible for a transition to animate the display property.
Add this css code, and it should work:
.login-button:hover span{
-webkit-transition-delay: 1s; /* Safari */
transition-delay: 1s;
transition: 2s;
background: rgba(1,1,1,0);
}
See your updated fiddle here.
Edit: I cleaned up the css a bit:
.login-button:hover span{
transition: 0.3s;
background: transparent;
}
Fiddle is here.
Transition properties are comma delimited in all browsers that support transitions:
.nav a {
-webkit-transition: color .2s, text-shadow .2s;
/* And so on... */
}
Ease is the default, so you don't have to specify it. If you really want linear, you will need to specify it, i.e. -webkit-transition: color .2s linear, text-shadow .2s linear;
Or try this
transition-property: width;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 2s;
This is the link

Hover one div make another div appear

Here is the site I'm working on: revistapuerto
It's a Wordpress based site. What I'm trying to achieve through CSS, is to get the excerpt to appear over the picture when you hover over the Title of the post. Right now, the excerpt appears when you hover over the picture only. Want to keep that effect, and add the Title thing.
The picture - excerpt effect I got it from another user here, and here is the CSS in case it helps:
#magia {
position: relative;
}
#magia img {
display: block;
}
#magia .cornerLink {
width:494px;
height:330px;
opacity: 0;
position: absolute;
top: 32px;
left: 0px;
right: 0px;
padding: 0px 0px;
background-color: rgba(0,0,0,0.50);
text-decoration: none;
text-align: center;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
#magia:hover .cornerLink {
opacity: 1.0;
}
Thanks!
Honestly the question isn't very clear, you're gonna need to give more information. All I can really offer in regards to what you've asked is basic fiddle: http://jsfiddle.net/MBLZx/
HTML:
<div class="showhim">HOVER ME
<div class="showme">hai</div>
<div class="ok">ok</div>
</div>
CSS:
.showme{
display: none;
}
.showhim:hover .showme{
display : block;
}
.showhim:hover .ok{
display : none;
}
(also the website won't load for me, could just be my work computer!)
that shows how to use hidden divs to make divs appear using a hover.
More information and I might be able to help you out :)
If I understood what you want, here's how you can achieve it.
#div-for-hover:hover #Div-you-want-to-show {
display: block;
}
The method is simple: The block of CSS code simply says when you hover of #div-for-hover, I'll show #Div-you-want-to-show
Note: The hover could be on a headings, DIVs, images, and more.

CSS3 Transition Slide Down Element

I'm trying to recreate a similar menu effect found on the World War Z movie site, but I can't seem get the CSS transition working correctly. I've gotten the hover element to display the hidden block, but the CSS transition wont work. I'm trying to get a cool effect that would slide from the top or bottom, I don't have a specific preference. Also if I try to go over any of the links, the submenu disappears before I can click on it. Here's the Fiddle.
HTML:
<ul id="menutitle">Menu Title</ul>
<ul id="submenu">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</nav>
CSS:
#topmenu {
background: #000;
width: 150px;
height: 50px;
color: #fff;
}
#submenu {
display: block;
position: absolute;
width: 110px;
display: none;
background: #333;
list-style: none;
line-height: 2em;
}
#menutitle:hover + #submenu {
display: block;
-webkit-transition: height 1s ease;
-moz-transition: ease-in 2s none;
-ms-transition: ease-in 2s none;
-o-transition: ease-in 2s none;
transition: ease-in 2s none;
}
#menutitle { color: #ff0000; }
a { color: #FF0; }
A few things:
Your :hover selector should be on the #topmenu element, not the title. That's why the nav area is disappearing so suddenly - it only takes hovering on the menu text.
You might have a little misconception of the animate property definition. You need to pick a specific property to animate; usually something like 'height'. In this case, my solution was to set "max-height". There may be some way of setting height to something like 'auto', but if so it's lost on me.
Additionally, the "transition" property is set on the object at all times - not just 'when hovering'. It's a sort of constant state to indicate "WHEN this property changes, do a smooth transition". That way, you can have a series of different states giving different heights.
http://jsfiddle.net/8YHbq/4/
#topmenu {background: #000; width: 150px; height: 50px; color: #fff; }
#submenu {display: block;
position: absolute;
width: 110px;
background: #333;
list-style: none;
line-height: 2em;
overflow: hidden;
max-height:0;
transition: max-height 0.7s ease-in;
}
#topmenu:hover #submenu {
max-height: 200px;}
#menutitle {color: #ff0000;}
a {color: #FF0}
Currently, the one issue with my version that I'm just now realizing is that since max height animates to 200px, the nav menu will be fully expanded before it reaches 200 - making the animation less smooth. Maybe you could adjust that a bit based on your needs.

How to create an interactive circular links using CSS [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I wish to do something similar to this,
http://timheuer.com/blog/archives.aspx
i need to create a interactive circular links using CSS.
There are a number of ways you can achieve that effect. The page in question looks like it simply uses an image background in a css style. The simplest example is;
1 Image Background
#link1 {
background-image: url('/images/button1-trans.png')
}
#link2 {
background-image: url('/images/button2-trans.png')
}
#link1:hover {
background-image: url('/images/button1.png')
}
#link2:hover {
background-image: url('/images/button2.png')
}
1b Image Spriting
Using multiple images like requires multiple browser requests so 'image spriting' is a technique commonly used these-days to optimise the download into a single request which will then be cached resulting in a single 304 response. In Tim's case, his looks like this (although the original is transparent);
Then you use the same image for each link along with a clipping and offsetting to locate the appropriate part of the image;
#links a {
background-image:url('/images/allButtons.png')
background-position: 0px 0px; /* sets the row for all normal links */
width: 64px;
height: 64px; /* bounding box for the image */
}
#links #link1 {
background-position: 0px 0px; /* first icon on the first row */
}
#links #link2 {
background-position: -64px 0px; /* slides the image strip left to locate the second icon on the first row */
}
#links #link1:hover {
background-position: 0px -64px; /* first icon on the second row */
}
#links #link2:hover{
background-position: -64px -64px; /* second image, second row */
}
Notice the background-image in #links a? Well that's actually superfluous in this case, but it would be nice if you could do that, and then you would only need to use background-position-x in each icon and you would only need one #links a:hover which would set the common row using background-position-y:-64px but the FireFox team with their usual pedantic standards-only 'computer says no' approach decided NOT support background-position-x or y, even though every other browser does and it's in common use. Much to the chagrin of everyone who'd like to use it in this way.
However, zoom in on those buttons on the blog you linked to. See how they look all pixelated?
2 Pure CSS
You can achieve the circles at least with a combination of CSS border-style, border-width and border-radius as others have posted, but you still need the image for the center button.
3 Icon Fonts
☺☻☼☽☾☿
This is the most modern, and my preferred approach as it's fully scalable, transparent, really, really tiny and super-fast. You need to download your font of course, but SVG compresses really well. It's just text in your HTML, no images at all. No crazy CSS styling either. Checkout IcoMoon! See how you can zoom all the way in on those?
Zoom in on the icons above, and Here's a fiddle
You can use icoMoon free, but I've purchased the pro pack, it's honestly priced and the value is well worth it. It's an awesome site as you can even load up your own SVG icons and it will generate your own font for you. There's even IE6 support.
EXPLANATION
The page You show us use a images sprit with icon of all menu item, event with border. My example show how do this with simple css. You can also use images sprit but including only icon.
HTML CODE:
<ul>
<li><span>Home</span></li>
<li><span>Blog</span></li>
<li><span>Contact</span></li>
<li><span>About</span></li>
<li><span>Projects</span></li>
</ul>
CSS CODE
html, body {
background: #369BD7;
font-family: tahoma;
font-size: 12px;
}
a {
color: #fff;
}
ul {
clear:both;
margin: 0;
padding: 0;
}
ul li {
display:block;
position: relative;
float: left;
height: 80px;
width: 80px;
padding: 0;
margin-left: 10px;
list-style: none;
text-align: center;
white-space: nowrap;
}
ul li:first-child {
margin: 0;
}
ul li a {
display:block;
margin: 10px auto;
height: 40px;
width: 40px;
border-radius: 100%;
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
border: 4px solid #fff;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
background: transparent url('http://cdn1.iconfinder.com/data/icons/TWG_Retina_Icons/24/home.png') no-repeat 50% 50%;
}
ul li a:hover {
background-color: #fff;
}
ul li a span {
display: block;
position: absolute;
bottom: 0;
left:0;
width: 100%;
text-align: center;
z-index: 1;
}
BORDER RADIUS BROWSER SUPPORT
http://caniuse.com/#search=border-radius
DEMO
http://jsfiddle.net/bartekbielawa/fgPf8/6/
The trick is to have the border-radius be half of the height and width. Then just use a gif or png for IE fallback.
.round-button {
width:100px;
height:100px;
border-radius:50px; /* be sure to add all the browser prefix versions */
}