The links on my site are not clickable.. I built another site earlier this year and made it work how I wanted, so I just copied that code.
<div id="links">
<div class="wrap">
<ul id="navigation">
<li>HOME</li>
<li>FRESHMAN</li>
<li>SOPHOMORE</li>
<li>JUNIOR</li>
<li>SENIOR</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
// Document ready shorthand statement
$(function() {
$('.link').click(function() {
var id = $(this).attr('href');
$('html,body').animate({ scrollTop: $(id).offset().top }, 'slow');
// Prevent default behavior of link
return false;
});
});
</script>
</div>
<div id="atlanta1">
</div>
<div id="atlanta2">
</div>
<div id="atlanta3">
</div>
<div id="atlanta4">
</div>
<div id="stoneMountain">
</div>
I have blank divs just because I have them there at specific heights so the links will take me to different heights on the page. This is how I set up the style, for the links and for the divs
<style>
#links {background-color: black;
background-color: rgba(0, 0, 0, 0.9);
color: white;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 60px;
padding: 0;
margin: 0;
z-index:0}
#navigation {list-style: none; padding: 1; margin: 18px 0px ; color: white; text-align: center;}
#navigation li {display: inline;}
#navigation li #space {margin-right:150px;}
#navigation a {color: inherit; text-decoration: inherit;}
#header, #footer {width:100%; float:left;}
#navigation li + li {
background:url('seperator.gif') no-repeat top left;
padding-left: 10px
}
.wrap {position:relative; margin:0 auto; width:100%;}
#atlanta1 {
position:absolute;
top:0px;
height: 1000px;
z-index: -0
}
#atlanta2 {
position:absolute;
top:1000px;
height: 1000px;
z-index: -0
}
#atlanta3 {
position:absolute;
top:2000px;
height: 1000px;
z-index: -0
}
#atlanta4 {
position:absolute;
top:3000px;
height: 1000px;
z-index: -0
}
#stoneMountain {
position:absolute;
top:4000px;
height: 1000px;
z-index: -0
}
</style>
I've been stuck here for a while and don't really see whats wrong, but the links aren't clickable.
Im not sure what you mean by the links are not clickable.
I mean your divs have no width for a start so its there is no divs for the Javascript to scroll to. I gave them a width and seems to work ok....
Example of giving a width:
#atlanta1 {
position:absolute;
top:0px;
height: 1000px;
width: 100px; // Width!
z-index: -0;
}
Working Example Here
As you can see the links are clickable and work.
Note: I only gave a width to a few.
I think I know what your talking about now, I think its because you are using z-index. Some of the divs are going above the header. You could try something like.
z-index:9999;
Put that in the header or as you have called it #links.
DEMO HERE
Fully working version:
DEMO HERE
Another update:
Right its because of this:
ul li {
list-style:none;
overflow:hidden;
height:1000px;
position: relative;
z-index:-2;
}
See how you are pushing the list behind the header. Set it to 9 or something and it will comeback to the front. You may want to look up what z-index does.
ul li {
list-style:none;
overflow:hidden;
height:1000px;
position: relative;
z-index:9;
}
Working Demo
Related
I would like two create two buttons that overlay a div using HTML like the following:
*Both the same DIV with two buttons overlapping each side. So one div with two buttons overlapping.
I would like the buttons to be transparent and overlay the div but I am not sure how.
I have created my Div:
<div class="container">
<div id="slides">
<img src="img/example-slide-1.jpg" alt="Photo by: Missy S Link: http://www.flickr.com/photos/listenmissy/5087404401/">
</div>
</div>
The div I would like to overlay is called "container" and the two buttons are:
<i class="icon-chevron-left icon-large"></i>
<i class="icon-chevron-right icon-large"></i>
Is there any way in CSS or HTML to do this?
You have to place your buttons absolutely on top of your image. To do so, first make .container take a position: relative; and then put your buttons as siblings of your .slides div and place them absolutely.
.container {
position: relative;
}
.slidesjs-navigation {
position: absolute;
top: 0;
display: block;
width: 50%;
height: 100%;
background: rgba(0,0,0,0); /* Added in case you want to transition this */
}
.slidesjs-navigation:hover {
background: rgba(0,0,0,0.25); /* Makes the hovered button visible */
}
.slidesjs-previous {
left: 0;
}
.slidesjs-next {
right: 0; /* left: 50%; works too */
}
.slides img {
display: block; /* Avoids the space usually seen under inline images */
width: 100%; /* Ensures the image takes up the whole width */
}
<div class="container">
<div id="slides" class="slides">
<img src="https://c1.staticflickr.com/5/4147/5087404401_d24513119a_b.jpg" alt="Photo by: Missy S Link: http://www.flickr.com/photos/listenmissy/5087404401/"><!-- original `src`: "img/example-slide-1.jpg" -->
</div>
<i class="icon-chevron-left icon-large"></i>
<i class="icon-chevron-right icon-large"></i>
</div>
Here is a simple way to do it. Put both buttons inside a div with a height:100%, width:50% and float:left;. This way each button takes up the full height of the div but only half of its width. The float:left; will then put them side by side in the div, hopefully achieving what you want!
.box {
border:1px solid black;
height:200px;
width:400px;
background-color:#005680;
}
.button1 {
width:50%;
height:100%;
float:left;
background-color: rgba(0,0,0,0);
border:0px solid black;
}
.button2 {
width:50%;
height:100%;
float:left;
background-color: rgba(0,0,0,0);
border:0px solid black;
}
.button1:hover {
background-color: rgba(10,10,10,0.1);
}
.button2:hover {
background-color: rgba(10,10,10,0.1);
}
<div class="box">
<button class="button1"></button>
<button class="button2"></button>
</div>
This can be your code.
.d {
position:relative;
}
.b1 {
float:left;
height:100px;
width:75px;
}
.b2 {
position:absolute;
left:75px;
height:100px;
width:75px;
}
<div class="d">
<button class="b1"></button>
<button class="b2"></button>
</div>
So basically you would like to create something similar to a toggle button or on/off switch? You could try something like:
HTML:
<div id="toggle">
<a id="left-side" href="">Left</a>
<a id="right-side" href="">Right</a>
</div>
CSS:
<script type="text/css">
DIV#toggle {
width:100px;
height:50px;
margin:0px;
padding:0px;
}
DIV#toggle>A {
display:block;
width:50%;
height:100%;
padding:0px;
text-size:10pt;
text-align:center;
}
DIV#toggle>A#right-side {
margin:0px auto 0px 0px;
background-color:#ff0000;
}
DIV#toggle>A#left-side {
margin:0px 0px 0px auto;
background-color:#00ff00;
}
</script>
Since you mentioned that the buttons are in the div, you can simply position them using position: absolute. By adding position: relative to the container, you can position them within that container rather than within the document as a whole.
/* -------------------------------------------------- --
The part that you actually need
-- -------------------------------------------------- */
/* Allow elements to be positioned relative to the container */
.container {
position: relative;
}
/* Let the buttons both cover the (left) half of the div */
.container .slidesjs-navigation {
position: absolute;
top: 0;
left: 0;
width: 50%; /* Of .container, its positioning parent */
height: 100%; /* Of .container */
}
/* Make an exception for the second button to move it to the right half */
.container .slidesjs-next {
left: 50%;
}
/* -------------------------------------------------- --
The part that's just for the demonstration.
-- -------------------------------------------------- */
/* Make the content large to show that the buttons scale */
#slides {
padding: 50px;
}
/* Make the div red, as in the question */
.container {
background-color: red;
}
/* Have white, semi-transparent buttons with a border, so you see where they are */
.container .slidesjs-navigation {
background-color: white;
border: 1px dashed black;
box-sizing: border-box;
opacity: 0.5;
}
/* Make the buttons opaque on hover to show that they respond */
.container .slidesjs-navigation:hover {
opacity: 1;
}
<div class="container">
<i class="icon-chevron-left icon-large"></i>
<i class="icon-chevron-right icon-large"></i>
<div id="slides">
<img src="img/example-slide-1.jpg" alt="Photo by: Missy S Link: http://www.flickr.com/photos/listenmissy/5087404401/">
</div>
</div>
Hope this is what you were looking for. Happy to explain or help in a better solution if needed.
.container {
width: 100vw;
height: 50vh;
background-image: url('https://c1.staticflickr.com/5/4147/5087404401_d24513119a_n.jpg');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
margin: 0;
padding: 0;
}
.container a{
width: 49.5%;
height: 50vh;
margin: 0;
padding: 0;
display: inline-block;
}
.container a:hover{
width: 49.5%;
height: 50vh;
background: rgba(255,255,255,0.4);
margin: 0;
padding: 0;
display: inline-block;
}
<div class="container">
<i class="icon-chevron-left icon-large"></i>
<i class="icon-chevron-right icon-large"></i>
</div>
I've got a tile containing a title, a category, a link to the category, a picture and a global link to the picture. As it is, this global link is only active in a piece of the picture area. I would like it to be global.
Here is the HTML :
<div id="article">
<div class="block-module">
<a class="view-full-module" href="http://www.cosmos.com/Common/Images/Destinations/machupicchu3.jpg">
<img class="image" src="http://www.cosmos.com/Common/Images/Destinations/machupicchu3.jpg"/>
</a>
<div class="block-about">
<h2 class="block-title">Title</h2>
<span class="block-stats">Category Date</span>
</div>
</div>
</div>
Here is the CSS :
.view-full-module { cursor: pointer; top: 0px; left: 0px; z-index: 2; background: none repeat scroll 0% 0% rgba(31, 32, 33, 0); width: 100%; height: 100%; }
.image { width: 100%; }
.block-module { width: 100%; position:relative; margin:0; padding:0; cursor:pointer; border-radius:10px; z-index:4; }
.block-about { position:absolute; bottom:0; left:0; right:0; padding:4em 1em 1em 1em; background-image:-webkit-linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); background-image:linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); }
.block-about a { position:relative; z-index:5; }
.block-title { max-width:100%; margin:0 0 0; color: white !important;font-size:1.625em; }
.block-stats { width:100%; margin-top:0.35714em; font-size:0.875em; color:rgba(255,255,255,0.55) !important; }
.author-link { color:#659dae; }
#article { top:0; margin: 0; padding:20px; -moz-column-gap: 20px; -webkit-column-gap: 20px; column-gap: 20px; -moz-column-width: 260px; -webkit-column-width: 260px; column-width: 260px; }
Here is a demo : http://jsfiddle.net/5qwejk20/4/
One option would be to add pointer-events: none to the element .block-about.
In doing so, you can essentially click through the element:
Updated Example
.block-about {
pointer-events: none;
}
Browser support for the pointer-events property can be found here.
Another option would be to move the anchor element and then absolutely position it relative to the parent in order to take the full dimensions.
The reason you need to move the anchor element in the DOM is because if it wraps the img element, then you can't have your background fading at the bottom since the anchor needs to be positioned above it in order for the click event to work anywhere within the element.
Updated Example
.view-full-module {
cursor: pointer;
position: absolute;
top: 0; right: 0;
bottom: 0; left: 0;
z-index: 2;
}
<div id="article">
<div class="block-module">
<img class="image" src="http://www.cosmos.com/Common/Images/Destinations/machupicchu3.jpg" />
<div class="block-about">
<h2 class="block-title">Title</h2>
<span class="block-stats">Category Date</span>
</div>
<a class="view-full-module" href="http://www.cosmos.com/Common/Images/Destinations/machupicchu3.jpg"></a>
</div>
</div>
As a side note, you may want to add vertical-align: top to the img element in order to remove the gap under it.
Example without the gap
img {
vertical-align: top;
}
This is supposed to be a simple div-appear-on-hover situation, but the div with #1949_neon is just not showing up after I hover on #1949_wrapper.
I am very sure that the div is at the right place, because when I change the visibility to block, it's showing up at the right place.
<div id="1949_wrapper">
<div class="year_line" style="top:170px;">1949</div>
<div class="neon_light" id="1949_neon"></div>
</div>
.neon_light{
position:relative;
top: 0px;
width:250px;
height:650px;
background:#FFFF00;
z-index: 1;
}
#1949_neon {
display: none;
}
#1949_wrapper:hover #1949_neon {
display: block;
}
This can be achieved with css. The issue here is your id's starting with a number. This works.
<div id="wrapper_1949">
<div class="year_line" style="top:170px;">1949</div>
<div class="neon_light" id="neon_1949"></div>
</div>
.neon_light{
position:relative;
top: 0px;
width:250px;
height:650px;
background:#FFFF00;
z-index: 1;
}
#neon_1949 {
display: none;
}
#wrapper_1949:hover #neon_1949 {
display: block;
}
You can't do it just by css.
Change your HTML to
<div id="1949_wrapper" onmouseover="document.getElementById('1949_neon').style.display = 'block';">
<div class="year_line" style="top:170px;">1949</div>
<div class="neon_light" id="1949_neon"></div>
</div>
and your css to:
.neon_light {
position:relative;
top: 0px;
width:250px;
height:650px;
background:#FFFF00;
z-index: 1;
display:none;
}
#1949_neon {
display: none !important;
}
Demo
You can do it using CSS. What is going wrong with your CSS is you are having ID starting with a number which will not work. Here is the working CSS.
.neon_light{
position:relative;
top: 0px;
width:250px;
height:650px;
background:#FFFF00;
z-index: 1;
}
[id='1949_neon'] {
display: none;
}
[id='1949_wrapper']:hover [id='1949_neon'] {
display: block;
}
Simple question (I hope) that's eluding me.. I have an overlay for a modal window that sets the opacity to .87, however my div inside that (the modal content) seems to inherit that opacity.
CSS:
body { background-color:black; }
#overlay {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
text-align:center;
z-index: 99;
background-color: black;
opacity:.87;
}
#overlay > div {
width:300px;
height:300px;
margin: 100px auto;
background-color: #fff;
border:1px solid #000;
padding:15px;
text-align:center;
opacity:1;
z-index: 100;
}
HTML:
<div id="overlay">
<div>some stuff here</div>
</div>
Here is a fiddle (the background should be pure white, not mixed). What am I doing wrong?
Opacity is inherited by child elements AFAIK.
Why not try using:
background:rgba(0,0,0,.87);
I removed the black background.
Check it here: http://jsfiddle.net/zZ57q/3/
I've a problem with a website I'm building.
I've a menu containing 2 links (called "Default" and "Test") into list items but in Firefox I can't click them.
In IE they works: I think is a z-index problem of items on the page but I can't solve it.
<!DOCTYPE html>
<html>
<head>
<style>
.sezup li.current{
color:#067d2c;
position:relative;
z-index:20;
}
.sezup a, a:hover{
color:#067d2c;
position:relative;
z-index:20;
}
.header{
position:relative;
top:0px;
}
.sezup {
margin: 0 auto;
padding: 0 0 0 75px;
width:800px;
position:relative;
z-index:20;
}
#lineaup {
background: url("../Images/sfondobarraup.png") repeat scroll 0 0 transparent;
height: 16px;
margin: 55px 0 0;
position: relative;
z-index: 0;
top: -25px;
left: 0px;
}
#lineaup li {
bottom: 6px;
float: left;
margin: 0 10px;
padding: 2px 15px;
position: relative;
}
.loghi {
margin: 0 auto;
padding: 20px 0 0;
position: relative;
top: -45px;
width: 1000px;
height: 97px;
border:1px black solid;
}
#logo {
position: relative;
top: -20px;
float:left;
}
#calciatore {
position: relative;
float:right;
top:-50px;
}
#erba {
background: url("../Images/erba.png") repeat scroll 0 0 transparent;
height: 65px;
position: relative;
top: -110px;
z-index: 0;
border:1px black solid;
}
</style>
</head>
<body>
<div class="header">
<div id="lineaup">
<div class="sezup">
<ul>
<li class="current">Default</li>
<li>Test</li>
</ul>
</div>
</div>
<div class="loghi">
<img src="" title="logo" id="logo" /><img src="" title="logo" id="calciatore" />
</div>
<div id="erba">
</div>
</div>
</body>
</html>
Because of the stacking context, once you set a z-index on a parent element, you can't "break out" of it by setting a higher z-index on a child element.
Usually it's a lot easier to deal with by removing all the superfluous z-index values and only adding them where you need it.
See demo here
Get rid of all z-index except for:
#lineaup {
z-index: 1;
}
and
#erba {
z-index: -1;
}
You should only change the z-index of the parent elements. There's no reason to assign the children elements with higher and higher indices.
Also, since it's usually just one element behind another, this -1 and 1 solution not only works but looks nice, and is easy to understand, I think.
For the record, negative z-indices are allowed.
Increase the z-index for #lineap
#lineaup {
z-index: 1;
...
}
http://jsfiddle.net/willemvb/wxWBm/