As you resize the window, the floating divs will wrap to the next line as expected. But I would really like this layout change to be animated.
EDIT: As an aside, it would be nice to find a solution to this that does not depend on JQuery. I don't mind writing my own js if I need to. Ideally I'd like to implement this into a AngularJS directive once I see it working, hence hence why I don't want the jQuery dependency.
Here is a shortened version of my code: http://jsfiddle.net/cDS7Q/3/
HTML
<div id="content">
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
</div>
And here is my CSS
body {background-color: #333;}
#content div {
position: relative;
float: left;
background-color: #eee;
margin-left: 10px;
margin-bottom: 10px;
width: 100px;
height: 100px;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
#content {
margin-top: 50px;
padding-top: $gutter;
padding-bottom: 50px;
overflow: hidden;
width: 100%;
}
The effect I'm trying to achieve is similair to this site: http://saffron-consultants.com/journal/
Resize the window to see the blocks animate into their new positions.
You could try quicksand for this.
http://razorjack.net/quicksand/
It is possible with css, but only if you change parameters with media queries.
For example:
If you change the width of an element, or the padding and margin with media queries, than you will get an animation.
Also, if you position divs absolute or relative and change the positions in the media queries then it work.
But not with simple floating / wrapping. For that you will need JavaScript / jQuery.
for example add this to your fiddle:
body {
background-color: #333;
}
#content div {
position: relative;
float: left;
background-color: #eee;
margin-left: 20px;
margin-bottom: 20px;
width: 200px;
height: 200px;
-webkit-transition: all .7s ease;
-moz-transition: all .2s ease;
-ms-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
#content {
margin-top: 50px;
padding-top: $gutter;
padding-bottom: 50px;
overflow: hidden;
width: 100%;
}
#media screen and (max-width: 480px) {
#content div {
margin-left: 10px;
margin-bottom: 10px;
width: 100%;
height: 100px;
}
}
Related
I wanting a header bar that slides vertically into view from negative top.
Rather than simply appears as if being behind a curtain.
The following is animated using height :-
https://jsfiddle.net/AaronNGray/kf0br46u/31/
HTML
<div id="box">
<div id="content">AaronNGray</div>
</div>
CSS
body {
margin: 0px;
padding: 0px;
}
#box {
height: 100px;
width: auto;
background: transparent;
transition: all 0.4s ease-in-out;
}
#content {
overflow: hidden;
width: auto;
background: white;
height: 0px;
transition: all 0.4s ease-in-out;
border-bottom: 2px solid black;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
}
#box:hover > #content {
height: 50px;
top: 0px;
}
What I need is to be able to animate top so the content div slides downwards from off the top of the screen.
This is what I have tried but it does not work :-
https://jsfiddle.net/AaronNGray/kf0br46u/40/
body {
margin: 0px;
padding: 0px;
}
#box {
height: 100px;
top: -50px;
width: auto;
background: transparent;
transition: top 0.4s ease-in-out;
}
#content {
overflow: hidden;
width: auto;
background: white;
top: -50px;
height: 50px;
transition: top 0.4s ease-in-out;
border-bottom: 2px solid black;
-webkit-transition: top .8s ease;
-moz-transition: top .8s ease;
-ms-transition: top .8s ease;
-o-transition: top .8s ease;
}
#box:hover > #content {
top: 0px;
}
Hope you can help and its probably something simple I am missing, usually is :)
There are a couple of problems.
First, positioning with e.g. top does not work if the element's position is not defined (and if it is, the positioning is in relation to the first ancestor which itself is positioned).
Second, the box element is positioned at -50px (half its height) which is fine, but the content is put -50px which would put it at -100px (if it were positioned at all).
Here's a snippet with your code with these two things altered:
body {
margin: 0px;
padding: 0px;
position: relative;
}
#box {
height: 100px;
top: -50px;
width: auto;
transition: top 0.4s ease-in-out;
position: relative;
}
#content {
overflow: hidden;
position: relative;
top: 0px;
width: auto;
height: 50px;
transition: top 0.4s ease-in-out;
border-bottom: 2px solid black;
}
#box:hover #content {
top: 50px;
}
<div id="box">
<div id="content">AaronNGray</div>
</div>
StackOverflow has a monopoly on Google and the Internet and is abusing this by stopping people asking questions that they really need to ask in order to do their work. You may regard this question as stupid but theres no where else you cn get CSS answers anymore you have killed off all the other CSS forums !!!!!
I am confused with soemthing most likely quite simple, but I can't figure it out. I want Image 2 to cover Image 1 when I hover over Image 1.
So, the goal is to overlap Image 1 with an Image 2 containing a semi-transparent color gradient. I know this could somehow be achieved with pure CSS, but I need it this way.
The below CSS Code was taken from another Typo3 CMS Website and there it works.
However, I can't seem to make it work on another part/element of that Typo3 website, I even can't make it work on a simple basic HTML page like this one.
<!DOCTYPE html>
<html>
<body>
<style>
.container {
height: 300px;
width: 500px;
position: relative;
background-color: red;
}
img {
position: relative;
height: 100%;
width: 100%;
}
.container .hover-second-image-over-first-image:hover {
width:100%;
height:100%;
background-image:url(image_02.jpg);
background-position:top left;
background-repeat: no-repeat;
background-size:100%;
position:absolute;
opacity:0;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
</style>
<div class="container">
<div class="hover-second-image-over-first-image"></div>
<img src="image_01.jpg" />
</div>
</body>
</html>
Edit:
Ok, so "z-index:10;" did fix it for me. This code here works:
.container {
height: 300px;
width: 500px;
position: relative;
background-color: red;
}
img {
position: relative;
height: 100%;
width: 100%;
}
.container .hover-second-image-over-first-image {
width:100%;
height:100%;
background-image:url(image_02.jpg);
background-position:top left;
background-repeat: no-repeat;
background-size:100%;
position:absolute;
z-index:10;
opacity:0;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.container:hover .hover-second-image-over-first-image {
opacity:.3;
}
But I still wonder why the code worked before on that other website WITHOUT any z-index position...
A few things to keep attention here :
Don't put your styles inside the <body> tag
Try to style the layer you want to see over the image whitout the use of the :hover state so it must be .container .hover-second-image-over-first-image
Use the :hover action on all the .container element
.container {
height: 300px;
width: 500px;
position: relative;
background-color: red;
}
img {
position: relative;
height: 100%;
width: 100%;
}
.container .hover-second-image-over-first-image {
width: 100%;
height: 100%;
background:blue;
opacity:0;
position: absolute;
top:0;
left:0;
z-index:10;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.container:hover .hover-second-image-over-first-image {
opacity:.7;
}
<div class="container">
<div class="hover-second-image-over-first-image"></div>
<img src="http://placehold.it/200" />
</div>
Looking at most of the examples in bootstrap, I see that sidebars have css of left:250px and margin-left:-250px.
Why not just have left: 0px which would give the same result?
Example:
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
I noticed in one project that used the practice, there were various #media queries that changed the sidebar to have different widths (and therefore different corresponding values for left and margin-left) at different window sizes.
One feature of doing this is that to hide the sidebar, one could simply call left: 0, and it would move the sidebar by its full width regardless of the current width of the sidebar. This is better than using display: none because it can be animated to slide off of the screen, and different than calling width: 0 because the sidebar could still be visible in the case that it wasn't going off-screen.
For example:
$("button").click(function() {
$(".sidebar, .content").toggleClass("hiddenSidebar");
});
body { margin: 0 }
.content {
left: 100px;
position: relative;
transition: all 0.4s ease 0s;
}
.sidebar {
width: 100px;
left: 100px;
margin-left: -100px;
height: 500px;
background: black;
position: fixed;
transition: all 0.4s ease 0s;
}
#media (max-width: 767px) {
.content { left: 50px; }
.sidebar {
width: 50px;
left: 50px;
margin-left: -50px;
}
}
.hiddenSidebar { left: 0; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sidebar"></div>
<div class="content">
<button>Toggle Sidebar!</button>
</div>
I'm currently attempting to have a with an image fade in when I hover over some text using CSS. I've applied the CSS code, but the effect doesn't show; the div appears, but without the fade-in.
Also, I realize that CSS transitions don't really work with IE. If anyone could point me in the right direction of a workaround for that, it would be much appreciated. (:
CSS:
.thumbnail{
position: relative;
z-index: 0;
}
.thumbnail:hover{
background-color: transparent;
z-index: 50;
}
.thumbnail span{ /*CSS for enlarged image*/
position: relative;
display: none;
color: black;
text-decoration: none;
opacity:0.0;
filter:alpha(opacity=0);
}
.thumbnail span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 5px;
left: -1000px;
border: 1px solid gray;
background-color: #fff;
}
.thumbnail:hover span{ /*CSS for enlarged image on hover*/
position: relative;
display: inline;
top: -290px;
left: -25px;
opacity:1.0;
filter:alpha(opacity=100);/*position where
enlarged image should offset horizontally */
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
#networking {
width: 200px;
height: 140px;
margin-left: 360px;
top: 115px;
position: absolute;
background-color: #613286;
opacity:1.0;
filter:alpha(opacity=100);
color: #ffffff;
text-align:center;
border-radius: 20px;
-webkit-transform: rotate(14deg);
-moz-transform: rotate(14deg);
-ms-transform: rotate(14deg);
-o-transform: rotate(14deg);
transform: rotate(14deg);
}
HTML:
<div id="networking">
<a class="thumbnail" href="1.5.2experientialstudios.html#down4"><h4>Networking Lounge</h4>
<span><img src="images/net3.jpg" width="250" /></span></a>
</div>
Thank you!
Try with removing your display rule:
.thumbnail span{ /*CSS for enlarged image*/
position: relative;
/*display: none; remove this */
color: black;
text-decoration: none;
opacity:0.0;
filter:alpha(opacity=0);
}
As you have opacity 0 you won't need display:none and you can't make a transition between not displayed at all to inlined as they are different types.
And modify this rule:
.thumbnail:hover span { /*CSS for enlarged image on hover*/
top: 0px; /* adjust as needed */
left: -25px;
opacity:1.0;
filter:alpha(opacity=100);/*position where
enlarged image should offset horizontally */
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
(the hover and then span can make it a bit jumpy).
I also added a ms prefixed version to transitions. It is apparently not useful in this context.
For IE9 and below you can use jQuery to fade in an element (or simply use vanilla JavaScript to modify the opacity in a setTimeout loop).
Fiddle here:
http://jsfiddle.net/AbdiasSoftware/9rCQv/
Is this what you're after?
I have this code for a banner that will reveal a drop down section when hovered over:
The HTML code below:
<div id="top_wrapper" class="hori_wrapper wrapper">
<div id="top" class="hori_banner banner"></div>
<div id="top_reveal" class="hori_reveal reveal"></div>
</div>
And the CSS:
.wrapper {
border: dashed;
position: relative;
}
.banner {
background: blue;
position: relative;
}
.reveal {
background: red;
position: absolute;
z-index: 1;
}
.hori_wrapper {
width: 300px;
height: 50px;
clear: both;
}
.hori_banner {
width: 300px;
height: 50px;
}
.hori_reveal {
width: 300px;
height: 0px;
}
#top:hover + #top_reveal, #top_reveal:hover {
-webkit-transition: height 1s ease-in .5s;
-o-transition: height 1s ease-in .5s;
-moz-transition: height 1s ease-in .5s;
-transition: height 1s ease-in .5s;
height: 300px;
top: 50px;
}
Basically, what I'd like to know is: how does CSS determine that it should animate downwards and not some other direction?
Thanks!
All that happens is that it transitions to what would happen if the property was set normally.
In other words, if the height was 300px, and the top was 50px, what would it look like?
It's nothing more complex like that, and is why for browsers that don't support transitions things still work, just with no animation.