I have an image that I've gotten to rotate in an endless circle.
However, I'd like to know if it is possible to show only a section of the image. For example:
Below is the code I have to make the image rotate.
.vinyl {
height:2072px;
width:2072px;
display:block;
position:absolute;
top: -1150px;
left: -200px;
background:url('http://level42.ca/mike-vinyl/img/Record.png') right no-repeat;
-webkit-animation: spin 2s infinite linear;
-moz-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
-ms-animation: spin 2s infinite linear;
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
}
}
#-o-keyframes spin {
0% {
-o-transform: rotate(0deg);
}
100% {
-o-transform: rotate(360deg);
}
}
#-ms-keyframes spin {
0% {
-ms-transform: rotate(0deg);
}
100% {
-ms-transform: rotate(360deg);
}
}
This is going on a wordpress theme and is ideally going to fill the header background. (Approx 1500x300 px)
I've got the image in the header, but it is on top of all other objects, and covers have the webpage.
Hope this makes sense.
*Note, this is just a prototype/idea that I have, not sure if it will be practical or completely implemented at all.
[Edit 1]
Following the suggestion below, I was able to achieve exactly what I was looking for, however. The site-sponsorship class that I have is stuck in the background. How can I force it on top?
<header id="masthead" class="site-header" role="banner">
<div class="vinyl-wrapper">
<div class="vinyl-background">
</div>
<h2 class="site-sponsorship">
<div>
<span style="">Presented by: </span>
<img src="http://level42.ca/mike-vinyl/img/sunriselogo3.png" style="width:200px;height:62px;vertical-align:bottom">
</div>
</h2>
</a>
<div id="navbar" class="navbar">
<nav id="site-navigation" class="navigation main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
<a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
<?php get_search_form(); ?>
</nav><!-- #site-navigation -->
</div><!-- #navbar -->
</header><!-- #masthead -->
Certainly possible, you could wrap the rotating image inside of a container element with relative positioning and hidden overflow. For example, with a container .header:
.header{
width:100%;
height:200px;
/* These are the important styles */
position:relative;
overflow:hidden;
}
Here's a JSFiddle demonstrating the implemented code, using the same CSS that you provide. Hope this helps! Let me know if you have any questions.
EDIT: In your addition to your question, it doesn't look like you close .vinyl-wrapper. If this was intentional, then you could use z-index to get .site-sponsorship to appear on top:
.site-sponsorship {
position:relative;
z-index:1;
}
Otherwise (if .site-sponsorship is actually outside .vinyl-wrapper), the fix will need to be a bit different, and you could also absolutely position .site-sponsorship (still using z-index):
.site-sponsorship {
position:absolute;
z-index:1;
top:0;
}
Here's a JSFiddle showing the second fix.
Related
I would like to ask if you can show me how to make the "scroll tape bar" (I don't know the correct term for this object) that is in this store: https://thefutureofficial.eu/
"scroll tape bar here"
Thanks a lot guys.
Simone.
Use following Snippet to achieve this effect. You can style the text as per your choice.
.main {
background:#000;
padding:0.5rem;
overflow: hidden;
}
.text {
color:white;
animation : slide 10s linear infinite;
}
.gap{ margin-right:100px;}
#keyframes slide {
0% {
transform: translateX(100%)
}
100% {
transform: translateX(-100%)
}
}
<div class="main">
<div class="text">
<span class="gap">Text</span>
<span class="gap">Text</span>
<span class="gap">Text</span>
<span class="gap">Text</span>
</div>
</div>
I have a dropdown that I want a scaling down animation to show when the dropdown opens and closes. I have a CODEPEN here with the code for you to experiment in.
I slowed it down to a 10 sec animation (not the final speed obviously) just for you to see what I mean. The items are scaling down at the speed I instructed (10 sec) but the items below won't come down until the ng-animation is completed. This causes overlap.
This is what I have in my HTML
<div class="cnt">
<md-list ng-click="menuIsOpen = 1" layout="row" layout-padding="" class="layout-row" layout-align="start center" flex>
<span class="title flex" flex=""> Menu Item</span>
<i class="fa fa-chevron-down"></i>
</md-list>
<div class="sub-menu" ng-show="menuIsOpen===1" ng-animate="'animate'" >
<md-menu-item ng-repeat="item in data" >
<md-button>
<div layout="row" flex="">
<a ui-sref="{{item.link}}">
<p flex=""><i class="fa fa-{{item.icon}}"></i> {{item.title}}</p>
</a>
</div>
</md-button>
</md-menu-item>
</div>
<md-list ng-click="menuIsOpen = 2" layout="row" layout-padding="" class="layout-row" layout-align="start center" flex>
<span class="title flex" flex=""> Menu Item 2</span>
<i class="fa fa-chevron-down"></i>
</md-list>
<div class="sub-menu" ng-show="menuIsOpen===2" ng-animate="'animate'" >
<md-menu-item ng-repeat="item in data">
<md-button>
<div layout="row" flex="">
<a ui-sref="{{item.link}}">
<p flex=""><i class="fa fa-{{item.icon}}"></i> {{item.title}}</p>
</a>
</div>
</md-button>
</md-menu-item>
</div>
</div>
And the CSS
.ng-hide-remove {
-webkit-animation:2s scaleIn ease;
animation:2s scaleIn ease;
}
#-webkit-keyframes scaleIn {
From {
transform-origin: top;
-webkit-transform: scaleY(0);
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-o-transform: scaleY(0);
transform: scaleY(0);
}
To {
transform-origin: top;
-webkit-transform: scaleY(1);
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
transform: scaleY(1);
}
}
#keyframes scaleIn {
From {
transform-origin: top;
-webkit-transform: scaleY(0);
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-o-transform: scaleY(0);
transform: scaleY(0);
}
To {
transform-origin: top;
-webkit-transform: scaleY(1);
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
transform: scaleY(1);
}
}
I am essentially trying to reproduce the same animation as in the angular material website seen here
p.s. any different approach or idea that doesn't require too much change overall, I am open to it. I am hoping for a css modification, but I know that it may not be that easy after all. I am hopeful though :)
Thanks for the help.
UPDATE:
After a litte bit trial and error I think I found a SOLUTION.
If you animate not the div around (sub-menu) your md-menu-items but the item itself, it will work.
I just added ng-if="menuIsOpen===1" to your md-menu-item (deleted the ng-show="menuIsOpen===1 from the sub-menu) and changed the animation as follows:
md-menu-item.ng-enter{
-webkit-animation:3s move ease;
animation:3s move ease;
}
#-webkit-keyframes move {
From {
margin-bottom:-50px;
}
To {
margin-bottom:0px;
}
}
#keyframes move {
From {
margin-bottom:-50px;
}
To {
margin-bottom:0px;
}
}
Now the size of every item in the menu is animated.
I cheated a little bit with margin-bottom, but height was still not working.
I think you have two options. ( At least I can't think of anything more.)
Or maybe three, see above.
1.You can change the height and add transform-origin: top; like here:
#keyframes scaleIn {
From {
transform-origin: top;
-webkit-transform: scaleY(0);
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-o-transform: scaleY(0);
transform: scaleY(0);
height: 0px;
}
To {
transform-origin: top;
-webkit-transform: scaleY(1);
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
transform: scaleY(1);
height: 190px;
}
}
With transform-origin it will scale from the top and not from the middle.
BUT then you have to adjust the height every time you change the number of menu items.
You write it new (is probably nothig for you because you wont change much). I think there are definitely easier solutions like your posted example. e.g. see HERE
Only the styles are missing and everything works.
I tried to change the height to % too, but that just never worked.
Even add some divs and change some positions nothing happens.
So maybe someone else has a better solution.
Hopefully I wasn't to slow only just got time to look at this properly.
Edited Codepen
Now to start your main problem was using CSS animations rather then transitions. With transitions being better for this as you are transitioning from one state(open) to another(closed). Rather then a complex animation with no defined start or end state.
So what I've done is change your classes:
.sub-menu{
background: #333;
max-height: 500px;
position: relative;
display: block;
overflow:hidden;
}
.sub-menu.ng-hide{
max-height: 0;
}
.sub-menu.ng-hide-remove {
transition: max-height 700ms cubic-bezier(0.35, 0, 0.25, 1);
}
.sub-menu.ng-hide-add {
transition: max-height 600ms cubic-bezier(0.35, 0, 0.25, 1);
}
They now use transisiton. As well as max-height rather than height so that no specific height value needs to be given to the submenu to fully show it. Also using cubic-bezier for smoother transitioning.
Also I removed the ng-animate="'animate'" directives on elements as it isn't needed, it is the old way of adding animations. All classes are now managed by the ng-show directive and there is no ng-animate directive. The current ngAnimate docs can give more info about the classes.
The only other change made was to move the ng-show to the div with the submenu class, which was just so an extra class didn't need to be created for the <ul>.
I have a div and can neither use ID nor class.
I can only use names like so:
<div name="picture">
<img src="http://i.imgur.com/p0Fu5UZ.jpg" />
</div>
<div name="info">
<p>- Insert information here</p>
</div>
CSS:
div{
-webkit-animation: name 4s infinite linear
}
#-webkit-keyframes name {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
What's the appropriate way to select any particular div, because [name=picture] doesn't work with the crammed code nor the non-crammed code. What can i do to fix this?
It should work for you:
CSS:
div[name="picture"] {
-webkit-animation: name 4s infinite linear
}
#-webkit-keyframes name {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
HTML:
<div name="picture">
<img src="http://i.imgur.com/p0Fu5UZ.jpg" />
</div>
<div name="info">
<p>- Insert information here</p>
</div>
Demo: http://jsfiddle.net/srnug/121/
If you need the elements inside the div to rotate, then you can modify the selector as div[name="picture"] img or div[name="picture"] p
I am needing to fadeIn a list of text and then fade each one out individually using css. Here is an example I did using javascript. Any help would be appreciated. I have read some examples of how to animate stuff with css but do not know the best practices or anything to complex.
I am thinking I need to create a wrapper div with a overflow of hidden and a separate div with all the text that is position absolute in the wrapper. Then animate the .text div up or down to show the text. I have no experience with css animations.
Here is what I want to do but with css not javascript:
http://jsfiddle.net/trav5567/8ejqsywu/
Here is my javascript:
var quotes = $(".whoiam").find('h2');
var quoteIndex = -1;
quotes.hide();
function showNextQuote() {
++quoteIndex;
console.log(quoteIndex);
if(quoteIndex === quotes.length){
console.log($(this));
//console.log('index greater than or equal to h2 length');
//$(this).fadeIn('200');
}else{
console.log('Kepp going');
quotes.eq(quoteIndex % quotes.length)
.fadeIn(500)
.delay(500, checkIndex(quoteIndex,quotes.length))
.fadeOut(500, showNextQuote);
}
}showNextQuote();
function checkIndex(index, length){
var length = length-1
if(index === length){
console.log('check good');
end();
}
}
Here is my HTML:
<div id="splash-wrapper">
<div class="row">
<div class="small-12 columns">
<h1>Travis M. Heller</h1>
<div class='whoiam'>
<h2>Front End Developer</h2>
<h2>Illustrator</h2>
<h2>Web Master</h2>
<h2>Front End Developer</h2>//This value will be the last to show on loop.
</div>
<button class="btn center gotoPortfolio">ENTER</button>
</div>
</div>
</div>
An experiment with just css animations: http://jsfiddle.net/8ejqsywu/6/
There is one animation which moves the text list verticaly, and another which fades in and out the text. The difficulty was to synchronize them!
#container{
overflow:hidden;
height:48px;
}
.whoiam{
-webkit-animation: move;
position:relative;
-webkit-animation-duration: 8s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: step-start;
-webkit-animation-delay: 0.5s
}
h2{ height:48px;margin:0;padding:0}
#-webkit-keyframes move {
0% { margin-top: 0em; }
25% { margin-top: -48px; }
50% {margin-top: -96px;}
75% {margin-top: -144px; }
100% {margin-top: 0;}
}
h2{
-webkit-animation: fade;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
#-webkit-keyframes fade {
0% { opacity: 1; }
50% { opacity: 0; }
100% { opacity: 1; }
}
I am trying to solve an issue with CSS on my shortcode.
You can see it here in action:
http://www.mariovital.com/jose-ollin/sample-page
and the shortcode code:
// Add Shortcode
function servicos_shortcode( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'posicao' => '',
'icon' => 'default.png',
'titulo' => 'O Serviço',
'link' => '',
), $atts )
);
// Code
return '
<div class="span3 fp-'.$posicao.'">
<div class="widget-front">
<div class="thumb-wrapper tc-holder">
<a class="round-div" href="'.$link.'" title="'.$titulo.'"></a>
<img src="'.$icon.'" alt="'.$servico.'">
</div>
<!-- /.widget-front -->
<h4>'.$titulo.'</h4>
</div>
</div> ';
}
add_shortcode( 'servicos', 'servicos_shortcode' );
The problem is with the hover selector you can see on my test page. I really don't know what is wrong with the CSS code.
I assume that you want the hover effect should happen to a particular div when it hovers by users. And it should not happen to all of those divs at once. So here goes the solution -
On your CSS, you have setup hover effect for both <article> and <div class="widget-font">
.widget-front.hover .round-div,
article.hover .round-div {
-webkit-transform: scale(1.4);
-moz-transform: scale(1.4);
-ms-transform: scale(1.4);
-o-transform: scale(1.4);
transform: scale(1.4);
}
But if you don't want the hover effect should affect all the divs inside the article. So, just remove the article.hover .round-div from CSS and your final snippet should looks like this -
.widget-front.hover .round-div {
-webkit-transform: scale(1.4);
-moz-transform: scale(1.4);
-ms-transform: scale(1.4);
-o-transform: scale(1.4);
transform: scale(1.4);
}
EDIT :
I just have a look at your code. You still have article.hover .round-div on your CSS code. If the CSS is generating externally and you are not able to change that, you can add this following code at the end -
article.hover .round-div {
-webkit-transform: none;
-moz-transform: none;
-ms-transform: none;
-o-transform: none;
transform: none;
}