I can currently place 2 icons in front of one another, however with position: fixed, I cannot seem to get them justified to the right hand side of my parent div...
I have attempted using right: 0, but this seems to justify with respect to the screen rather than div itself. Is there something I'm missing?
.settings,
.clear {
position: fixed;
// positioning to right?
transition: all .2s cubic-bezier(.4, 0, .2, 1);
}
.hide {
opacity: 0;
transform: rotate(225deg);
}
<!-- Just for material icon purposes -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<div class="expandPanel" #panel [ngClass]="{expanded: isExpanded}" style="width: 300px; height: 300px; background: lightgrey;">
<div class="expandButton" (click)="togglePanel()">
<a class="material-icons clear" [ngClass]="{hide: isExpanded}">clear</a>
<a class="material-icons settings" [ngClass]="{hide: !isExpanded}">settings</a>
</div>
</div>
First position fixed property will position the element relative to view port.
So that is not what you are looking for. To align you child element relative to the parent element first give your parent position relative property and your child a position absolute property. I think this is what you want:
.settings,
.clear {
transition: all .2s cubic-bezier(.4, 0, .2, 1);
-webkit-transition: all .2s cubic-bezier(.4, 0, .2, 1);
-moz-transition: all .2s cubic-bezier(.4, 0, .2, 1);
-ms-transition: all .2s cubic-bezier(.4, 0, .2, 1);
}
.hide {
opacity: 0;
transform: rotate(225deg);
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
-ms-transform: rotate(225deg);
}
.expandPanel {
position:relative;
}
.expandButton {
position:absolute;
right:0;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<div class="expandPanel" #panel [ngClass]="{expanded: isExpanded}" style="width: 300px; height: 300px; background: lightgrey;">
<div class="expandButton" (click)="togglePanel()">
<a class="material-icons clear" [ngClass]="{hide: isExpanded}">clear</a>
<a class="material-icons settings" [ngClass]="{hide: !isExpanded}">settings</a>
</div>
</div>
Related
Long story made short I am trying to work on a page that will be showing a playing card that I want to animate flipping over to the back side and back again at certain points. So far I've been using a lot of the code from this useful blog post to do so: https://manjitkarve.com/posts/card-flip-interaction/
What I'm trying to add on now is a clip-path as the majority of my card images are not 'clean' and have some jank white lines around the image and using clip-path in CSS seemed like the cleanest way to nail this. And so far isolated on its own it is doing the job swimmingly.
However with the clip-path added in, my card flip transitions are messed up. As an example: If I am sitting on the 'front' face of the card and ask it to flip to the back, it flips to a mirrored version of the front face instead. Once I take clip-path out, it's back to normal.
There's a LOT of moving parts to my code now but I'll post what I can/what's relevant. As an addition note, I'm also using the SWUP JS library in here but that functionality is working fine and best I can tell is not interfering with this currently. If I call these card transitions manually outside of SWUP, I get the same behavior:
HTML:
<main id="swup">
<div id="swup-card-img card_img_overlay" class="card-left-half card transition-flip center">
<div class="front face" style="background-image:url('{{ card.card_image.url }}')"></div>
<div class="back face" style="background-image:url('{% static 'img/fow_cardback.png' %}')"></div>
</div>
</main>
CSS:
.transition-flip {
transition: transform 1.0s;
transform-style: preserve-3d;
}
.transition-flip .card .front {
transform: rotateX(0deg);
}
.transition-flip .card .back {
transform: rotateX(180deg);
}
html.is-animating .transition-flip {
transform: rotateY(180deg);
transition: transform 1.0s;
}
html.is-leaving .transition-flip {
transform: rotateY(180deg);
transition: transform 1.0s;
}
.card {
/* Card height to width ratio is 1.396 rounded */
width: 50vw;
height: 69.8vw;
position: relative;
perspective: 100vw;
perspective-origin: 50% 50%;
transform-style: preserve-3d;
display: inline-block;
clip-path: inset(0.3% 0.2% 0.0% 0.2% round 3.9%);
background: rgba(0, 0, 0, 1.0);
}
.card .face {
backface-visibility: hidden;
position: absolute;
width: 100%;
height: 100%;
transition: transform 0.35s cubic-bezier(0.13, 1.03, 0.39, 0.98), box-shadow 0.35s cubic-bezier(0.13, 1.03, 0.39, 0.98), border-width 0.35s cubic-bezier(0.13, 1.03, 0.39, 0.98);
box-shadow: 0px 1.2vw 4vw -1vw rgba(0, 0, 0, 0.6);
background-position: 0 0;
background-size: 50vw;
background-repeat: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 1.1vw;
}
.card .front {
}
.card .back {
transform: rotateY(180deg);
transform: rotateX(180deg);
}
.center {
margin:0 auto;
}
I'm having difficulty trying to get an image overlay and image zoom to appear at the same time on mouse hover. For some reason, the overlay disappears when I added the image zoom. It seems like one webkit transition cancels the other out. Either the zoom will work or the overlay will appear but not both. Any help is greatly appreciated, I've been researching for hours and can't seem to figure it out.
HTML Code:
<div class="image_wrap">
<div class="caption">
<i class="fa fa-search-plus" aria-hidden="true"></i>
<p class="heading">
Resort Website
</p>
</div>
<img src="css/images/resort.jpg" alt="resort" class="portfolio-pic">
</div>
CSS Code:
.image_wrap{
position:relative;
}
.image_wrap .caption{
position:absolute;
width:100%;
height:100%;
opacity: 0;
text-align:center
display:inline-block;
background: linear-gradient(rgba(51, 153, 170, 0.9), rgba(51, 153, 170, 0.8));
-webkit-transition:all .4s ease-in-out;
transition:all .4s ease-in-out
}
.image_wrap .caption:hover{
opacity: 1;
}
.image_wrap .caption img {
position:relative;
-webkit-transition:all .4s linear;
transition:all .4s linear;
}
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
I detect two problems on your code, change this:
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
For this:
.image_wrap:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
z-index:8;
}
You can answer why. Because your image not inside .caption and you didn't declare the z-index (caption on the image).
Declare the z-index on caption too.
.image_wrap:hover .caption {
opacity: 1;
z-index:9999;
}
Here is the link for jsfiddle where I test our code: link
I'm searching a way to make an css effect but with exception of not applying the effect to the letters and the buttons (Only to the image), so I need create a rule in css. I can't change the order of the things.
With my code, I get something like this.
This is my code, like you can see I applied some effect in css and this is getting applied to all. I only need it for the image.
.myimage01 {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" data-style="background-image: url(http:www.myurl.com/image.jpg);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
When I apply the effect apply the effect to the letters (h5, h3, p and the button with btn class)
I don't want the effect for them, only for the background-image.
How can I do?
for transition backgrounds use the property background-size, and use background-position to adjust as fits you better
body {
margin: 0
}
.myimage01 {
background-size: 100%;
background-position:center center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
background-image: url(http://lorempixel.com/1600/900);
padding: 40px 30px;
color: #ffffff;
text-align: center;
}
.myimage01:hover {
background-size: 130%;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
Use background-size for transition:
div {
background-image: url(http://lorempixel.com/400/200/sports/1/);
background-size: 100%;
background-repeat:no-repeat;
background-position:50% 50%;
width:400px;
height:200px;
transition: background-size 200ms linear;
text-align:center;
line-height:200px;
}
div:hover {
background-size: 120%;
}
<div>
Some text
</div>
try to transform the background-size property instead of scaling the whole container.
You can apply transform on background-size, background-position to get the effect on the background image.
.myimage01 {
background-size:100%;
background-position:0px 0px;
-webkit-transform: all;
transform: all;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
background-size:140%;
background-position:-50px -50px;
-webkit-transform: all;
transform: all;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" style="background-image: url(http://dummyimage.com/600x200/000/fff);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
I'm working on making a sidebar on My main page something like google ventures (https://www.gv.com/lib/how-to-choose-the-right-ux-metrics-for-your-product). but the problem I'm getting is when I click to any menu item in the sidebar , the side bar gets collapse but the text for menu item is still there. I want to keep the sidebar open till the mouse cursor is in the sidebar area (even when user clicks on any menu it should remain opened/expended) but it gets collapse on cliking on any item while the text for the menu item remain in the air. I don't know how to fix it as Im not much hands-on with css and designing.
here is my jquery code for adding classes for collapse/expand the side bar
$('[data-toggle="offcanvas"]').mouseenter(function(e) {
e.preventDefault();
if ($("body").hasClass('sidebar-collapse')) {
$("body").removeClass('sidebar-collapse');
$("body").addClass('sidebar-open')
}
});
$('[data-toggle="offcanvas"]').mouseleave(function(e) {
e.preventDefault();
if ($("body").hasClass('sidebar-open')) {
$("body").removeClass('sidebar-open');
$("body").addClass('sidebar-collapse')
};
});
and here are css classes (with media queries) for this
.main-sidebar,
.left-side {
position: absolute;
top: 0px;
left: 0;
padding-top: 50px;
min-height: 100%;
width: 230px;
z-index: 0;
-webkit-transition: -webkit-transform 0.3s ease-in-out, width 0.3s ease-in-out;
-moz-transition: -moz-transform 0.3s ease-in-out, width 0.3s ease-in-out;
-o-transition: -o-transform 0.3s ease-in-out, width 0.3s ease-in-out;
transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
}
#media (max-width: 767px) {
.main-sidebar,
.left-side {
-webkit-transform: translate(-230px, 0);
-ms-transform: translate(-230px, 0);
-o-transform: translate(-230px, 0);
transform: translate(-230px, 0);
}
}
#media (min-width: 768px) {
.sidebar-collapse .main-sidebar,
.sidebar-collapse .left-side {
-webkit-transform: translate(-230px, 0);
-ms-transform: translate(-230px, 0);
-o-transform: translate(-230px, 0);
transform: translate(-230px, 0);
}
}
#media (max-width: 767px) {
.sidebar-open .main-sidebar,
.sidebar-open .left-side {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0);
}
}
.sidebar {
padding-bottom: 10px;
}
and here is html code where my sidebar resides
<aside class="main-sidebar" data-toggle="offcanvas">
<section class="sidebar">
<ul class="sidebar-menu">
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</section>
<aside>
I tried to implement it on mouseclick event by keeping adding the sidebar-open class but this didn't work. Any help would be highly appreciated. Thanks
You can put the text in an element like, say p's. Then you can you try hiding the them when mouse leaves and show them when mouse enters. You can add the lines similar to the below ones in your jquery.
// on mouse leave
$('ul.sidebar-menu li>p').hide();
// on mouse enter
$('ul.sidebar-menu li>p').show();
Edit ---
Alternatively you can try the below CSS for aside.main-sidebar,
white-space: nowrap;
overflow: hidden;
For a new webdesign I made two 50% width div's that slide over on hover. When hovering on the left 'slide' div, I want the right 'logo' div to hide (display:none) and vice versa, but it just won't work. What am I missing here? Any help would be much appreciated!
body {
background:black;
}
.slide {
position:absolute;
top:0;
bottom:0;
width:50%;
-webkit-transform:skew(-15deg);
-moz-transform:skew(-15deg);
-ms-transform:skew(-15deg);
-o-transform:skew(-15deg);
transform:skew(-15deg);
z-index:2;
}
.slide:hover {
width:60%;
z-index:80;
}
.slide#left {
left:0;
}
.slide#right {
right:0;
}
.wrap {
width:100%;
height:100%;
position:absolute;
overflow:hidden;
z-index:2;
}
.inner {
width:100%;
height:100%;
-webkit-transform:skew(15deg) scale(1.5);
-moz-transform:skew(15deg) scale(1.5);
-ms-transform:skew(15deg) scale(1.5);
-0-transform:skew(15deg) scale(1.5);
transform:skew(15deg) scale(1.5);
opacity:0.6;
position:absolute;
}
.slide:hover .inner {
opacity:0.9;
}
.inner#left {
background:url(//savado.nl/new/key.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#right {
background:url(//savado.nl/new/code2.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
.slide .logo {
position:absolute;
z-index:99;
top:50%;
height:30%;
}
.logo img {
height:100%;
}
.logo#left {
right:0;
-webkit-transform:translateX(50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(50%) translateY(-50%) skew(15deg);
-o-transform:translateX(50%) translateY(-50%) skew(15deg);
transform:translateX(50%) translateY(-50%) skew(15deg);
}
.logo#right {
left:0;
-webkit-transform:translateX(-50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(-50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(-50%) translateY(-50%) skew(15deg);
-o-transform:translateX(-50%) translateY(-50%) skew(15deg);
transform:translateX(-50%) translateY(-50%) skew(15deg);
}
div {
-webkit-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-moz-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-ms-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-o-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
}
<div class='slide' id='right'>
<div class='wrap'>
<div class='inner' id='right'></div>
</div>
<div class='logo' id='right'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
<div class='slide' id='left'>
<div class='wrap'>
<div class='inner' id='left'></div>
</div>
<div class='logo' id='left'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
And here is the [JSFIDDLE][1]!
Thanks in advance!
[1]: http://jsfiddle.net/NZXeT/
That is because your CSS
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
Will never be valid, there is no .logo#right INSIDE your .inner#left:hover element, it only contains a .logo#left. The same with the other.
You will have to re-think your design for this to work, I do not see why you need two logo's, why not just have one logo that slides one side or the other? Why have to hide them?
So your first issue is that you have multiple elements with the same ID. That's going to make things confusing (and invalid), so stick with unique IDs.
Second, CSS has the limitation of only being able to affect the element in the rule, siblings after that element, or children of that element. This means that if you want to stick with pure CSS you're going to need to get slightly hacky.
If you want to use javascript/jQuery, it's basically a one-liner fix.
If you want to stick with pure HTML+CSS you can use the sibling selector ~ to match the other slide. Try this:
.slide#right:hover ~ .slide#left {display: none;}
You'll see the left side hide when you hover the right just like intended! However, doing the opposite won't work :( This is because the left element is after the right in the markup. However, you can "cheat" and add a hidden "trigger" over the left side. If you add an element before .slide#right that is exactly the same size and shape of .slide#left, then add the same rule as I have here but replace #right with #lefttrigger it should work.
Does that make sense?