CSS smooth move animation not working - css

The css animation code isn't working. When #tools_button is checked, I want #tools_hidden to become visible and move from top:0% to top:6% smoothly.
Here is the code:
#tools_hidden {
position: fixed;
left: 10%;
top: 0;
display: none;
-webkit-transition: width 2s;
/* For Safari 3.1 to 6.0 */
transition: top 0.5s;
}
#tools_button:checked~#tools_hidden {
position: fixed;
left: 10%;
top: 6%;
display: block;
}
<div id="tools">
<span>
<input type="checkbox" id="tools_button">
<label for="tools_button">
<img src="img/tools.png" id="tools_icon" alt="">
<span id="tools_label">
Tools
</span>
</label>
<span id="tools_hidden">
this is hidden
</span>
</span>
</div>
Scripts are strictly restricted for my project. So, please don't think of adding scripts.

You can use animate opacity instead of display to get the effect you want:
#tools_hidden {
position: fixed;
left: 10%;
top: 0;
opacity: 0;
-webkit-transition: width 2s;
/* For Safari 3.1 to 6.0 */
transition: top 0.5s;
}
#tools_button:checked~#tools_hidden {
position: fixed;
left: 10%;
top: 6%;
opacity: 1;
}
<div id="tools">
<span>
<input type="checkbox" id="tools_button">
<label for="tools_button">
<img src="img/tools.png" id="tools_icon" alt="">
<span id="tools_label">
Tools
</span>
</label>
<span id="tools_hidden">
this is hidden
</span>
</span>
</div>

Maybe it's not possible to do with display property.
So, I've changed the first position of div to -6% and removed both display: none and display: block.
Here is the new css code:
#tools
{
height:6vh;
background-color:#747474;
font-size:5em;
}
#tools_icon
{
height:90%;
width:5vh;
}
#tools_hidden
{
height:6vh;
background-color:#747474;
font-size:1em;
position:fixed;
left:10%;
top:-6%;
-webkit-transition: top 2s; /* For Safari 3.1 to 6.0 */
transition: top 0.5s;
}
#tools_button:checked ~ #tools_hidden{
position:fixed;
left:10%;
top:7%;
}
The HTML code is still the old one.

Related

css transition not working correctly in vuejs

I am trying to animate the slide in/out of my flyout however it doesn't transition but appear and disappear in the same place.
in chrome devtools the animation works if I tick/untick right: 0;
How can I slide in/out the flyout correctly?
<template>
<portal to="modalPortal">
<div
v-if="isMoreOffersFlyoutActive"
:id="id"
class="flyOut"
#click.self="sendCloseModal(true)">
<div
:class="['flyOut__container', {'flyOut__container--active': isMoreOffersFlyoutActive}]">
<div class="flyOut__buttonContainer">
<button
id="storeInfoClose"
class="flyOut__button"
#click="sendCloseModal(false)">
<icon
:scale="closeButtonIconScale"
name="close"
color="white" />
</button>
</div>
<div class="flyOut__content">
<slot />
</div>
</div>
</div>
</portal>
</template>
.flyOut {
position: fixed;
top: 0;
left: 0;
z-index: z("overlay");
display: flex;
justify-content: flex-end;
width: 100%;
height: 100%;
overflow: auto;
background-color: $black-alpha;
&__container {
position: relative;
z-index: z("modal");
right: -50%;
width: 50%;
height: 100%;
background-color: $white;
box-shadow: -2px 0 15px 5px rgba(0,0,0,0.2);
transition: right ease 0.5s;
&--active {
right: 0;
transition: right ease 0.5s;
background: #ff00ff;
}
}
There isn't really an issue with Vue here. The problem stems from trying to animate a position between two different units (or in your case units and no units). Changing right: 0; to right: 10%; would probably work.
All that said, PLEASE don't animate CSS position. It's not performant and causes the browser to reflow & repaint stuff. The better solution is to use css translate(). Here's an example...
.wrapper {
/* need a positioned container for SO's editor */
position: fixed;
top:0; right:0; bottom:0; left:0;
overflow:hidden;
}
.action{
margin: 30px;
font-size: 18px;
font-weight: bold;
cursor:pointer;
font-family: sans-serif;
}
.moved{
position: absolute;
/* put the element where you want it */
top:0;
right:0;
bottom:0;
width: 150px;
background: #333;
padding: 20px;
color: #fff;
/* use transform to move to a new position (100% of element width) */
transform: translatex(100%);
transition: transform 0.5s cubic-bezier(.47,1.64,.41,.8);
}
.action:hover+.moved {
transform: translatex(0);
}
<div class="wrapper">
<div class="action">Hover Me</div>
<div class="moved">Transformed element</div>
</div>

IE behaving completely different for Iframes

I have an iframe which is the target area to display a completely different website inside my website. In Mozilla and chrome I can see the desired output but in Internet explorer sidebar div is completely located in a different manner.
Here goes the html code
<div class="menu_sample top_mar">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li><span style="color:blue; font-weight:bold;">Dashboards</span></li>
{% for Dashboard in dashboards %}
<li>{{ Dashboard.d_name }}</li>
{% endfor %}
</ul>
</div>
</div>
<button class="pushed content" onclick="toggleMenu()" style="margin-top:28%;height:4%;"><span id="menu-button"><span class="glyphicon glyphicon-chevron-left" id="glymphi" style="margin-left:24%;"></span></span></button>
<div style="margin-left:-1%; margin-top:2.5%; height: 625px;" >
<iframe width="100%" height="100%" name="iframe_a" frameborder="0"></iframe>
</div>
and css is
/* Styles go here */
.menu_sample {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100px;
border: solid 1px;
transition: transform 0.1s ease-out;
}
.content {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
transition: left 1s ease-out;
margin-left: -1.5%;
margin-top: 150%;
}
/*transition*/
.top_mar {
margin-top: 25%;
}
/* on toggle*/
.content.pushed {
left: 225px;
}
.hide {
transform:translateX( -100px);
}
can anyone help me to solve this compatibility problem.
in IE---
in chrome---
I may be mistaken, but it looks to me the culprit is the chevron button glyphicon-chevron-left,
and not the iframe;
try giving your button a width, e.g.:
style="margin-top:28%;height:4%;width:20px"
otherwise IE will give it maximum width, which is not what you want.
Now to prevent IE scrollbar from overlapping your content:
html { -ms-overflow-style: scrollbar; }

My simple gallery using css transitions isn't working

I've been trying to create a very simple gallery with a main image and three thumbnails down the right side, which when hovered over will display themselves as the main image. I used a found jfiddle and tried to edit it for my own needs but seem to have agot a bit mixed up along the way! This is my first time using css transitions to create something like this so it could quite possibly be something very obvious - i just can't see it.
The code I have is as follows:
<div id="gallery">
<div class="thumb" id="thumb-1"><img alt="" src="/wp-content/themes/magicmirror/images/gallery1-thumb.jpg" /></div>
<div class="main"><img alt="" src="/wp-content/themes/magicmirror/images/gallery1-main.jpg" /></div>
<div class="thumb" id="thumb-2"><img alt="" src="/wp-content/themes/magicmirror/images/gallery2-thumb.jpg" /></div>
<div class="main"><img alt="" src="/wp-content/themes/magicmirror/images/gallery2-main.jpg" /></div>
<div class="thumb" id="thumb-3"><img alt="" src="/wp-content/themes/magicmirror/images/gallery3-thumb.jpg" /></div>
<div class="main"><img alt="" src="/wp-content/themes/magicmirror/images/gallery3-main.jpg" /></div>
</div>
#gallery {
position: relative;
width: 470px;
height: 350px;
float: left;
margin: 0 35px 20px 0;
}
#gallery .thumb img {
height: 110px;
width: 110px;
}
#gallery .main img {
height: 350px;
width: 350px;
}
#gallery .thumb {
cursor: pointer;
left: 357px;
position: absolute;
display: block;
width: 112px;
height: 112px;
border: 1px solid #6d6d6d;
}
#thumb-2 {
top: 117px;
}
#thumb-3 {
top: 234px;
}
#gallery .main {
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
position: absolute;
border: 1px solid #6d6d6d;
}
#gallery .thumb:hover + .main {
opacity:0;
}
Hovering on the thumbnail should show the corresponding image in the main view. But you're doing it reversely (which hides the image in the main view with opacity:0). So try changing it like this:
#gallery .main {
opacity: 0; /* changed 1 to 0 */
...
}
/* always show the first initially */
#gallery > .main:nth-of-type(2) {
opacity:1;
}
#gallery .thumb:hover + .main {
opacity:1; /* changed 0 to 1 */
}
Demo.
NOTE: The demo just solves your problem mentioned in the question. To make it an acceptable gallery, I think you have to change the layout (HTML code) if you want a pure CSS solution, otherwise you have to add more script code.

Trouble creating a navigation bar

I'm trying to create little navigation bar that will stay on certain position of the page even the the user is scrolling through it. I'm a total noob so I started out using the css for a navigation button from the template that i'm using. But for the life of me I cannot figure out how to add two more buttons. I'm sorry if this is a supernoob question but I could really use the help. Thanks guys!
The website is www.muzedimage.com
this is what I have in mind: http://i.imgur.com/oN6osxv.jpg
The HTML segment for the button is:
<div class="downArrow">
<div class="row">
<div class="large-1 small-2 column push-11">
<i class="icon-chevron-down"></i>
</div>
</div>
</div>
The CSS Style Sheet:
section.banner {
float: left;
width: 100%;
position: relative;
overflow: hidden;
}
section.banner .downArrow {
float: right;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
z-index: 100;
text-align: center;
}
section.banner .downArrow a.down {
float: left;
width: 50%;
height: 60px;
background: #cb7039;
text-align: center;
}
section.banner .downArrow a.down i {
color: white;
font-size: 1.688em;
line-height: 60px;
-webkit-transition: line-height 0.1s ease-in;
-moz-transition: line-height 0.1s ease-in;
-o-transition: line-height 0.1s ease-in;
transition: line-height 0.1s ease-in;
}
section.banner .downArrow a.down:hover i {
line-height: 80px;
}
Here is a little FIDDLE that can give you a start.
Spend your time playing with the CSS.
And add/style as many buttons as you want.
HTML
<div class='holder'>
<div class='button1'>X</div>
<div class='button1'>Y</div>
<div class='button1'>W</div>
<div class='button1'>Z</div>
</div>

Text on Image Mouseover - CSS Positioning

I am using this fork code to display text on mouseover of an image.
http://codepen.io/anon/pen/hxqoe
HTML
<img src="http://placekitten.com/150" alt="some text" />
<img src="http://placekitten.com/150" alt="more text" />
<img src="http://placekitten.com/150" alt="third text" />
<div id="text"></div>
CSS
div {
display: none;
position: absolute;
}
img:hover + div {
display: block;
}
JQUERY
$('img').hover(function() {
$('div').html($(this).attr('alt')).fadeIn(200);
}, function() {
$('div').html('');
});
I am looking for the div text to be displayed inside each image instead of a stationary div.
Any ideas?
You actually don't need jQuery for this. It can easily be achieved with pure CSS.
In this example, I use the :after pseudo element to add the content from the alt attribute of the parent div. You can add whatever styling you want..
jsFiddle here - Updated to include a fade
HTML - pretty simple
<div alt="...">
<img src="..."/>
</div>
CSS
div {
position: relative;
display: inline-block;
}
div:after {
content: attr(alt);
height: 100%;
background: rgba(0, 0, 0, .5);
border: 10px solid red;
position: absolute;
top: 0px;
left: 0px;
display: inline-block;
box-sizing: border-box;
text-align: center;
color: white;
padding: 12px;
font-size: 20px;
opacity: 0;
transition: 1s all;
-webkit-transition: 1s all;
-moz-transition: 1s all;
}
div:hover:after {
opacity: 1;
}
Change your javascript to this:
$('img').hover(function() {
$('div').html($(this).attr('alt')).fadeIn(200);
$('div').css('left',$(this).offset().left + 'px');
$('div').css('top',$(this).offset().top + $(this).height() - 20 + 'px');
}, function() {
$('div').html('');
});
And that should do the trick.
I would wrap your images in some kind of wrapper and then use CSS for the hover effect (DEMO).
HTML:
<div class="img-wrapper">
<img src="http://placekitten.com/150" alt="some text 1" />
<div class="img-desc">some text 1</div>
</div>
CSS:
.img-wrapper {
position: relative;
display: inline;
}
.img-desc {
display: none;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
background: #FFF;
opacity: 0.6;
padding: 5px;
}
.img-wrapper:hover .img-desc{
display: block;
}
I added an alternative solution with additional css transition to the demo.
To get a transition just control the visibility with opacity:
.img-desc {
/*...*/
opacity: 0;
/*...*/
}
.img-wrapper:hover .img-desc{
opacity: 0.6;
transition: opacity 0.4s ease-in;
}

Resources