Color change of fixed/sticky position object - javascript

I have seen this page (chrome version) and I am wondering about that circle that goes down and changes color. I am trying to do something similar myself and I am stuck in the transition from pink-circle with orange background to green-circle with white background. I have tried 2 strategies.
A)
using position: sticky; + hidding one layer under another and coordinating appropriately, see code below. The problem is that this only works for one of the circles (the one "appearing") but no the "hidding" one; so the effect is not the same.
.yellowbanner {
background-color: yellow;
height: 500px;
width: 500px;
z-index: 2;
position: sticky;
top:50px;
left:0px;
border-radius: 100%;
}
.orangebanner {
background-color: orange;
height: 500px;
width: 500px;
z-index: 21;
position: sticky;
top:50px;
left:0px;
border-radius: 100%;
}
.greenbanner {
background-color: mediumspringgreen;
height: 1000px;
width: 100%;
z-index: 3;
position: relative;
top:500px;
left:0px;
}
.bluebanner {
background-color: blue;
opacity: 1;
height: 1500px;
width: 100%;
z-index: 1;
position: relative;
top:0px;
left:0px;
}
.redbanner {
background-color: white;
height: 3000px;
width: 100%;
z-index: -2;
position: absolute;
top:0;
left:0px;
}
<!DOCTYPE html>
<html>
<head>
<title>DevProject</title>
<link href="./resources/css/index.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="greenbanner"><div class="yellowbanner"></div></div>
<div class="redbanner"></div>
<div class="bluebanner">
<div class="orangebanner"></div>
</div>
</body>
</html>
B) Using position: fixed; + some JS. However all I have found would change the color (at a certain moment) of the entire circle, and not just the appropriated section of it.
Thank you

Related

CSS force div with absolute position be behind div with static position

So lets say that I have some document
#a{width: 10px; height: 10px; background: red; z-index: 10;}
#b{width: 100%; height: 100%; background: black; z-index: 5; position: absolute;}
<body>
<div id="a">foo</div>
<div id="b">bar</div>
<body>
The #b div covers the #a, because #b has absolute position.
How can I force #b be behind #a without changing #a position?
You can add position: relative to #a element.
You have to set a position other than static to your first div to apply styles like z-index
#a {
width: 100px;
height: 100px;
background: red;
z-index: 10;
position: relative;
}
#b {
width: 100%;
height: 100%;
background: black;
z-index: 5;
position: absolute;
left:0;
top:0;
}
<div id="a">foo</div>
<div id="b">bar</div>
You should add a relative position to your first div :
<body>
<div id="a">foo</div>
<div id="b">bar</div>
<body>
<style>
#a{width: 10px; height: 10px; background: red; z-index: 10; position:relative}
#b{width: 100%; height: 100%; background: black; z-index: 5; position: absolute;}
</style>

Resize two halves of a browser screen

How to make that hovering the mouse over the boundary between two elements (here on the vertical line which separates the blue and red)
makes it possible to resize the width of each element?
I'm looking for the behaviour of https://stackedit.io/editor
Is this possible directly with <textarea> resizing possibilities ?
* { margin: 0; border: 0; padding: 0; }
textarea { background-color: red; width: 50%; position: absolute; top:0; left:0; height: 100%; }
#separator { cursor: ew-resize; position: absolute; top:0; width:1%; left:50%; height: 100%; }
#right { background-color: blue; width: 49%; position: absolute; top:0; right:0; height: 100%;}
<textarea>hello</textarea>
<div id="separator"></div>
<div id="right">yo</div>
Sort of like this:
* { margin: 0; border: 0; padding: 0; }
html,body { height: 100% }
textarea { background-color: red; width: 50%; height: 100%; resize: horizontal; min-width: 1px; max-width: 99%; float: left; }
div { background-color: blue; height: 100%}
textarea:active {width: 1px;}
<textarea>hello</textarea>
<div>yo</div>
Note that the textarea:active style is necessary because of an issue with chrome that won't allow an element to be resized less than it's initial width. It's a bad hack to work around it until chrome fixes it.

How to move images slightly up on scroll using Jquery?

I'm trying to create a simple parallax effect using Jquery (without plugins). Basically I have a few different images layered on-top of each-other and need them to move slightly upwards at different speeds when a user scrolls down, similar to a parallax scrolling effect.
Here's the layout so far (excuse the sloppy code):
body {
position: relative;
width: 100%;
height: auto;
margin: 0 auto;
background-color: #ededed;
z-index: 4;
display: table;
}
.header {
position: relative;
width: 100%;
background-color: #ffde15;
height: 900px;
margin-left: auto;
margin-right: auto;
}
.headertopimg {
position: absolute;
width: 100%;
z-index: 10;
}
.headerbehindimg {
position: absolute;
width: 100%;
z-index: 9;
top:0%;
}
.headerbehindbehindimg {
position: absolute;
width: 100%;
z-index: 8;
margin-top: 8%;
}
.headerbgimg {
position: absolute;
width: 70%;
z-index: 7;
left: 50%;
margin-left: -35%;
}
<body>
<div class="header">
<div class="headertop"><img src="http://i.imgur.com/z2DORfA.png" class="headertopimg"> </div>
<div class="headerbehind"><img src="http://i.imgur.com/o1Yl0PD.png" class="headerbehindimg"></div>
<div class="headerbehindbehind"><img src="http://i.imgur.com/VQxs9LD.png" class="headerbehindbehindimg"></div>
<div class="headerbg"><img src="http://i.imgur.com/t5fTRZe.png" class="headerbgimg"></div>
</div>
</body>
Any help would be much appreciated!

Positioning z-index does not work as expected

I cannot position info-pop-title on top of bar-header as you can see from my current code the text "TEST----" is visible but under the bar-header element.
http://jsfiddle.net/uvh4ymh9/
Could you point me out what am I doing wrong and how to fix it
PS: I cannot change structure for the HTML, only CSS solution
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.bar-header, .bar-footer {
position: fixed;
left: 0px;
width: 1280px;
z-index: 1;
background-color: rgba(50,50,50,0.5);
text-align: center;
}
.bar-header {
top: 0px;
height: 60px; /* safearea top 25 + content 20 + space bottom 15*/
}
.bar-header h1 {
position: fixed;
top: 25px; /* safearea top 25 */
left: 25px; /* safearea left */
font-size: 20px; /* content */
}
.bar-footer {
top: 670px;
height: 50px; /* safearea bottom 20 + content 20 + space top 10 */
font-size: 20px; /* content */
}
.bar-footer > ul {
position: fixed;
top: 680px; /* footer top 670 + space top 10*/
left: 1150px;
}
.bar-footer > ul li {
float: left;
}
.bar-footer li:nth-child(1) span {
color: blue;
}
#scene-main {
position: fixed;
top: 0px;
left: 0px;
width: 1280px;
height: 720px;
/*background: #ffffff url("/auth/assets/tv-safearea-transparent.png") no-repeat left;*/
background-color: darkgrey;
}
#btn-up, #btn-down {
position: fixed;
left: 1230px;
width: 50px;
height: 50px;
background-color: yellow;
outline: 1px solid black;
z-index: 200;
}
#btn-up {
top: 0px;
}
#btn-down {
top: 50px;
}
#content {
position: fixed;
top: 0px; /* header */
}
.content-section:first-child {
margin-top: 60px; /* header height content does not go under header */
}
.content-section {
background-color: lightgray;
outline: 1px solid black;
width: 1280px;
}
/* Content sizes */
.content-snippet {
height: 360px; /* 1 slots */
width: 1280px;
background-color: lightblue;
outline: 1px solid green;
}
.content-snippet:nth-child(even) {
background-color: lightcoral;
}
.content-section h2 {
position: relative;
top: 30px; /**avoid to go under the header bar*/
}
.active {
background-color: violet !important;
}
.snippet-pop-info {
position: fixed;
top: 640px; /*430 = final position as visible / 670 = final position as not visible */
width: 1280px;
height: 240px;
background-color: darkblue;
opacity: 1;
color: white;
}
.snippet-pop-info ul {
position: absolute;
top: 0px;
left: 1155px;
width: 100px;
}
.snippet-pop-info ul li {
width: 100px;
}
.snippet-pop-info .rating {
position: absolute;
top: 65px;
left: 25px;
unicode-bidi: bidi-override;
direction: rtl;
}
.snippet-pop-info .rating > span {
display: inline-block;
position: relative;
width: 20px;
}
.snippet-pop-info .rating > span:hover:before,
.snippet-pop-info .rating > span:hover ~ span:before {
content: "\2605";
position: absolute;
}
#info-pop-title {
position: fixed;
top: 0px;
left: 250px;
z-index: 1;
font-size: 30px;
color: white;
font-weight: bold;
}
#info-pop-description {
position: absolute;
overflow: hidden; /* hide content that does not fit in the columns*/
top: 25px;
left: 300px; /* TEST */
height: 80px;
width: 800px;
font-size: 20px;
-webkit-column-count: 2;
-webkit-column-gap: 10px;
column-count: 2;
column-gap: 10px;
}
</style>
</head>
<body>
<div id="viewport">
<div id="scene-main" class="scene" style="">
<div class="bar-header"><h1>ChannelLive logo</h1></div>
<div id="page">
<div id="content">
<div id="snippet-cnt-0" class="content-snippet">
0
<div class="snippet-pop-info" style="top: 720px;">
<h1 id="info-pop-title" style="word-wrap: break-word;">TEST-----------------</h1>
<div class="rating"><span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span></div>
<div id="info-pop-description" style="word-wrap: break-word;">null</div>
<ul>
<li class="focusable" data-href="movie-play">Play</li>
<li class="focusable" data-href="movie-details">Details</li>
</ul>
</div>
</div>
</div>
</body>
</html>
It's not clear what you're trying to accomplish, but I can make Chrome work like Firefox by getting rid of the
position: fixed;
style from #content. Whether that will work in the larger context of your layout, I don't know, but the problem is that the way z-index works is weird and complicated, and involves not just individual fixed elements but also any fixed parents they might have.
edit — oh also, set the z-index of .snippet-pop-info to 2. Here is an updated version of your fiddle.
Make your
.bar-header, .bar-footer{
z-index:0;
}
This will do the trick. Since your z-index for .bar-header and .info-pop-title are the same.
Add z-index in your content div
#content
{
position:fixed;
top:0;
z-index:1;
}
I'm afraid you can't make it work with the way your html is nested.
The element you want to pull on top to cover the rest is located in the main container while your second element is isolated in the header. If you want to bring your info-pop-title there you'll have to change the z-index of your #page element, which will cover everything.
The only thing I see you can achieve with this structure would be to position your diverse containers relatively and change the css of your info-pop-title with a negative margin, position absolutely this time.

Fit to height of browser's window

I want to achieve the following layout with 100% height to browser.
Only the content area should be scrollable, when required and footer should be display at the bottom of browser.
But after tried many times i got this one
by using following code.
html { height:100%; }
body { position:absolute; height: 100%; overflow: hidden; top:0; bottom:0; right:0; left:0; padding: 0px; margin: 0px;}
#header, #footer {
float: left;
width: 100%;
/*height: 100px;*/
background-color: #808080;
}
#wrapper {
overflow: scroll;
height: 100%;
width: 999px;
margin: auto;
}
//HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Satkar Travels</title>
<meta name="keywords" content="ltc, travel, Satkar Travels, lfc, Satkar Parivar, Satkar Holidays, Satkar Travels Gurgaon">
<meta name="description" content="A Leader in LTC Travel.">
<meta name="author" content="Satkar Travels">
<link rel="stylesheet" href="StyleSheet.css" type="text/css">
</head>
<body>
<div id="header">
<br><br>
</div>
<div id="wrapper">
<div id="content">
<section>
<p>
</p>
</section>
<section>
<p>
</p>
</section>
<p>
</p>
</div>
</div>
<div id="footer">
<br><br>
</div>
</body>
</html>
please help
Thank you.
Try this example:
.header {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 50px;
background-color:red;
}
.container {
position: absolute;
top: 51px;
bottom: 51px;
left: 50%;
width: 900px;
margin-left: -450px;
overflow: auto;
background-color: blue;
}
.footer {
position: absolute;
bottom: 50px;
left: 0;
right: 0;
height: 50px;
background-color:red;
}
And then this:
<div class="header"> </div>
<div class="container"> </div>
<div class="footer"> </div>
Here is a fiddle: http://jsfiddle.net/dxL7s/
Is this what you need?
Just need to change in CSS.
Example: demo
or
Apply this css:
html { height:100%; }
body { position:absolute; height: 100%; overflow-x: hidden; top:0; bottom:0; right:0; left:0; padding: 0px; margin: 0px;}
#header{
float: left;
width: 100%;
/*height: 100px;*/
background-color: #808080;
}
#footer {
width:100%;
position:fixed;
bottom:0;
left:0;
background:#808080;
}
#wrapper {
overflow: scroll;
height: 100%;
width: 999px;
margin: auto;
}
I would use fixed position, to align the header and footer at the top and bottom. Then just leave the content with a margin-top to keep it below the header.
HTML:
<header></header>
<div id="mainContent">
Lorem ipsum
</div>
<footer></footer>
CSS:
header {
height: 50px;
width: 100%;
background-color: #f00;
position: fixed;
top: 0;
}
footer {
height: 50px;
width: 100%;
background-color: #ff0;
position: fixed;
bottom: 0;
}
div#mainContent {
margin-top: 60px;
}
Fiddle demo: http://jsfiddle.net/w22dr/1/

Categories