I am trying to create something similar to the attached image where the images show up all of the time and then on hover the content shows up with the color overlay.
Right now I have the images as a background to the div, but I'm not sure if that's the best way to go about this because I cannot find a way to make the image be the correct height in the div. The link is mtmdevbox.com
Thanks in advance!
HTML
<div class="homepage-content img-one">
<div class="hidden-content">
<h1> For Guests </h1>
<p> Usdaerum explaudae officto commossum seque delitiae. Rate conempo rectio ius ium- quun tinullaborum dentiunt. Tem in re occatem poreperum aut faciae escia dolute pore pro volo ex etur? Offictet doluptas aruptam eos qui temossimet voloria tes- tiam reium harum sum </p>
</div>
</div>
CSS
.img-one {
background-image: url(/wp-content/uploads/2015/07/homepage_images-03.jpg); background-repeat: no-repeat;
width: 65%;
background-size: 100%;
float: right;
clear: both;}
screenshot of design
I think this is what you're after. Let me know if it helps!
<div class="article">
<div class="content">
<h1>
This is your title
</h1>
<p>
This is your content
</p>
</div>
</div>
CSS
.article { display: block; min-height: 500px; background: url("http://placehold.it/500x500"); background-size: cover; }
.content { display: none; margin: 0; padding: 15px; background: rgba(0, 0, 0, .5); position: relative; min-height: calc(500px - 30px); width: 30%; }
.content h1 { margin: 0; padding: 0; }
.article:hover .content { display: block; }
https://jsfiddle.net/2rb18h0r/
Rather than floating the elements, you can use positioning instead. Something like:
.img-one {
background-image: url("http://i.imgur.com/5BK0htU.png");
/*background-repeat: no-repeat;*/
width: 100%;
height: 300px;
position: relative;
background-size: 100%;
cursor: pointer;
}
.img-one .hidden-content {
position: absolute;
opacity: 0.2;
transition: all 0.4s;
left: calc(35% - 10px);
width: 65%;
height: 100%;
background: rgba(200, 200, 200, 0.4);
border-left: 10px solid white;
}
.img-one:hover .hidden-content {
opacity: 1;
}
.hidden-content h1 {
margin-left: 5%;
}
.hidden-content p {
width: 35%;
margin-left: 5%;
}
<div class="homepage-content img-one">
<div class="hidden-content">
<h1> For Guests </h1>
<p>Usdaerum explaudae officto commossum seque delitiae. Rate conempo rectio ius ium- quun tinullaborum dentiunt. Tem in re occatem poreperum aut faciae escia dolute pore pro volo ex etur? Offictet doluptas aruptam eos qui temossimet voloria tes- tiam
reium harum sum</p>
</div>
</div>
In the above demo I have set the opacity to 0.2, however setting this to 0 will allow a complete 'hidden' state.
I have decided to use the opacity CSS instead of display:hidden|none as it will allow for transitions/smooth fade in effects. If you don't want that, you can set the initial state of display:hidden and then on the hover state use display:block|inline-block
Related
I have three styles, the first two is for div, the last one is for the image. The image can be clicked without the div. But I need the div effect, how could I solve this issue. Now the image doesn't reponse to onClick.
const onclick=(e)=>{
e.stopPropagation();
console.log('clicked')
}
.start-screen {
position: absolute;
top: 0;
margin-top: 2.3%;
height: 65vh;
width: 91vw;
background: -webkit-linear-gradient(
top,
#0a0a0a 0,
rgba(10, 10, 10, 0.58) 58%
);
display: flex;
justify-content: center;
align-items: center;
}
#start {
transition-duration: 2s;
pointer-events: none;
}
.schema{
position: absolute;
top: 5%;
left: 35%;
display: block;
pointer-events: auto;
transition-duration: 2s;
}
<div class="start-screen" id="start">
<img class="transport" src='imgs/transportDiagram.png' alt='fail to load services' onClick="onclick">
</div>
You should add the click event in the div.
<div className="start-screen" id="start" onClick={onclick}>
<img className="transport" src='imgs/transportDiagram.png' alt='fail to load services' />
</div>
I made a mistake that didn't use the right class name. Change className='transport' to 'schema' would work.
Hopefully this will work
<div className="start-screen" id="start">
<img className="transport" src='imgs/transportDiagram.png' alt='fail to load services' onClick={() => onclick()} />
</div>
So i've come to live by these 3 CSS rules that almost always vertically center any block level element:
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50% );
}
It works often. But in the case of this particular layout I'm building it is pushing the elements too high ( partially off the screen ) and I don't know why.
This is how the webpage looks before adding my vertically-center class to my portrait-container div:
And this code snippet is how it appears after adding the vertically-center class to the portrait-container div:
.clearfix:after {
content: "";
display: block;
clear: both;
}
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50% );
}
body {
overflow: hidden;
}
main {
padding-top: 50px;
background: #fafafa;
text-align: left;
}
.portrait-container {
float: left;
}
img {
width: 150px;
border-radius: 50%;
}
.about-container {
width: 70%;
float: right;
}
<main class="clearfix">
<div class="portrait-container vertically-center">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
</div>
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good Kool Aid, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</main>
I just want the image container to be vertically-centered regardless of the height of it's parent. Help? Inspecting elements gave me no insights.
Edit: Just to show how this has always worked for me in the past. Here is a jsfiddle: https://jsfiddle.net/9kyjt8ze/4/. Why does it work for me there and not here?
Related question: What does top: 50%; actually do on relatively positioned elements?
Your CSS was not bad but I didn't get along with it. So here is another approach on how you could solve it, maybe it helps also. It will always center the image vertically and does not matter how much text the box on the right will have. The colored borders are just there to help show the visual effect of the box sizes.
* {
box-sizing: border-box;
}
.portrait-container {
position: relative;
margin: 20px 0;
}
.portrait-container:after {
content: '';
display: block;
clear: both;
}
.portrait-container img {
position: absolute;
top: calc(50% - 80px); /* 50% from top minus half img height*/
width: 150px;
height: 160px;
border-radius: 50%;
float: left;
}
.portrait-container {
border: solid 2px orange;
}
.portrait-container .about-container {
border: solid 2px green;
padding: 0 50px;
margin-left: 150px; /* this elements should be at least 150px away from left side */
width: calc(100% - 150px); /* the max width this element should have to be placed */
/* next to the image is the total width(100%) - the image width */
}
<main>
<div class="portrait-container">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</div>
</main>
<main>
<div class="portrait-container">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko">
<div class="about-container">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all
of my favorite work. When I'm not creating things, I enjoy excercising,
playing video games, drinking good fruit punch, and more.
<br><br> If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</div>
</div>
</main>
UPDATE
Edit: Just to show how this has always worked for me in the past. Here is a jsfiddle: https://jsfiddle.net/9kyjt8ze/4/. Why does it work for me there and not here?
The black circle is the only element there in the Fiddle, there's no obstructions. In the code you are having trouble with, you have many elements either in the way or wrapped around other elements trapping them. Your ruleset will work if you start stripping away the layers. Or you can just add a property and change another property as per Snippet 1.
One important note a relative element is actually occupying the original spot, so if given a left:40px it appears to be moved 40px to the left, but in reality it still occupies the space 40px to the right of where it appears to be. So relative elements are not really in a flow different from static elements. Therefore they are affected by and affect static layout, it's just not noticeable normally because they stack with z-index.
Snippet 2 is an interactive demo, I figured maybe that'll help explain things better.
The 3 CSS ruleset is a common way to vertically align elements, but it was originally position: absolute instead of position:relative and it had to be in another positioned element if I remember correctly.
REFERENCE
Specific Ruleset
W3Schools
MDN
SOLUTION
.vertically-center {
/* Changed to absolute from relative */
position: absolute;
top: 50%;
transform: translateY( -50% );
}
main {
/* Added position: relative */
position: relative;
padding-top: 50px;
background: #fafafa;
text-align: left;
}
SNIPPET 1
.vertically-center {
position: relative;
top: 50%;
transform: translateY( -50%);
}
body {}
main {
padding-top: 50px;
overflow: scroll;
background: #fafafa;
text-align: left;
}
img {
width: 150px;
border-radius: 50%;
float: left;
}
.about {
width: calc(100% - 150px);
float: right;
}
<main class="clearfix">
<img src="http://i.imgur.com/Eb5sRZr.jpg" alt="Portrait of John Lesko" class="vertically-center">
<article class="vertically-center about">
<h3>About</h3>
<p>
Hi, I'm John Lesko! This is my art portfolio where I share all of my favorite work. When I'm not creating things, I enjoy excercising, playing video games, drinking good Kool Aid, and more.</p>
<p>If you'd like to follow me on Twitter, my username is
#jletsgo.
</p>
</article>
</main>
SNIPPET 2
$('#b1').click(function() {
$('body').toggleClass('R S');
});
$('#b2').click(function() {
$('#N1,#N2,#N3').toggleClass('N M');
});
$('input[id$="2"]').on('input', function() {
var grp = "." + $(this).attr('class');
var num = parseInt($(this).val(), 10);
grp !== '.S' ? $('section' + grp).css('left', num + '%') : $('section.S').css('margin-left', num + '%');
});
$('input[id$="3"]').on('input', function() {
var grp = "." + $(this).attr('class');
var num = parseInt($(this).val(), 10);
grp !== '.S' ? $('section' + grp).css('top', num + '%') : $('section.S').css('margin-top', num + '%');
});
html,
body {
height: 100%;
width: 100%;
}
body {
overflow: scroll;
font: 400 12px/1.2 Consolas;
}
section {
width: 50px;
height: 150px;
border: 2px dashed grey;
text-align: center;
color: white;
}
.R {
position: relative;
background: rgba(0, 0, 255, .3)
}
.A {
position: absolute;
background: rgba(255, 0, 0, .3)
}
.F {
position: fixed;
background: rgba(0, 255, 0, .3)
}
.S {
position: static;
background: rgba(122, 122, 0, .3)
}
.N {
position: absolute;
background: yellow;
color: blue;
}
.M {
position: relative;
background: black;
color: yellow;
}
#R1 {
left: 20%;
top: 3%;
z-index: 1;
}
#A1 {
left: 42%;
top: 44%;
z-index: 2;
}
#F1 {
right: 20%;
top: 44%;
z-index: 3;
}
#S1 {
margin-left: 0;
margin-top: -28%;
}
#N1 {
bottom: 0;
right: 0;
width: 25px;
height: 80px;
z-index: 4;
}
input {
width: 6ex;
position: static !important;
}
button {
font: inherit;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body class='S'>
<fieldset>
<button id='b1'>Body Relative/Static</button>
<button id='b2'>Nested Absolute/Relative</button>
<br><br> RLeft
<input id='R2' class='R' type='number' value='20'> RTop
<input id='R3' class='R' type='number' value='3'> ALeft
<input id='A2' class='A' type='number' value='44'> ATop
<input id='A3' class='A' type='number' value='44'><br> FLeft
<input id='F2' class='F' type='number' value='64'> FTop
<input id='F3' class='F' type='number' value='44'> SLeft
<input id='S2' class='S' type='number' value='0'> STop
<input id='S3' class='S' type='number' value='-28'><br> NLeft
<input id='N2' class='N' type='number' value='45'> NTop
<input id='N3' class='N' type='number' value='45'>
</fieldset>
<section id='R1' class='R'>RELATIVE
<section id='N1' class='N'>N<br>E<br>S<br>T<br>E<br>D</section>
</section>
<section id='A1' class='A'><br><br><br>ABSOLUTE</section>
<section id='F1' class='F'><br><br>FIXED</section>
<section id='S1' class='S'><br><br><br><br><br>STATIC</section>
</body>
You can achieve this by using flexboxwith a lot less code. The below code will do the trick.
.clearfix {
display: flex;
align-items: center;
}
img {
width: 150px;
border-radius: 50%;
}
.about-container {
width: 70%;
padding-left: 30px;
}
Check it out in codepen http://codepen.io/anon/pen/OWYxrb
I'm trying to layer some text over an image, but want to allow the text to run off all edges of its container without extending the container. I'm going for something just like this:
where the background box is an image that's full-screen wide, and the text completely fills and overruns the image on all sides without extending its container. (That is, the image and the text should both be 100% wide.) I also wish to assign each word a unique id for other reasons.
Here's what I have right now: fiddle. So far I haven't been able to get the text to run off the right side of the image unless I set the width of #text-overlay to > 100%, which extends the width of the image container.
Is it possible to use something like text-overflow here? I'd be grateful for any help others can offer!
Code from fiddle:
<!DOCTYPE HTML>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
#banner-image {
height: 0;
padding: 0;
padding-bottom: 10%;
background: linear-gradient( rgba(0, 0, 0, 0.5),
rgba(0, 0, 0, 0.5) ), url(http://placekitten.com/150/300);
background-position: 0% 0%;
background-size: 100%;
background-repeat: no-repeat;
position: relative;
}
#text-overlay {
position: absolute;
max-height: 100%;
margin-left: -10px;
margin-right: 10px;
width: 120%;
overflow: hidden;
word-spacing: 3px;
}
#text-overlay div {
float: left;
padding-right: 4px;
color: red;
cursor: pointer;
}
</style>
</head>
<body>
<body>
<div id="banner-image">
<div id="text-overlay">
<div id="word-number-0">Lorem</div><div id="word-number-1">ipsum</div><div id="word-number-2">dolor</div><div id="word-number-3">sit</div><div id="word-number-4">amet</div><div id="word-number-5">at</div><div id="word-number-6">suas</div><div id="word-number-7">utamur</div><div id="word-number-8">bonorum</div><div id="word-number-9">usu</div><div id="word-number-10">Appareat</div><div id="word-number-11">oportere</div><div id="word-number-12">ad</div><div id="word-number-13">nec</div><div id="word-number-14">meis</div><div id="word-number-15">consulatu</div><div id="word-number-16">vel</div><div id="word-number-17">eu</div><div id="word-number-18">partem</div><div id="word-number-19">equidem</div><div id="word-number-20">duo</div><div id="word-number-21">ne</div><div id="word-number-22">Affert</div><div id="word-number-23">corrumpit</div><div id="word-number-24">no</div><div id="word-number-25">eos</div><div id="word-number-26">Te</div><div id="word-number-27">cum</div><div id="word-number-28">appareat</div><div id="word-number-29">urbanitas</div><div id="word-number-30">laudem</div><div id="word-number-31">meliore</div><div id="word-number-32">appellantur</div><div id="word-number-33">mel</div><div id="word-number-34">te</div><div id="word-number-35">Quo</div><div id="word-number-36">no</div><div id="word-number-37">noster</div><div id="word-number-38">periculis</div><div id="word-number-39">accusamus</div><div id="word-number-40">tale</div><div id="word-number-41">scriptorem</div><div id="word-number-42">ad</div><div id="word-number-43">quo</div><div id="word-number-44">Nec</div><div id="word-number-45">tale</div><div id="word-number-46">partiendo</div><div id="word-number-47">id</div><div id="word-number-48">Eros</div><div id="word-number-49">aliquam</div><div id="word-number-50">vix</div><div id="word-number-51">ei</div><div id="word-number-52">ne</div><div id="word-number-53">eos</div><div id="word-number-54">nulla</div><div id="word-number-55">dolor</div><div id="word-number-56">disputationi</div><div id="word-number-57">No</div><div id="word-number-58">sit</div><div id="word-number-59">soleat</div><div id="word-number-60">facete</div><div id="word-number-61">efficiendi</div><div id="word-number-62">Eu</div><div id="word-number-63">animal</div><div id="word-number-64">integre</div><div id="word-number-65">sed</div><div id="word-number-66">sea</div><div id="word-number-67">no</div><div id="word-number-68">quaeque</div><div id="word-number-69">reformidans</div><div id="word-number-70">His</div><div id="word-number-71">ne</div><div id="word-number-72">homero</div><div id="word-number-73">tritani</div><div id="word-number-74">sed</div><div id="word-number-75">ea</div><div id="word-number-76">odio</div><div id="word-number-77">labore</div><div id="word-number-78">Odio</div><div id="word-number-79">delenit</div><div id="word-number-80">referrentur</div><div id="word-number-81">mel</div><div id="word-number-82">at</div><div id="word-number-83">has</div><div id="word-number-84">an</div><div id="word-number-85">etiam</div><div id="word-number-86">soluta</div><div id="word-number-87">molestie</div><div id="word-number-88">prima</div><div id="word-number-89">cotidieque</div><div id="word-number-90">ea</div><div id="word-number-91">eos</div><div id="word-number-92">Vix</div><div id="word-number-93">iusto</div><div id="word-number-94">tollit</div><div id="word-number-95">aliquid</div><div id="word-number-96">no</div><div id="word-number-97">audiam</div><div id="word-number-98">utamur</div><div id="word-number-99">prodesset</div><div id="word-number-100">ad</div><div id="word-number-101">pri</div><div id="word-number-102">cum</div><div id="word-number-103">dictas</div><div id="word-number-104">reformidans</div><div id="word-number-105">instructior</div><div id="word-number-106">ut</div><div id="word-number-107">Error</div><div id="word-number-108">quidam</div><div id="word-number-109">eu</div><div id="word-number-110">vel</div><div id="word-number-111">at</div><div id="word-number-112">mei</div><div id="word-number-113">aliquip</div><div id="word-number-114">volumus</div><div id="word-number-115">Ei</div><div id="word-number-116">regione</div><div id="word-number-117">aliquid</div><div id="word-number-118">quaerendum</div><div id="word-number-119">est</div><div id="word-number-120">Vel</div><div id="word-number-121">eius</div><div id="word-number-122">malorum</div><div id="word-number-123">at</div><div id="word-number-124">molestie</div><div id="word-number-125">copiosae</div><div id="word-number-126">interesset</div><div id="word-number-127">et</div><div id="word-number-128">cum</div><div id="word-number-129">Cum</div><div id="word-number-130">lorem</div><div id="word-number-131">splendide</div><div id="word-number-132">at</div><div id="word-number-133">debet</div><div id="word-number-134">everti</div><div id="word-number-135">maiestatis</div><div id="word-number-136">ut</div><div id="word-number-137">nam</div><div id="word-number-138">No</div><div id="word-number-139">vim</div><div id="word-number-140">putant</div><div id="word-number-141">liberavisse</div><div id="word-number-142">Ad</div><div id="word-number-143">euismod</div><div id="word-number-144">posidonium</div><div id="word-number-145">his</div><div id="word-number-146">graece</div><div id="word-number-147">quidam</div><div id="word-number-148">utroque</div><div id="word-number-149">eum</div><div id="word-number-150">te</div><div id="word-number-151">Nec</div><div id="word-number-152">ei</div><div id="word-number-153">commodo</div><div id="word-number-154">mentitum</div><div id="word-number-155">te</div><div id="word-number-156">his</div><div id="word-number-157">wisi</div><div id="word-number-158">detracto</div><div id="word-number-159">voluptaria</div><div id="word-number-160">Mei</div><div id="word-number-161">oratio</div><div id="word-number-162">antiopam</div><div id="word-number-163">contentiones</div><div id="word-number-164">et</div><div id="word-number-165">ex</div><div id="word-number-166">animal</div><div id="word-number-167">accommodare</div><div id="word-number-168">mei</div><div id="word-number-169">nullam</div><div id="word-number-170">admodum</div><div id="word-number-171">has</div><div id="word-number-172">at</div><div id="word-number-173">Ne</div><div id="word-number-174">tempor</div><div id="word-number-175">argumentum</div><div id="word-number-176">signiferumque</div><div id="word-number-177">quo</div><div id="word-number-178">nec</div><div id="word-number-179">ea</div><div id="word-number-180">feugiat</div><div id="word-number-181">postulant</div><div id="word-number-182">pri</div><div id="word-number-183">prima</div><div id="word-number-184">labore</div><div id="word-number-185">facete</div><div id="word-number-186">ut</div><div id="word-number-187">Eum</div><div id="word-number-188">gubergren</div><div id="word-number-189">consequat</div><div id="word-number-190">ut</div><div id="word-number-191">Alienum</div><div id="word-number-192">insolens</div><div id="word-number-193">evertitur</div><div id="word-number-194">est</div><div id="word-number-195">an</div><div id="word-number-196">Has</div><div id="word-number-197">ex</div><div id="word-number-198">labores</div><div id="word-number-199">tibique</div><div id="word-number-200">omittantur</div>
</div>
</div>
</body>
</html>
working fiddle first
Remove the margins and weird width and heights. Text should be 100% width, 100% height, no margin, no padding.
Set overflow: hidden on the parent container (so the text hides when it overflows)
Now you have text which fills the container completely, no space on the sides, no overflow.
Use transform: scale(1.1) (any number would work) to make the text slightly bigger so it spills out ever so slightly.
#banner-image {
height: 0;
padding: 0;
padding-bottom: 40%;
background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url(http://placekitten.com/150/300);
background-position: 0% 0%;
background-size: 100%;
background-repeat: no-repeat;
position: relative;
overflow: hidden;
}
#text-overlay {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
word-spacing: 3px;
transform: scale(1.1);
}
I am building a japanese learning site (and i am a total beginner with css and html etc.) with wordpress and want to add a kana-helper: Every time when the cursor hovers over a kana (basic japanese characters) in the text, the belonging romaji should be shown in a fixed div.
This is a simplified version of what i have so far (thx to the help of this community):
/*working, but only when in same parent*/
.ko:hover ~ .kanahelfer-ko {display: block;}
/*not working, because not same paren?*/
.re:hover ~ .kanahelfer-re {display: block;}
/*not working because ???*/
.ha:hover .kanahelfer-ha {display: block;}
/*how to get it working?*/
.kanahelfer-ko{
display: none;
position: fixed;
left: 28px;
top: 120px;
height: 160px;
width: 160px;
color: black;
}
.kanahelfer-re{
position: fixed;
left: 28px;
top: 120px;
display: none;
height: 160px;
width: 160px;
color: black;
}
.kanahelfer-ha{
position: fixed;
left: 28px;
top: 120px;
display: none;
height: 160px;
width: 160px;
color: black;
}
<span class="ko">こ</span><span class="re">れ</span><span class="ha">は</span>
<div class="kanahelfer-ko">
<div class="kana">ko</div>
</div>
<div>
<div class="kanahelfer-re">
<div class="kana">re</div>
</div>
</div>
<div class="kanahelfer-ha">
<div class="kana">ha/Partike wa</div>
</div>
Problem is, that there are over 200 different kana und the text with the japanese letters is in a table and so i would have to make over 200 entries per table cell (too much) if i will not find a working solution. Is there a selector or way to achieve this with css and html only, even when elements are not in the same parent? (If not, i would have to learn js -.-). I do not understand why .ha:hover .kanahelfer-ha {display: block;} does not work.
I've updated your snippet and add some JavaScript.
You need to link JQuery to make this code working.
You need to put all the JS code into ready event handler:
$(function() {
// JS code
});
$('.letters') – finding all elements with letters class.
this – current object (clicked in this particular case).
$(this).data('letter') – gets a value from data-letter attribute.
// Taking all ".letter" in ".letters" and bind an event handler to "hover" event
$('.letters .letter').hover(function () {
// Get a letter from hovered element
var letter = $(this).data('letter');
// Show just necessary element
$('.kanahelfer-' + letter).show();
}).
// Bind an event handler for "mouseleave" event
mouseleave(function() {
// Hide all ".kanahelfer" elements
$('.kanahelfer').hide();
});
.kanahelfer-ko{
display: none;
position: fixed;
left: 28px;
top: 120px;
height: 160px;
width: 160px;
color: black;
}
.kanahelfer-re{
position: fixed;
left: 28px;
top: 120px;
display: none;
height: 160px;
width: 160px;
color: black;
}
.kanahelfer-ha{
position: fixed;
left: 28px;
top: 120px;
display: none;
height: 160px;
width: 160px;
color: black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="kana-container">
<div class="letters">
<span class="letter" data-letter="ko">こ</span><span class="letter" data-letter="re">れ</span><span class="letter" data-letter="ha">は</span>
</div>
<div class="kanahelfer kanahelfer-ko">
<div class="kana">ko</div>
</div>
<div>
<div class="kanahelfer kanahelfer-re">
<div class="kana">re</div>
</div>
</div>
<div class="kanahelfer kanahelfer-ha">
<div class="kana">ha/Partike wa</div>
</div>
</div>
Currently i have a running slideshow as my website background (3 images)
I also have a logo in the middle of these 3 images, which remains there throughout the duration of the slideshow.
Whilst the first image is displayed (when the website is loaded up) the logo image (which also has the function of a button) can be clicked and direct you to another website, however when the images change, the logo remains, however the ability to click is gone...
all help greatly appreciated
here is my current code
$(document).ready(function() {
var header = $('body');
var backgrounds = new Array(
'url(http://urs2009.net/wp-content/uploads/2011/11/lights-of-city.jpg)', 'url(http://hdwallpaperd.com/wp-content/uploads/2014/12/background-wallpaper-hd-1.jpg)', 'url(http://guruwallpapers.com/wp-content/uploads/2014/09/Sunset-Wide-Screen-Wallpapers-6.jpg)'
);
var current = 0;
function nextBackground() {
$('#mask').fadeTo(1000, 0.9, function() {
current++;
current = current % backgrounds.length;
header.css('background-image', backgrounds[current]);
})
$('#mask').fadeTo(500, 0);
}
setInterval(nextBackground, 5000);
header.css('background-image', backgrounds[0]);
});
body {
-webkit-background-size: 1390px 700px;
-moz-background-size: 1390px 700px;
background-size: 1390px 700px;
}
h1 {
font-size: 600%;
color: white;
margin-top: 0.5em;
}
h3 {
color: white;
margin-top: -50px;
}
.GFImage {
margin-top: 65px;
border: 0;
}
.Footer {
position: fixed;
bottom: 0;
width: 100%;
margin-left: -8px;
color: white;
background: #151515;
opacity: 0.8;
text-align: center;
vertical-align: middle;
height: 7%;
}
#mask {
width: 100%;
height: 100%;
background: #000000;
top: 0;
left: 0;
position: absolute;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<center>
<br>
<h1>Welcome to GF</h1>
</center>
<center>
<br>
<h3>Welcome to GF! Check out all the information you need by just the click of a button...</h3>
</center>
<center>
<a href="Home Page .html">
<img src="Images/GF Logo White .jpg" style="width: 275px; height: 275px;" class="GFImage">
</a>
</center>
<div class="Footer">
<p>Copyright © All Rights Reserved. Design by Gavin Foley.</p>
</div>
<div id="mask">SCRIPT FUNCTION IN HERE!!!!</div>
Seams like the link goes below the images.
I was able to solve this adding to the link element these properties:
position:absolute;
z-index:9
and then it should work.
EDIT
Just as a suggestion, have a look at this example, it could be useful if you are at the first try with html and css:
http://css-tricks.com/perfect-full-page-background-image/