Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
Following on from another SO question.
Is it possible to expand the div, left and right instead of the answers on the other SO question which only expand to the right and down...
cheers
Of course it is.
Structure
You need a parent container set to position: relative; and your actual div set to position: absolute;
This way you can modify position of your div without any worry. This should work as a starting point. You can see the child div being shifted top and left compared to the parent.
<style>
.parent {
position: relative;
width: 200px;
height: 200px;
background: yellow;
margin: 40;
}
.child {
position: absolute;
top: -10px;
left: -10px;
width: 100px;
height: 100px;
background: red;
}
</style>
<div class="parent">
<div class="child">
</div>
</div>
Expansion
so for the actual expansion, you would have to animate / change the left / top position together with width and height of the box.
For every 1px you shift your box left, you have to increase its width by 2px! to get an even expansion.
$('.child').animate({'left' : '-=10px', 'width' : '+=20px'});
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Stumbled upon this example on the web
https://redq.io/react-next-landing
So how is this effect called that the main slider seems to be unmovable and the rest of the body covers it while scrolling?
It's actually position: fixed. Fixed removes the element from the normal document flow which sticky does not. For this to proberly work the scrolling part has to be "above" the top part. Which is done with z-index: int as you can see in the following screenshot:
You can read more about in the link shared by Roko.
It's called sticky
Achieved using CSS position: sticky; and top: /*i.e:*/ 0px; you can find more info here:
https://developer.mozilla.org/en-US/docs/Web/CSS/position
If the element was just to move at a different pace (slower then the rest of the document scroll) than it would be called: parallax.
Sticky slideshow example:
/* Quick Reset */ * {margin:0; box-sizing: border-box;}
header,
main,
footer {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
header {min-height: 100vh; background: gold; position: sticky; top: 0; }
main {min-height: 100vh; background: white;}
footer {min-height: 50vh; background: grey;}
<header><h1>ABOVE THE FOLD SLIDESHOW</h1></header>
<main><div>MAIN CONTENT</div></main>
<footer><div>Footer links etc</div></footer>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
In React on a button click I make a small component (compSmall) visible on top of another big component (compBig). using css properties on compSmall such as
position: absolute;
width: 300px;
height: 150px;
margin-left: 40%;
margin-top: 200px;
border: 1px solid #0083a5;
z-index: 100;
But when compSmall is visible on top of compBig, background (means content of compBig) still visible . But I want content of compBig is to be not visible clear or blur when compSmall is visible.
How to achieve this.
PS:
I can only apply properties on compSmall, not on CompBig. Since CompBig is the whole application component except compSmall.
What about make compSmall with the same size of compBig, so you will not see the compBig and inside the compSmall you can create another component or just a div with those css properties.
JSX
<CompBig>
<CompSmall className="compSmall">
<div className="content"></div>
</CompSmall>
</CompBig>
CSS
.content {
position: absolute;
width: 300px;
height: 150px;
margin-left: 40%;
margin-top: 200px;
border: 1px solid #0083a5;
z-index: 100;
}
.compSmall {
/* Add the blur effect */
filter: blur(8px);
height: 100%;
width: 100%
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a div in which, I need to display the div as shown in the image below.
Can we acheive this using css or with any script. Need help
Thanks
Use perspective and transform: rotate.
If you take a look at this link, perspective, you'll find some interesting things one can do
div {
margin-top: 40px;
perspective: 100px;
}
img {
height: 150px;
transform: rotateY(15deg);
}
<div>
<img src="http://lorempixel.com/500/200/nature/1/" alt="">
</div>
This is basic idea.
.parent {
perspective: 600px;
}
.child {
width: 100px;
margin: auto;
height: 35px;
text-align: center;
background: red;
transform: perspective(500px) rotateY(35deg);
}
<div class="parent">
<div class="child">Banners</div>
</div>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Imagine div1 and div2. div1 has 100% width and is 800px high. div2 is fixed to top of browser, also has 100% width and is maybe 3000px high. I am trying to land so you see div1 but, when you scroll down, div1 slides up out of the way, revealing div2 and all it's content. It seems easy but, I can't figure it out.
div1 {
width:100%;
height: 800px;
position: ???;
z-index:100;
background-color: white;
}
div2 {
width:100%
height: 3000px;
position: fixed;
background-color: black;
}
First off, your sample code has some flaws such as wrong CSS selectors (unless you created custom tags named "div1" etc.), a missing ending ; in div2 CSS rule (width:100%). You also need to position your fixed div at left/top 0 to position it behind the moving div.
To make your moving div move, add a bottom margin the size as its height and it will scroll out of sight/viewport.
This technique is sometimes called parallax scrolling and here is a post showing more how/what one can do
.div1 {
width:100%;
height: 800px;
position: relative;
z-index:100;
background-color: white;
margin-bottom: 800px;
}
.div2 {
top: 0;
left:0;
width:100%;
height: 3000px;
position: fixed;
background-color: black;
}
<div class="div1"></div>
<div class="div2"></div>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
As mentioned in the title, https://onlycoin.com/ has a smooth mouse scroll effect of the cards getting animated when we scroll.
I want to achieve something similar to that. I have made the webpage. Instead of the cards, I have mobile phones that will animate in that .
Can anyone help me on how I should proceed to do it ?
I have already done the HTML coding on the page and I am really confused with the jquery.animate(); function.
Therefore, the only reference site i know is the one I posted above.
I am a novice in jquery.
Thanks for your help.
It's pretty hard to provide you with a complete explanation, but I put this together to get you started:
http://jsfiddle.net/Ms7gw/
HTML
<div id="container">
<div class="box" id="right"></div>
<div class="box" id="center"></div>
<div class="box" id="left"></div>
</div>
CSS
#container {height: 1000px; width: 1000px; background-color: #000;}
.box {width: 100px; height: 100px; position: absolute; left: 50%; top: 50%; margin-left: -50px; margin-top: -50px; background-color: #ff0000;}
#right {background-color: #aa0000;}
#left {background-color: #aa0000;}
JS
var lastScrollTop = 0;
var leftBox = $('#left').position();
var rightBox = $('#right').position();
$(window).scroll(function(event){
var st = $(this).scrollTop();
$('#right').css({left: rightBox.left + st});
$('#left').css({left: leftBox.left - st});
lastScrollTop = st;
});