I have a disjointed rollover and I would like to add a timed ease-out (only) effect.
I made a page with just that particular issue isolated, see here:
When hovering over "overview" an over-view image shows up in a defined area and on roll-out the image disappears. All good but I now would like the image to fade-out after half a second, even if the pointer is still hovering over "overview" (not just only when the pointer is out). With other words, every time the visitor hovers over "overview" the image appears for half a second and then fades out.
I'm a newbie. CSS only would be great. I tried webkit ease-out/ease-in but couldn't really get it to show and then ease-out only.
The code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>raphaelzwyer</title>
<link href="css/raphaelzwyer.css" type="text/css" media="screen" title="raphaelzwyer stylesheet" rel="stylesheet" charset="utf-8"/>
<script type="text/javascript" src="js/raphaelzwyerFive.js"></script>
</head>
<body>
<div id="header">
<ul id="overviewlayer">
<li>
<a href="portfolio.html">
<div id="overviewtext">overview</div>
<div class="overview"><img src="images/overview.png" width="660" height="1284" alt="overviewlayer"/></div>
</a>
</li>
<li id="wordmark"></li>
</ul> <!-- end of overviewlayer -->
</div> <!-- end of header -->
</body>
</html>
The relevant CSS:
#header {
position: relative;
top: 36px;
left: 212px;
width: 660px;
height: 48px;}
#overviewlayer a .overview {
display:none;}
#overviewlayer a:hover .overview {
display: block;
position: absolute;
top: 116px;
left: 0px;
height: 852px;
width: 660px;
padding: 0px;
margin: 0px;
color: #000;
font-size: 11px;
background-color: #FFF;
z-index: +20;}
.overview {
position: relative;
top: 12px;
left: 0px;
height: 852px;
width: 660px;
z-index: +10;}
#overviewtext {
position: absolute;
top: 0px;
width: 100px;
height: 48px;
padding-top: 4px;
border-top-style: solid;
border-top-width: 1px;
z-index: +600;}
a {
text-decoration: none;
color: #a9a9a9;}
a:hover, a:focus {
text-decoration: none;
color: #be1f2d;}
li {
list-style-type: none;
display: inline;}
Perhaps you can use CSS3 animations for this ...
Add this line of code to { #overviewlayer a:hover .overview }
-webkit-animation: fade 1.0s ease-out forwards;
and then add the keyframes to your css.
#-webkit-keyframes fade
{
0% {opacity: 1;}
50% {opacity: 1;}
100% {opacity: 0;}
}
In this case, the image will show up immediately when you hover over 'overview' and then the image will fade out.
Since I've only added -webkit- for this example, don't forget to add the prefixes for Firefox, IE and Opera and keep in mind that this only works in modern browsers.
Hope that helps!
Related
Our Angular (v7) app has a splash animation that basically shows a rotating wheel (CSS animation) embedded into the index.html, so it shows instantly on page load.
This works fine, however every ~4 page loads there is a slight flicker of the zoom level (I am using the latest Chrome on Windows 10), meaning the square div which holds the "splash message" starts at one size, and then drops in about 5% of it's size. It happens very fast and about a second from the moment the static HTML contents are rendered to view, and before the Angular view is rendered. And it looks like some of the rendering engine is getting loaded lazily and something goes wrong (?)
Could it be that Angular is changing zoom/translation factor on page load?
Index.html
<!doctype html>
<html lang="en" class="mitzi-page-root">
<head>
<meta charset="utf-8">
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.mitzi-splash-view-indicator {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
-webkit-animation: fadein 2s;
animation: fadein 2s;
}
#keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
#-webkit-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
.mitzi-splash-indicator-dialog-bg {
position: absolute;
width: 15rem;
height: 12rem;
align-self: center;
border-style: solid;
border-width: .1rem;
border-radius: 1rem;
background: #FFFFFF;
border-color: #378b68;
-webkit-animation: fadein 5s;
animation: fadein 5s;
}
.mitzi-splash-indicator-loader-wrapper {
position: absolute;
left: 4.6875rem;
top: 2.2495rem;
width: 5.625rem;
height: 5.625rem;
padding-bottom: 3rem;
}
.mitzi-splash-indicator-loader {
width: 5.625rem;
height: 5.625rem;
align-self: center;
animation: mitzi-splash-indicator-spin 1s steps(8) infinite;
}
.mitzi-splash-indicator-message {
position: absolute;
top: 9.125rem;
width: 100%;
text-align: center;
height: 1rem;
line-height: 1rem;
font-family: 'Open Sans', serif;
font-size: 1rem;
font-weight: normal;
color: #2A6E52;
}
#keyframes mitzi-splash-indicator-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.mitzi-splash-indicator-spinner {
fill: #0c573c;
}
</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open Sans">
<link rel="shortcut icon" sizes="32x32" href="assets/img/favicon-mitzi.png" type="image/png" />
</head>
<body class="mitzi-body">
<mitzi-root>
</mitzi-root>
<div id="mitzi_app_preloader" class="mitzi-splash-view-indicator">
<div class="mitzi-splash-indicator-dialog-bg">
<div class="mitzi-splash-indicator-loader-wrapper">
<div class="mitzi-splash-indicator-loader">
<svg class="mitzi-splash-indicator-spinner" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" style="background: none;">
<!-- HERE COMES SOME **STATIC** SVG GRAPHICS THAT IS BEING ROTATED BY **CSS** (AND NOT BY SVG ANIMATIONS - WHICH *WOULD* MESS THINGS UP)... -->
</svg>
</div>
</div>
<span class="mitzi-splash-indicator-message">Loading ...</span>
</div>
</div>
<div style="display: none !important" id="hidden-div-for-assets-load-on-startup">
<img src="assets/img/common/error.svg">
<img src="assets/img/status_icons/form_error.png">
<span class="pi pi-times"></span>
</div>
<title>mitzi</title>
</body>
</html>
box-sizing was set by our own code .... which triggered a minor change in the size of the div
I am working on a website and I finally made a responsive menu that takes up the whole screen when you click on the label. The problem is, I cannot hide it(I want to use pure css) I created a new label in the menu that tries to close the menu but it doesn't work and I am assuming that it's because a child is trying to select a parent. I am new to CSS and would really appreciate any help on how to make a close button that closes the menu(width: 0%). Thank you!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>La Regina</title>
</head>
<body>
<div id="pagewrap">
<!--HEADER-->
<header class="pagesection" id="pageheader">
<div class="pagewidth">
<figure id="logo">
<img src="img/logo-full.png" alt="Logotype La Regina">
</figure>
<label for="toggle">☰</label>
<input type="checkbox" id="toggle">
<div id="myNav" class="overlay">
<nav>
<label for="toggle2">☰</label>
<input type="checkbox" id="toggle2">
Home
Menu
About us
Contact
</nav>
</div>
</div>
</header>
<!--END OF HEADER-->
</div>
</body>
</html>
html,
body,
figure {
padding: 0;
margin: 0;
list-style: none;
}
#pageheader {
background: #333;
position: fixed;
top: 0;
left: 0;
right: 0;
}
.pagesection {
padding-left: 11px;
padding-right: 11px;
}
#logo img{
width: 200px;;
}
.overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
right: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
}
#myNav > nav {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
#toggle{
z-index: 3;
}
#toggle2:checked < #myNav{
width: 0%;
}
#toggle:checked + #myNav{
width: 100%;
}
Unfortunately in CSS you cant go up the parent level.
But you can do this in Pure CSS.
#pageheader {
background: #333;
position: fixed;
top: 0;
left: 0;
right: 0;
}
.pagesection {
padding-left: 11px;
padding-right: 11px;
}
#logo img{
width: 200px;;
}
.overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
right: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
}
#myNav > nav {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
#toggle{
z-index: 3;
}
#toggle:checked + #myNav{
width: 100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>La Regina</title>
</head>
<body>
<div id="pagewrap">
<!--HEADER-->
<header class="pagesection" id="pageheader">
<div class="pagewidth">
<figure id="logo">
<img src="img/logo-full.png" alt="Logotype La Regina">
</figure>
<label for="toggle">☰</label>
<input type="checkbox" id="toggle">
<div id="myNav" class="overlay">
<nav>
<label for="toggle">☰</label>
Home
Menu
About us
Contact
</nav>
</div>
</div>
</header>
<!--END OF HEADER-->
</div>
</body>
</html>
As you can see I've removed one of the input fields (one inside the nav) and then changed the id of the for attribute inside the nav to point to the checkbox outside the nav making use of the selector
#toggle:checked + #myNav
What you want to affect is the overlay class but i do not believe you are able to do this with CSS.
You could do this with JQuery.
However, you can modify your current code so that the original toggle is still visible in the overlay and therefore when you untick that toggle, the overlay is removed.
So, in the html remove these two lines:
<label for="toggle2">☰</label>
<input type="checkbox" id="toggle2">
In your CSS change the 'top' to relative:
.overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: relative;
right: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
}
Give that a try otherwise, I would recommend you look into JQuery and the hide function
I would also encourage checking out Bootstrap at some point once you are comfortable with CSS since it is a great framework for mobile-first design.
I'm trying to get display:none to work for smaller screens. But I can't get it to work properly. The class disappears if I minimize the screen on my computer, but not when I check my phone.
I've tried the suggested solution on stack overflow of using display:none!important; to override the display:block in the info class, but that hasn't worked either. I've also tried taking out display:block from the info class but that didn't work. I don't think I can take out the display:block in .tooltip because then it messes with the layout.
HTML:
<div class="container">
<a href="#" class="info" data-tooltip-text="Header
Content."><img src="info_button.png"></img></a>
</div>
CSS:
.info {
display: block;
position: absolute;
top: 18px;
right: 30px;
text-align: right;
margin: 0;
padding: 0;
cursor: pointer;
text-decoration: none;
white-space:pre-wrap;
}
.tooltip {
display: block;
position: relative;
left: 0;
bottom: 120%;
width: auto;
padding: 10px;
background-color: #00DCFF;
color: White;
line-height: normal;
text-transform: none;
font-size: 16px;
opacity: 0;
transform: scaleY(0);
transition: all 0.2s ease;
white-space:pre-wrap;
}
.info:hover .tooltip {
opacity: 1;
transform: scaleY(1);
}
#media screen and (max-width: 768px) {
.info {
display: none!important;
}
}
You need to include the viewport meta tag in the head of your main html file. It looks something like this
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
Note that you can customize a few of the options you see in this tag.
I had a problem with border-radius in webkit browsers and found the solution at the following URL:
How to make CSS3 rounded corners hide overflow in Chrome/Opera
but iam using a another element with position: absolute; inside this
now I need to make the caption with rounded border too, but do not know how
note: i can't use another border-radius in caption, because this will have an animation
see the code with:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Problem</title>
<style type="text/css">
img {
border: 0;
}
a {
text-decoration: none;
}
.wrap-events {
float: left;
position: relative;
width: 500px;
height: 250px;
}
.events {
overflow: hidden;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
}
.caption {
position: absolute;
width: 100%;
bottom: 0;
color: #FFFFFF;
background-color: #151515;
font: 12px "Arial", Helvetica, sans-serif;
opacity: 0.6;
border-radius: 0 0 50px 50px; /* add border-radius to caption */
}
.caption p {
padding: 10px;
}
</style>
</head>
<body>
<div class="wrap-events">
<div class="events">
<a href="#">
<img src="http://www.cg-auto.com.br/forum/imagens/imagens_news/26c4dc4359edcfd4c6871ee1fa958539.jpg" alt="image">
</a>
<div class="caption">
<p>This is a caption</p>
</div>
</div>
</div>
<button id="slide">Slide It!</button>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$('#slide').click(function(){
$('.caption').hide().slideDown(2000);
});
</script>
</body>
</html>
cheers
That is a problem for now I think. May I suggest you use fadeIn() Instead. See a demo
This question already has answers here:
How to affect other elements when one element is hovered
(9 answers)
Closed 8 years ago.
I want it to be as simple as this, but I know it isn't:
img {
opacity: 0.4;
filter: alpha(opacity=40);
}
img:hover {
#thisElement {
opacity: 0.3;
filter: alpha(opacity=30);
}
opacity:1;
filter:alpha(opacity=100);
}
So when you hover over img, it changes the opacity of #thisElement to 30% and changes the opacity of the image to 100%. Is there a way to actually do this using only css?
So this is the HTML
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="C:\Users\Shikamaru\Documents\Contwined Coding\LearningToCode\Learning jQuery\js\jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="briefcase.js"></script>
<link rel="stylesheet" type="text/css" href="taskbar.css"/>
<link rel="stylesheet" type="text/css" href="briefcase.css" />
<title>Briefcase</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div class="mask"></div>
<div class="float">
<div id="album1">Album Title</div>
<img class="left" src="bradBeachHeart.JPG" alt="Brad at the Lake" />
<img class="left" src="mariaNavi.jpg" alt="Making Maria Na'vi" />
<img class="left" src="mattWaterRun.jpg" alt="Photoshopped Matt" />
</div>
<div class="gradientTop"></div>
<div class="gradientBottom"></div>
</body>
</html>
And this is the CSS:
body {
font: normal small/3em helvetica, sans-serif;
text-align: left;
letter-spacing: 2px;
font-size: 16px;
margin: 0;
padding: 0;
}
div.gradientTop {
position: absolute;
margin-top: 5px;
z-index: 2;
width: 206px;
height: 30px;
float: left;
background: -webkit-linear-gradient(rgba(255, 255, 255, 2), rgba(255, 255, 255, 0))
}
div.gradientBottom {
position: absolute;
margin-bottom: 5px;
z-index: 2;
width: 206px;
height: 120px;
float: left;
bottom: -210px;
background: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 1))
}
div.float {
border-right: 1px solid orange;
position: absolute;
z-index: 2;
margin-left: 5px;
margin-top: 5px;
float: left;
width: 200px;
}
div.mask {
position: relative;
z-index: 1;
margin-top: 5px;
float: left;
width: 206px;
height: 805px;
background-color: white;
}
img.left {
z-index: inherit;
margin-bottom: 3px;
float: left;
width: 200px;
min-height: 200px;
/* for modern browsers */
height: auto !important;
/* for modern browsers */
height: 200px;
/* for IE5.x and IE6 */
opacity: 0.4;
filter: alpha(opacity=40)
}
img.left:hover + #album1 {
opacity: .4;
}
img.left:hover {
opacity: 1.0;
}
#album1 {
z-index: 2;
width: 200px;
color: white;
text-align: center;
position: absolute;
background: orange;
top: 70px;
}
The only way to do this with CSS is if the element to affect is either a descendent or an adjacent sibling.
In the case of a descendent:
#parent_element:hover #child_element, /* or */
#parent_element:hover > #child_element {
opacity: 0.3;
}
Which will apply to elements such as:
<div id="parent_element">
<div id="child_element">Content</div>
</div>
For adjacent siblings:
#first_sibling:hover + #second_sibling {
opacity: 0.3;
}
Which works for mark-up such as:
<div id="first_sibling">Some content in the first sibling</div> <div id="second_sibling">and now in the second</div>
In both cases the latter element in the selector is the one chosen.
Given your pseudo-code example, you probably want something like:
img:hover + img {
opacity: 0.3;
color: red;
}
JS Fiddle demo.
I know you're probably looking for a pure-css way of doing what you want, but I'd suggest you use HTML+CSS+JS as the wonderful MVC structure that they are.
HTML is your Model, containing your data
CSS is your View, defining how the page should look
JS is your Controller, controlling how the model and view interact.
It's the controlling aspect that should be taken advantage of here. You want to control a view of an item on a user interaction. That's exactly what JS is meant for.
With very minimal JavaScript, you could toggle a class on and off of #thisElement when the img is hovered over. It certainly beats playing CSS selector games, although I'd understand if you're only willing to accept a pure-css answer.