I am trying to make nested flip-cards for a login-system - successful as far as Edge, Chrome, Opera and Firefox goes, but Safari...
I am aware of the "hack" for Apple Safari to propper rotate cards, so I applied the '-webkit-backface-visibility: hidden;' to all the cards.
Unfortunately, Safari still does show the rotated backface of my Cards. Can anyone help?
Here is my code:CSS
/* The OUTER & INNER flip */
.flip-o-card, .flip-i-card {
background-color: transparent;
width: 320px;
/*border: 1px solid #f1f1f1;*/
perspective: 1000px;
margin:0 auto;
}
.flip-o-card {
height: 480px;
}
.flip-i-card {
height: 400px;
}
.flip-o-card-inner, .flip-i-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-o-card.hover .flip-o-card-inner, .flip-i-card.hover .flip-i-card-inner {
transform: rotateY(180deg);
}
.login-forgot, .register, .login, .forgot {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.login-forgot, .login {
background-color: #bbb;
color: black;
}
.register {
background-color: #1eff73;
color: white;
transform: rotateY(180deg);
}
.forgot {
background-color: #ff1e1e;
color: white;
transform: rotateY(180deg);
}
/* ####################################### */
.toggle-o, .toggle-i {
text-align: center;
}
.toggle-o {
padding-top: 50px;
}
.toggle-i {
padding-top: 0px;
}
the jquery:
$(document).ready(function(){
$('.toggle-o').on('click', function(){
console.log('Flip button clicked...');
$('.flip-o-card').toggleClass('hover');
if( $('div.text-center.toggle-o p').html() === "Register" ){
$('div.text-center.toggle-o p').html("Log in");
} else {
$('div.text-center.toggle-o p').html("Register");
}
});
$('.toggle-i').on('click', function(){
console.log('Switch button clicked...');
$('.flip-i-card').toggleClass('hover');
if( $('div.text-center.toggle-i p').html() === "Forgot password" ){
$('div.text-center.toggle-i p').html("Back to log in");
} else {
$('div.text-center.toggle-i p').html("Forgot password");
}
});
});
the html:
<div class="flip-o-card">
<div class="flip-o-card-inner">
<div class="login-forgot">
<div class="flip-i-card">
<div class="flip-i-card-inner">
<div class="login">
<p>login</p>
</div>
<div class="forgot">
<p>forgot</p>
</div>
</div>
</div>
<div class="text-center toggle-i">
<p>Forgot password</p>
</div>
</div>
<div class="register">
<p>register</p>
</div>
</div>
</div>
<div class="text-center toggle-o">
<p>Register</p>
</div>
Using some jQuery to hide the flipped main Card did the trick! (see the fiddle that I added in the comments...) However, as T J mentioned, Safari is the new IE... Grrr
Related
I am fairly new to HTML in the past month. I cannot for the life of me, figure out how to change the second image on hover to be a different image when the mouse hovers over it. I know some of the code probably looks dumb with how I tried to guess how I could possibly alter the second hover image. But I am quite confused. If anyone could help that would be great. The only progress I made so far is finally getting them perfectly aligned the way I would want them in the center and also the smooth transition to the hover. All that is left is being stumped on how to change the image to a different one when you hover over the second image. I do not want both hover images to be the same.
* {
background-color: coral;
}
.container {
position: relative;
width: 50%;
overflow: hidden;
display: table-cell;
border: 1px solid transparent;
/* a way to add a space around */
}
#media screen and (max-width:480px) {
.container {
/* make them full-width and one-a-row */
width: 100%;
display: block;
}
}
.image {
display: table-cell;
width: 100%;
height: auto;
transition: all .4s ease-in;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: .5s ease;
background-image: url("sketchcollage.JPG");
color: white;
text-align: center;
padding-top: 40%;
}
.overlay .overlay2 {
background-image: url("digitalartcollage.JPG");
}
a {
color: white;
}
.container:hover .overlay {
opacity: 1;
}
.container:hover .image {
transform: scale(1.2);
-webkit-transform: scale(1.2);
}
h1 {
text-align: center;
font-size: 72px;
background: -webkit-linear-gradient(rgb(12, 215, 230), rgb(170, 9, 130));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<h1> Who is Rosalyn? </h1>
<div class="container">
<a href="https://trezoro.co">
<img src="https://via.placeholder.com/500" alt="Le Tricolore Smartwatch" class="image">
<div class="overlay">
<p>Entire element is the link here</p>
</div>
</a>
</div>
<div class="container">
<img src="https://via.placeholder.com/500" alt="Le Tricolore Smartwatch" class="image">
<div class="overlay">
<a href="https://trezoro.co">
</a>
</div>
<div class="overlay2">
<p>Only the text is a link </p>
</div>
</div>
I don't know what is p tags are for, so I removed those. Also, I used a div with background-image instead img tag. when you hover on the container, the image changes.
* {
background-color: coral;
}
.flex{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
height: 50vh;
}
.container {
position: relative;
width: 48%;
overflow: hidden;
}
#media screen and (max-width:480px) {
.container {
width: 100%;
margin-top: 20px;
}
.flex{
height: 100vh;
}
}
.img{
background-size: 100% 100%;
transition: all .4s ease-in;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 1;
}
.img1{
background-image: url('https://s4.uupload.ir/files/5c29cf910a706_8m.jpg');
}
.img2{
background-image: url('https://s4.uupload.ir/files/717195_346_g0du.jpg');
}
a {
color: white;
}
.container:hover .img {
transform: scale(1.2);
-webkit-transform: scale(1.2);
opacity: 0.5;
}
.container:hover .img1{
background-image: url('https://s4.uupload.ir/files/0.270967001322580170_jazzaab_ir_ajvv.jpg');
}
.container:hover .img2{
background-image: url('https://s4.uupload.ir/files/7560b48482bfae5c-02b97ffc647f-3822363654_tji3.jpg');
}
h1 {
text-align: center;
font-size: 72px;
background: -webkit-linear-gradient(rgb(12, 215, 230), rgb(170, 9, 130));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<h1> Who is Rosalyn? </h1>
<div class="flex">
<div class="container">
<a href="https://trezoro.co">
<div class="img img1"></div>
</a>
</div>
<div class="container">
<div class="img img2"></div>
</div>
</div>
QUESTION
How to change the second image on hover to be a different image when the mouse hovers over it?
ANSWER
The approach of this question is to change an image when the user hovering the mouse over it. This task can be simply done by using the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.
.changeImg:hover {
background-image:
url("https://images.app.goo.gl/gfRnCCBPH6r4v3kp6");
}
I have an app that has a two-sided HTML element. When a user clicks a button, I want to "flip" the element. I've been trying to get it to work as shown here. That example includes the following HTML, CSS, and JavaScript.
HTML
<div id="myApp">
<div class="flip-card">
<div class="flip-card-inner">
<div :class="{ 'flip-card-front':true, 'flipped':!isFlipped }">Side A</div>
<div :class="{ 'flip-card-back':true, 'flipped':isFlipped }">Side B</div>
</div>
</div>
<button #click="onButtonClick">Flip</button>
</div>
CSS
.flip-card {
background-color: transparent;
width: 300px;
height: 300px;
perspective: 1000px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transform: rotateY(180deg);
transition: transform 0.6s;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.flipped {
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-front {
background-color: #bbb;
color: black;
}
.flip-card-back {
background-color: #2980b9;
color: white;
transform: rotateY(180deg);
}
JavaScript
const MyApp = {
data() {
return {
isFlipped: false
}
},
methods: {
onButtonClick() {
this.isFlipped = true;
}
}
}
Vue.createApp(MyApp).mount('#myApp');
There doesn't appear to be any errors. It's just not behaving as I'd expect. Everything looks correct. How do I get the card to flip when someone clicks the button?
UPDATE
This example cleared it up.
Your class is being applied as expected, but you have a CSS specificity problem.
Increase specificity like this:
.flip-card-front.flipped {
transform: rotateY(180deg);
}
Try to replace below code.
this.isFlipped = true;
To
this.isFlipped = !this.isFlipped;
I am trying to build a simple css slider that shows specific text when in the :target state. The text actually appears fine but what's happening is it's just appearing instead of sliding in. I have left:0 set on the parent and the idea being that when the slide id is selected the parent should move to left: -100%/-200%/-300% depending on the slide targeted. Hope this makes sense, markup is below.
Appreciate any advice where I have gone wrong.
.slider__wrapper {
width: 300px;
margin: 50px auto 0 auto;
}
.slider {
position: relative;
overflow: hidden;
}
.slider__inner {
position: relative;
width: 300%;
left: 0;
transition: all .6s;
}
.slider__slides {
float: left;
width: 33.333%;
font-size: 25px;
}
.slider__toggle {
display: inline-block;
margin-right: 10px;
margin-top: 20px;
font-size: 16px;
}
#slide--1 {
background: red;
}
#slide--2 {
background: yellow;
}
#slide--3 {
background: green;
}
#slide--1:target~.slider__inner {
left: 0;
transition: all .6s;
}
#slide--2:target~.slider__inner {
left: -100%;
transition: all .6s;
}
#slide--3:target~.slider__inner {
left: -200%;
transition: all .6s;
}
<div class="slider__wrapper">
<div class="slider">
<div class="slider__inner">
<div class="slider__slides" id="slide--1">
slide 1
</div>
<div class="slider__slides" id="slide--2">
slide 2
</div>
<div class="slider__slides" id="slide--3">
slide 3
</div>
</div>
</div>
<div class="slider__toggle">
01
02
03
</div>
</div>
I've come across a strange bug in Safari browser rendering.
When I hover over element (green .hover) which makes its child element (pink .pop) visible, the child stays visible even after the hover has ended. It's visible but not selectable - I can select text "behind" the child element as you can see in the screenshot below.
HTML:
<div class="hover">
Hover me! (display)
<div class="pop pop--display">
I will cover your content in Safari indefinitely
</div>
</div>
<div class="content">
Content
</div>
CSS:
.hover {
position: relative;
overflow: hidden;
}
.pop {
position: absolute;
top: 80%;
left: 10px;
}
.hover:hover {
overflow: visible;
}
.pop--display {
display: none;
}
.hover:hover .pop--display {
display: block;
}
It seems to be caused by changing overflow hidden/visible of the parent element together with changing of display none/block (or visibility hidden/visible) of the child element. I came across this bug using JavaScript but mere CSS :hover can reproduce it.
Tested on Safari 8.0.6 (10600.6.3) and 9.0.1 (11601.2.7.2).
/* basic styling and formating */
.hover {
padding: 10px 0;
width: 200px;
background: green;
}
.pop {
padding: 20px;
height: 90px;
width: 140px;
background: pink;
}
.content {
width: 200px;
padding-top: 20px;
height: 100px;
background: grey;
}
.test + .test {
margin-top: 30px;
}
/* overflows and positioning */
.hover {
position: relative;
overflow: hidden;
}
.pop {
position: absolute;
top: 80%;
left: 10px;
}
.hover:hover {
overflow: visible;
}
/* variations */
.pop--display {
display: none;
}
.hover:hover .pop--display {
display: block;
}
.pop--visibility {
visibility: hidden;
}
.hover:hover .pop--visibility {
visibility: visible;
}
<div class="test">
<div class="hover">
Hover me! (default)
<div class="pop">
I will cover your content in Safari indefinitely
</div>
</div>
<div class="content">
Content
</div>
</div>
<div class="test">
<div class="hover">
Hover me! (display)
<div class="pop pop--display">
I will cover your content in Safari indefinitely
</div>
</div>
<div class="content">
Content
</div>
</div>
<div class="test">
<div class="hover">
Hover me! (visibility)
<div class="pop pop--visibility">
I will cover your content in Safari indefinitely
</div>
</div>
<div class="content">
Content
</div>
</div>
The only solution I could came to is to use opacity with pointer-events. I expect opacity: 0; pointer-events: none to act the same way as visibility: hidden.
But I'm still not sure if this is a right approach...
The corresponding CSS is:
.pop--opacity {
opacity: 0;
pointer-events: none;
}
.hover:hover .pop--opacity {
opacity: 1;
pointer-events: auto;
}
/* basic styling and formating */
.hover {
padding: 10px 0;
width: 200px;
background: green;
}
.pop {
padding: 20px;
height: 90px;
width: 140px;
background: pink;
}
.content {
width: 200px;
padding-top: 20px;
height: 100px;
background: grey;
}
.test + .test {
margin-top: 30px;
}
/* overflows and positioning */
.hover {
position: relative;
overflow: hidden;
}
.pop {
position: absolute;
top: 80%;
left: 10px;
}
.hover:hover {
overflow: visible;
}
.pop--opacity {
opacity: 0;
pointer-events: none;
}
.hover:hover .pop--opacity {
opacity: 1;
pointer-events: auto;
}
<div class="test">
<div class="hover">
Hover me! (opacity)
<div class="pop pop--opacity">
I will cover your content in Safari indefinitely
</div>
</div>
<div class="content">
Content
</div>
</div>
I have a small bug that I can't seem to locate. In my snippet you can see how whenever you hover over the image, opactiy and an image scale takes place, as well as a box comes over the image. That is perfect, but my issue is whenever you hover over the text below it, the hover effect takes place over the image.
I can't seem to figure out how for the hover effect to only take place when the mouse is hovering over the image.
Any suggestions would be appreciated.
$('.home-img-block img').addClass(function() {
return (this.width / this.height > 1) ? 'wide' : 'tall';
});
#home-img-block-section {
width: 100%;
height: 900px;
}
#home-img-blocks {
width: 100%;
height: 750px;
}
.home-img-block {
width: 33.33%;
float: left;
display: block;
overflow: hidden;
position: relative;
}
.home-img-container {
position: relative;
overflow: hidden;
cursor: pointer;
}
.home-img-block:hover .overlay {
background: rgba(0, 0, 0, 0.6);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.home-img-container:after {
content: attr(data-content);
color: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: all 0.5s;
border: 1px solid #fff;
padding: 20px 25px;
text-align: center;
}
.home-img-container:hover:after {
opacity: 1;
}
.home-img-block img {
display: block;
transition: all 1s ease;
}
.home-img-block:hover img {
transform: scale(1.25);
background: rgba(0, 0, 0, 0.3);
width: 33.33%;
max-height: 100%;
overflow: hidden;
}
.home-img-block img.wide {
max-width: 100%;
max-height: 100%;
height: auto;
width: 100%;
}
.home-img-block img.tall {
max-width: 100%;
max-height: 100%;
width: auto;
}
#home-img-block-wording-container {
width: 100%;
height: 300px;
}
.home-img-wording-blocks {
width: 100%;
height: 100%;
text-align: center;
display: inline-block;
vertical-align: top;
}
.home-img-wording-block-title {
padding-top: 30px;
font-size: 1.7em;
}
.home-img-wording-block-description {
padding: 25px 50px 0 50px;
font-size: 1.1em;
color: #5d5d5d;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="home-img-block-section">
<div id="home-img-blocks">
<div class="home-img-block fadeBlock1">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test1.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought
to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
</div>
<div class="home-img-block fadeBlock2">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test2new.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.
gfdgfdsg greg reg regrfesg fdsg gretswtgy tgreswt treswt trgegfd gsvbd fbgre greasgv drfdg greaag gredr</div>
</div>
</div>
<div class="home-img-block fadeBlock3">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test3new.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES gfdgf fdggs gfsg gfsg gf sgf g
gfdsg sdfggfs gfdsgssdfg fdggfds gfdsg gfds gfdgs gf dsgfdsgfgs gfdgfs gtrg resg reg rgesgresrgrg</div>
</div>
</div>
</div>
</div>
.home-img-block:hover .overlay
and
.home-img-block:hover img
replace them with
.home-img-container:hover .overlay
.home-img-container:hover img
otherwise you're triggering when you hover over the whole container instead of only wheen hovering the img one.