I have this issue with getting an animation working only if the user hovers over a div.
I made a jsfiddle: http://jsfiddle.net/HBfLY/1/
So I want it to bounce in from the left, but instead it is blinking. What I am doing wrong?
The problem you're experiencing is that, once the element changes its position due to the animation, it's no longer hovered-over by the cursor, therefore the :hover selector no longer applies.
To remedy this you could apply the :hover to an ancestor element:
body:hover #animatie1 {
border: 5px solid black;
position:relative;
top: 20px;
left:100px;
width:100px;
height: 200px;
animation:mymove 2s ;
-moz-animation:mymove 2s ; /* Firefox */
-webkit-animation:mymove 2s ; /* Safari and Chrome */
-o-animation:mymove 2s ; /* Opera */
}
JS Fiddle demo.
Or use a preceding sibling element:
#immediatelyPrecedingSibling:hover + #animatie1 {
border: 5px solid black;
position:relative;
top: 20px;
left:100px;
width:100px;
height: 200px;
animation:mymove 2s ;
-moz-animation:mymove 2s ; /* Firefox */
-webkit-animation:mymove 2s ; /* Safari and Chrome */
-o-animation:mymove 2s ; /* Opera */
}
JS Fiddle demo.
In those browsers that support the general-sibling combinator, you could use any preceding sibling element (so long as you can target it with CSS, and, to reiterate, that this sibling precedes the element to be targeted in the DOM):
#notAnImmediatelyPrecedingSibling:hover ~ #animatie1 {
border: 5px solid black;
position:relative;
top: 20px;
left:100px;
width:100px;
height: 200px;
animation:mymove 2s ;
-moz-animation:mymove 2s ; /* Firefox */
-webkit-animation:mymove 2s ; /* Safari and Chrome */
-o-animation:mymove 2s ; /* Opera */
}
JS Fiddle demo.
References:
Browser support for general sibling ~ combinator.
CSS Level 3 Selectors.
Related
I have a div with this scroll see the image here
but i want this type of scroll for my div see the image here
You can checkout the below URL
https://www.w3schools.com/howto/howto_css_custom_scrollbar.asp
I'm not sure if all web browsers react the same way, but you can try this:
<style>
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: red;
border-radius: 10px;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #b30000;
}
</style>
Source : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_scrollbar2
I am trying to create a button with "caps" on either end, and a repeating background, in order to keep the button a flexible size.
In order to do this, I have used the :before and :after pseudo-elements in CSS, along with position:absolute to get it outside of the main button's background-covered space (using negative values).
It works in FF and Chrome, but it looks like in IE8 and 9, the images are there, but are "outside" the button, and therefore are hidden. Does anyone know how to pop these pseudo-elements "out" of the button, so that they will render?
I want to keep the HTML to just the <button></button> element, and am using SASS.
You can see a jsFiddle here: http://jsfiddle.net/Dqr76/8/ or the code below:
button {
display: inline-block;
zoom: 1;
*display: inline;
border:0;
background-image: url(../images/btn_bg.png);
background-repeat: repeat-x;
color: #fff;
font-weight: bold;
height: 22px;
line-height: 22px;
position: relative;
margin: 0 5px;
vertical-align: top;
&:before {
display: inline-block;
height: 22px;
background-image: url(../images/btn_left.png);
width: 5px;
position: absolute;
left: -5px;
top: 0;
content: "";
}
&:after {
display: inline-block;
height: 22px;
background-image: url(../images/btn_right.png);
width: 5px;
position: absolute;
right: -5px;
top: 0;
content: "";
}
}
Just a sidenote, before someone brings it up, I know that these pseudo-elements do not work in < IE8, and have created a work-around that is not effecting this problem.
Add overflow: visible; to the button element, and it shows up.
Demonstrated at this jsFiddle
I swear I tried that already, but I guess not. Thanks to this question
I have a few buttons on my webpage in different colors. I have one class for the shape of the button, and then a few classes that give them colors.
.button {
font-family:"Helvetica Neue W01 75 Bold", Helvetica, Arial, Sans-serif;
text-decoration: none;
white-space: nowrap;
color: #333;
padding: 13px 15px;
display: inline-block;
font-size: 1em;
font-weight: bold;
text-align: center;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
a.button {
color: #333;
}
.black.button {
background-color: #dedede;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.1, #D3D3D3), color-stop(0.45, #EFEFEF), color-stop(0.90, #D3D3D3));
background: -moz-linear-gradient((linear, left bottom, left top, color-stop(0.1, #D3D3D3), color-stop(0.45, #EFEFEF), color-stop(0.90, #D3D3D3));
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=##EFEFEF, endColorStr=##D3D3D3);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#D3D3D3)";
-webkit-appearance: push-button;
}
.black.button:hover {
background: #E2E2E2;
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#E2E2E2, endColorStr=#E2E2E2);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#E2E2E2, endColorstr=#E2E2E2)";
}
.orange.button {
background-color: #ffaa44;
background: -webkit-gradient(linear,left bottom, left top, color-stop(0.22, rgb(255,144,9)), color-stop(0.81, rgb(255,170,68)));
background: -moz-linear-gradient(center bottom, rgb(255,144,9) 22%, rgb(255,170,68) 81%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#ffaa44, endColorStr=#ff9009);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffaa44, endColorstr=#ff9009)";
}
.orange.button:hover {
background: #ff9009;
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#ff9009, endColorStr=#ff9009);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ff9009, endColorstr=#ff9009)";
}
I use them like:
<a class="orange button" href="#">Click Me</a>
This works in Chrome and Safari but does not work in Firefox12 (and IE). All I see is a white box with 'ClickMe' (So probably the .button is applied, but not .orange)
From what I read, this is supported in Firefox. But I cannot figure what is wrong in my stylesheet.
When I do an 'Inspect Element', Firefox shows the class as a.orange.button, but in the Styles tab, it doesnot display these classes. It is picking my stylesheet as the rest of the page is displayed okay.
What am I missing here?
It seems to work if you remove invalid CSS code. I'm wondering if you have these exact lines in your original CSS code (with ... and unclosed brackets - which should cause the problem):
background: -webkit-gradient(...
border-radius:...
Cleaned up jsFiddle Demo
The problem is surely not with multiple classes. They work fine in every modern browser.
UPDATE: I found the issue based on this jsFiddle. It is this declaration:
.black.button {
background: -moz-linear-gradient((linear, left bottom, left top, color-stop(0.1, #D3D3D3), color-stop(0.45, #EFEFEF), color-stop(0.90, #D3D3D3));
}
You have one more opening ( than needed right after -moz-linear-gradient.
Correct version (jsFiddle):
.black.button {
background: -moz-linear-gradient(linear, left bottom, left top, color-stop(0.1, #D3D3D3), color-stop(0.45, #EFEFEF), color-stop(0.90, #D3D3D3));
}
Try using something like the following
background: -moz-linear-gradient( top left, white, black );
-webkit-gradient is for webkit browsers -- like Chrome and Safari; Firefox is not a webkit browser.
see http://jsfiddle.net/Wfxym/
Some notes found # linear gradients and especially Cross-browser CSS gradient (details on the Firefox implementation can be found on MDN: https://developer.mozilla.org/en/CSS/linear-gradient)
I need some divs to be center-positioned and to fit their content width at the same time.
I am now doing it like this:
.mydiv-centerer{
text-align: center;
.mydiv {
background: none no-repeat scroll 0 0 rgba(1, 56, 110, 0.7);
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 5px #0099FF;
color: white;
margin: 10px auto;
padding: 10px;
text-align: justify;
width: -moz-fit-content;
}
}
Now, the last command "width: -moz-fit-content;" is exactly what I need!
Only problem is.. it works only on Firefox.
I also tryed with "display:inline-block;", but I need these divs to behave like divs. Namely, every next div should be under, and not inline, the previous.
Do you know any possible cross-browser solution?
At last I fixed it simply using:
display: table;
Mozilla's MDN suggests something like the following [source]:
p {
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
width: -webkit-max-content; /* Chrome */
}
In similar case I used: white-space: nowrap;
Is there a single declaration that fixes this for Webkit, Gecko, and Blink? No. However, there is a cross-browser solution by specifying multiple width property values that correspond to each layout engine's convention.
.mydiv {
...
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
width: -webkit-max-content; /* Chrome */
...
}
Adapted from: MDN
I use these:
.right {display:table; margin:-18px 0 0 auto;}
.center {display:table; margin:-18px auto 0 auto;}
I was looking for a way to prevent a long line of text from outgrowing past its container, and max-width: fit-content worked in Chrome, but not in Firefox.
I found a workaround: if the element is the last displayed subelement, setting display: table-caption; and caption-side: bottom; does have the same effect, together with display: table; on the parent object.
Why not use some brs?
<div class="mydiv-centerer">
<div class="mydiv">Some content</div><br />
<div class="mydiv">More content than before</div><br />
<div class="mydiv">Here is a lot of content that
I was not anticipating</div>
</div>
CSS
.mydiv-centerer{
text-align: center;
}
.mydiv{
background: none no-repeat scroll 0 0 rgba(1, 56, 110, 0.7);
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 5px #0099FF;
color: white;
margin: 10px auto;
padding: 10px;
text-align: justify;
display:inline-block;
}
Example: http://jsfiddle.net/YZV25/
Can anyone tell me if it's possible to make this work in Firefox2 (and also IE6)?
http://collinatorstudios.com/ff2_test.html
I was able to emulate inline-block with the '-moz-inline-stack' hack, however it appears that it ignores position: relative, so elements with position absolute inside the inline-stack container do not appear relative to where they should.. instead they are at the top right of the page in FF2...
I know FF2 is outdated and I probably shouldn't care, but I am wondering if there is a way to achieve this, and also I need it to work in IE6.
Thank you.
Unfortunately I no longer have FF2 to test this for you, but I think the only way to make in work in that is to nest a div and apply position relative to the nested div so it would be inside you li
as for IE6 I think an alteration to your hacks should works for it too..
change:
.item {
list-style-type: none;
height: 50px;
width: 50px;
position: relative;
border: 1px solid teal;
background: #00f;
display: -moz-inline-stack; /* for FF2 */
display: inline-block;
/* <ie hacks> */
zoom: 1;
*display: inline;
min-height: 50px;
_height: 50px; /* for ie6 */
/* </ie hacks> */
}
to:
.item {
list-style-type: none;
height: 50px;
width: 50px;
position: relative;
border: 1px solid teal;
background: #00f;
display: -moz-inline-stack; /* for FF2 */
display: inline-block;
}
.item {/** IE Hacks **/
display: inline !ie7; /* should work for 6 as well */
_height: 50px; /* IE6 */
}
putting the display:inline rule in a separate ruleset means you don't need zoom, and it should work for both IE6 and 7.
I just moved the min-height hack to keep them together ;) - as an aside I'm not sure why you've got min-height as you already have a height rule further up the stack and the 2nd height rule (which I removed) was just repeating, so perhaps you don't need the IE6 min-height hack anyway?