This is a website that I and some friends of mine are building for their youtube channel.
I got this popup code from W3schools
I have the popups working but I want the popups to be 320px wide instead of the 160px and aligned with the image. The problem is when I widen the popup to 320px and try to center the popup onto the image, it never works out. All of my solutions have either moved the popups further to the right OR have messed with the actual layout itself.
What I've tried - after setting the width to 320px, in the CSS I've tried deleting the margin-left property and/or setting it to 0px, I've tried deleting the left property and/or setting it to auto, I've deleted the padding, I've messed with the position property in both the .popup and .popup .popuptext but alas, nothing has worked. They have either messed with the layout itself or just moved the popups further right. I've also tried researching online for the solutions but I haven't found a solution because I think that this problem is too specific, since I got the original code from W3schools that nobody has addressed it before and posted it online. Either that, or I'm still just too new to be able to research the answer specifically enough. Also, I'm still trying to wrap my head around the position property. I think the problem is in the position property because when I inspect the elements, I see how much positioning there is other than margin or padding, and I want to say that's what is throwing things off.
Here is the relevant CSS code-
.popup {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* The actual popup */
.popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
/* Popup arrow */
.popup .popuptext::after {
}
/* Toggle this class - hide and show the popup */
.popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
/* Add animation (fade in the popup) */
#-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}
#keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}
And here is a link to the actual site so you guys can see what's going on and check out the source code behind it.
The Site
Thank you so much. Any and all help is greatly appreciated. To see the popup, click the episode title.
You need to remove the margin-left.
After you do that, set your desired width and define a property called transformwith a value of translateX(-50%);
Leaving you with:
.popup .popuptext {
visibility: hidden;
width: 320px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
transform: translateX(-50%);
}
I don't know if you are aware but Bootstrap already has its own popover.
On a side note, you should not be looking at W3Schools, it is not a good source.
Here are some better resources:
Plain Javascript
CSS Reference Codrops
It seems that if you remove the left: 50% and margin-left and then add width: 320px your problem is gone. Try not to just copy-paste from W3Schools as it's very outdated. A more reliable source is MDN.
you could always use bootstrap class text-center
http://getbootstrap.com/css/
Related
Setting up my website portfolio site following this yt tutorial from Traversy Media (https://youtu.be/gYzHS-n2gqU). I want to turn the menu (which is simply transparent) into one that simply applies a blur to what's underneath it.
I have tried inputting filter: blur(5px); and all sorts of combinations of that in the css but it never works :(
// Menu Overlay
.menu {
position: fixed;
top: 0;
width: 100%;
opacity: 1; //this is where you control the opacity of the menu. 1 = opaque, 0 = transparent
visibility: hidden;
&.show {
visibility: visible;
}
&-branding,
&-nav {
display: flex;
flex-flow: column wrap;
align-items: center;
justify-content: center;
float: left;
width: 50%;
height: 100vh;
overflow: hidden;
}
&-nav {
margin: 0;
padding: 0;
/*background: darken($primary-color, 5);*/
background: transparentize(
$color: darken($primary-color, 5),
$amount: 0.05
);
list-style: none;
transform: translate3d(0, -100%, 0);
#include easeOut;
&.show {
// Slide in from top
transform: translate3d(0, 0, 0);
}
}
You can see the menu code in action on the portfolio site I have created at mashal.co/ It's under construction still, so don't flame me too hard for it haha.
Right now, all it is a minor transparent overlay when I click the menu button in the upper right. the code I provided above is only for the right half of the the overlay. Thanks a ton for any and all help in advance!!
The backdrop-filter CSS property lets you apply graphical effects such as blurring or color shifting to the area behind an element. Note that it is still an experimental property:
Chrome, Opera, Chrome for Android: supported after enabling "Experimental Web Platform Features "
IE, Firefox: not supported
What I'd advise you is to play around with a simple filter CSS property to apply the blur you want.
My problem is pretty weird. I have a background in a container::before, absolute-positioned and on every browser it works perfectly.
On IE 11 when I first load my page, my background only takes the width of my container (both sides are not visible). When I open my debugger or when I move the window the sides are revealed.
I tried this hack but it doesn't work.
.connexion-layout {
position: relative;
overflow: hidden;
}
.connexion-layout .container {
padding-top: 200px;
padding-bottom: 200px;
}
.connexion-layout .container::before {
content: " ";
display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
background: none no-repeat center center / cover;
}
#media screen and (min-width: 980px) {
.connexion-layout .container::before {
background-image: url("../../theme/images/connexion-bg-desktop.jpg?1433411383");
}
}
#media screen and (max-width: 979px) {
.connexion-layout .container::before {
background-image: url("../../theme/images/connexion-bg-mobile.jpg?1433411383");
}
}
Have you ever had something like this?
Adding position: relative; to the parent fixed this exact same bug for me.
When you say "it corrects itself when I resize the window or open the console" you are actually saying "forcing a browser repaint".
I haven't encountered this exact issue, but I did have a similar one with webfonts in Chrome a while back. It had to do with the order of loading.
So, based on that information, I'm going to guess that because the browser renders things in order, it's rendering the :before element first, then the parent element. However, the :before element's position is based upon the parent element (which it hasn't loaded yet) so it goes to the next available positioned element. When you resize, everything is loaded so it's fine.
There are two things I would try.
First, if you can, move it to the :after element. That may fix it. Since it is absolutely positioned, the :before vs :after shouldn't matter.
If that isn't possible, you can use a javascript/jquery repaint hack.
if($('html').hasClass('ie11')) {
$('.connexion-layout').hide(0, function(){$(this).show()});
}
Alternatively, you can try this in CSS. Load it at the bottom of your CSS. Again, this was meant for fonts but it should force a repaint regardless:
.ie11 body {
animation-duration: 0.1s;
animation-name: repaint;
animation-iteration-count: 1;
animation-timing-function: linear;
animation-delay: 0.1s;
}
#-webkit-keyframes repaint {
from { opacity: 1; }
to { opacity: 1; }
}
Both the jquery and css assume you have a classname of ie11 on your <html> so that you don't unnecessarily repaint other browsers.
I don't have a PC at the moment, so please let me know if none of these work and I'll find my BrowserStack login and give it a whirl.
i'm trying to apply a minimize/maximize effect to a div through keyframes and animations in css. While the plain, non-animated, effect is by itself pretty simple (i've already added it), the need for a starting point (from{...}) for keyframes is driving me mad! I've already tried with an empty from property, whitout it and with a dummy, non-related attribute (like opacity: 1, where opacity is not needed) or with auto values for needed properties, but so far i had no luck. So my question is, is there a way to set a keyframes so it starts from div's current properties values? To be more specific, can i have a div's width and height expanded to a given size starting from it's CURRENT, generic, width and height?
My code so far (effect related code):
#-webkit-keyframes maxWin{
from
{
/* width: auto; or width: ; or nothing at all */
/* height: auto; or height: ; or nothing at all */
/* left: auto; or left: ; or nothing at all */
/* top: auto; or top: ; ...you know. */
}
to
{
width: 100% !important;
height: 100% !important;
left: 0px !important;
top: 0px !important;
}
}
#-webkit-keyframes minWin
{
from
{
/*width: auto; or width: ;*/
/*height: auto; or height: ;*/
}
to
{
width: 200px !important;
height: 30px !important;
}
}
....
.maximized
{
/*width: 100% !important;
height: 100% !important;
left: 0px !important;
top: 0px !important;*/ Plain maximize effect. Works.
-webkit-animation: maxWin 1s normal forwards !important;
animation: maxWin 1s normal forwards !important;
}
.minimized
{
/*width: 200px !important;
height: 30px !important;*/ Plain minimize effect. Also works.
-webkit-animation: minWin 1s normal forwards !important;
animation: minWin 1s normal forwards !important;
}
If you are simply concerned about setting the end state relative to the present state of an element, You want a transition not an animation.
Transitions allow you to set the desired outcome and keyframes are then extrapolated automatically from the current state of the element.
e.g. in the below- applying the .minimized class to .window would reduce its size with only the endpoints specified.
.window{
transition: all 250ms ease-in;
width: 100%;
height: 100%;
}
.minimized{
width: 200px !important;
height: 30px !important;
}
If anyone has do that for some reason, simply leave the from {} part and only specify the to {}
#keyframes addright{
/* from{width:0;} */
to {width: var(--small-width);}
}
Take a look at the Web Animations API. You can use it to directly manipulate the browser's CSS animation engine and directly call CSS animations on elements with JavaScript. Just like CSS animations, you specify a set of keyframes for the animation engine to interpolate.
The benefit is, as it is JavaScript, you can get the current CSS (property: value) pair/s from the element you want to animate and pass them into the first keyframe. That way your animation would always take the elements current CSS styling as the starting point for your animation.
Easiest thing to do is, if you have added margins or top remove it and use
'transform'. It will animate it according to the starting positions of it.
ex:
#keyframes move_right
0% {
transform: translatex(16px);
}
100% {
transform: translatex(160px);
}
I am using marquee scroll from right side to the left. The below code works fine. But its not scrolling smoothly. The content "Hover on me to stop" is blinking or flashing. I need a 100% smooth scroll for the below marquee. Please help me. Whether it is possible without javascript??
<marquee behavior='scroll' direction='left' scrollamount='3' onmouseover='this.stop()' onmouseout='this.start()'>Hover on me to stop</marquee>
If you wish to try it using pure CSS then this is the easiest approach. Though you need to check the support for older browsers and do add vendor prefixes.
.marquee-parent {
position: relative;
width: 100%;
overflow: hidden;
height: 30px;
}
.marquee-child {
display: block;
width: 147px;
/* width of your text div */
height: 30px;
/* height of your text div */
position: absolute;
animation: marquee 5s linear infinite; /* change 5s value to your desired speed */
}
.marquee-child:hover {
animation-play-state: paused;
cursor: pointer;
}
#keyframes marquee {
0% {
left: 100%;
}
100% {
left: -147px /* same as your text width */
}
}
<div class="marquee-parent">
<div class="marquee-child">
Hover on me to stop
</div>
</div>
A little late to the party..
There's an angular directive for this: https://github.com/davidtran/angular-marquee. You don't touch any js - just add the directive tag and you're done
<div angular-marquee></div>
And it doesn't fall back on the "deprecated tag" argument, relying on modern solution
Is it possible to animate the transition between the open/close state of the <details> element with just CSS?
No, not currently. Yes, but only if you know the height or can animate the font-size.
Originally, this wasn't the case. From http://html5doctor.com/the-details-and-summary-elements/, "...if you could use CSS transitions to animate the opening and closing, but we can’t just yet." (There is a comment at HTML5 doctor near the end, but it appears to require JS to force the CSS animation.)
It was possible to use different styles based on whether it's opened or closed, but transitions didn't "take" normally. Today, however, the transitions do work if you know the height or can animate the font-size. See http://codepen.io/morewry/pen/gbJvy for examples and more details.
This was the 2013 solution that kind of fakes it:
CSS (May need to add prefixes)
/* http://daneden.me/animate/ */
#keyframes fadeInDown {
0% {
opacity: 0;
transform: translateY(-1.25em);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.details-animated[open] {
animation-name: fadeInDown;
animation-duration: 0.5s;
}
HTML
<details class="details-animated">
<summary>CSS Animation - Summary</summary>
Try using [Dan Eden's fadeInDown][1] to maybe fake it a little. Yay, some animation.
</details>
This works today:
CSS (May need to add prefixes)
.details-animated {
transition: height 1s ease;
}
.details-animated:not([open]) { height: 1.25em; }
.details-animated[open] { height: 3.75em; }
PS: Only tested in Chrome. Hear FF still doesn't support details in general. IE and Edge prior to version 79 still don't support details.
(You can use keyframe animations or transitions to do all sorts of other animations for open. I've chosen fadeInDown for illustration purposes only. It is a reasonable choice which will give a similar feel if you are unable to add extra markup or will not know the height of the contents. Your options are, however, not limited to this: see the comments on this answer that include two alternatives, including the font-size approach.)
My short answer is : you can not transition between summary and the rest of the details content.
BUT!
You can do some nice transition inside the summary between the selector details and details[open]
details{
position: relative;
width: 100px;height: 100px;
perspective: 1000px;
}
div{
position: absolute;
top: 20px;
width: 100px;height: 100px;
background: black;
}
details .transition{
transition: 1s linear;
transform-origin: right top;
;
}
details[open] .transition{
transform: rotateY(180deg);
background: orangered;
}
<details>
<summary>
<div></div>
<div class="transition"></div>
</summary>
</details>
NB : I answer this because it was the first result from googling on this!
Given the height has to snap at some point I prefer to start to animate the height and then snap. If your lucky enough to have all the elements a similar height this solution can be quite effective. (you do need a div inside your details elements though)
#keyframes slideDown {
0% {
opacity: 0;
height: 0;
}
100% {
opacity: 1;
height: 20px; /* height of your smallest content, e.g. one line */
}
}
details {
max-width:400px;
}
details[open]>div {
animation-name: slideDown;
animation-duration: 200ms;
animation-timing-function:ease-in;
overflow:hidden;
}
see http://dabblet.com/gist/5866920 for example
Of course it's possible:
DETAILS[open] SUMMARY ~ * {
animation: sweep 3s ease-in-out;
}
#keyframes sweep {
0% {
opacity: 0;
margin-left: -10px
}
100% {
opacity: 1;
margin-left: 0px
}
}
<details>
<summary>Summary content</summary>
Test test test test.
</details>