Mootools 1.4.3 Background Fade Effect - css

So I have code to swap the background, the problem I am having is incorporating the fade effect into it. I have messed with it for a while now and I am just getting frustrated. So the code is there, see how you can hack this to work.
Mootools 1.4.3
.socialIconsFB {
float: right;
display: block;
margin: -20px 3px;
width: 48px;
height: 57px;
background-image: url(XXXXXX/social_icons/facebook.png);
}
<div class="socialIconsFB"></div>
$$('.socialIconsFB').each(function(socialIconsFB) {
socialIconsFB.addEvent('mouseover', function() {
this.tween("background-image", "url(XXXXXX/social_icons/facebook.png)", "url(XXXXXX/social_icons/facebook_highlight.png)");
});
socialIconsFB.addEvent('mouseout', function() {
this.tween("background-image", "url(XXXXXX/social_icons/facebook.png)");
});
});

I think that "tween" effects not work with "background-image" but work with "background-color"
I would try in this way:
HTML:
<div class="socialIconsFB">
<span></span>
</div>
CSS:
.socialIconsFB {
float: right;
display: block;
margin: -20px 3px;
width: 48px;
height: 57px;
background-image: url(XXXXXX/social_icons/facebook.png);
}
.socialIconsFB span{
margin:0; padding:0;
opacity:0; filter:alpha(opacity=0);
width:100%;
height:100%;
background-image: url(XXXXXX/social_icons/facebook_highlight.png);
}
JAVASCRIPT:
$$('.socialIconsFB').each(function(socialIconsFB) {
socialIconsFB.addEvents({
'mouseenter': function(){
this.getChildren('span').tween("opacity", 1);
//it could be: this.getChildren('span')[0]
},
'mouseleave': function(){
this.getChildren('span').tween("opacity", 0);
//it could be: this.getChildren('span')[0]
}
});
});

Related

Is there a way to reproduce currentColor with var(--current-color)?

I don't use currentColor very often but when I do, it's extremely useful.
So I've been a little excited about the arrival of CSS Variables.
Let's take a traffic light.
N.B. Please take it on trust from me that Japanese traffic lights go red to amber to blue. I know it's hard to believe. I know the blue light looks sort-of green. But it isn't, it's blue.
div {
float: left;
width: 200px;
}
div div {
float: none;
}
.top {
color: rgb(255,0,0);
}
.middle {
color: rgb(255,227,0);
}
.bottom {
color: rgb(63,255,63);
}
.jp .bottom {
color: rgb(0,255,191);
}
.light {
text-align: center;
}
.light::before {
content: '';
display: block;
margin: 6px auto 0;
width: 25px;
height: 25px;
border-radius: 15px;
background-color: currentColor;
}
<div class="uk">
<h2>UK Traffic Lights</h2>
<div class="top light">Red</div>
<div class="middle light">Amber</div>
<div class="bottom light">Green</div>
</div>
<div class="jp">
<h2>JP Traffic Lights</h2>
<div class="top light">Red</div>
<div class="middle light">Amber</div>
<div class="bottom light">Blue</div>
</div>
Now, the clever thing about
background-color: currentColor;
is that it just reads whatever the current value for color is and uses that.
By contrast...
background-color: var(--current-color);
That can't reference the current value of another style declaration, can it?
So, you'd need to set up 4 variables (just like you need to declare color: 4 times in the styles above):
.top {
--color-top: rgb(255,0,0);
}
.middle {
--color-middle: rgb(255,227,0);
}
.bottom {
--color-bottom: rgb(63,255,63);
}
.jp .bottom {
--color-bottom-jp: rgb(0,255,191);
}
And then... you need to reference each of those different variables later on. Which means a different background-color declaration for each variable:
.top::before {
color: var(--color-top);
background-color: var(--color-top);
}
.middle::before {
color: var(--color-middle);
background-color: var(--color-middle);
}
.bottom::before {
color: var(--color-bottom);
background-color: var(--color-bottom);
}
.jp .bottom::before {
color: var(--color-bottom-jp);
background-color: var(--color-bottom-jp);
}
Really?!
That can't be right. Have I missed something?
Is there no way to reproduce currentColor with var(--current-color) ?
Is there no way for CSS variables to represent the current value of another style declaration?
Actually, you can set a CSS custom property instead of setting directly the color property, and use it for color and background-color.
/* Set global variable inside the :root scop */
:root {
--color-top: rgb(255,0,0);
}
div {
float: left;
width: 200px;
}
div div {
float: none;
}
/* Set the local --color variable, according to your need */
.top {
--color: var(--color-top);
}
.middle {
--color: rgb(255,227,0);
}
.bottom {
--color: rgb(63,255,63);
}
.jp .bottom {
--color: rgb(0,255,191);
}
.light {
color: var(--color);
text-align: center;
}
.light::before {
content: '';
display: block;
margin: 6px auto 0;
width: 45px;
height: 45px;
border-radius: 15px;
background-color: var(--color);
}
<div class="uk">
<h2>UK Traffic Lights</h2>
<div class="top light">Red</div>
<div class="middle light">Amber</div>
<div class="bottom light">Green</div>
</div>
<div class="jp">
<h2>JP Traffic Lights</h2>
<div class="top light">Red</div>
<div class="middle light">Amber</div>
<div class="bottom light">Blue</div>
</div>
I do not really understand why you are not using background-color: currentColor, because it works well in your own example.
If you are using SASS (which is compiled into css), then you can use SASS variables. The code will look like :
$font-stack: Helvetica;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
more informations on the SASS official website

Gear 2 (SM-380) doesn't support #media screen queries

I use the following media query in CSS and it works fine with Gear 2 Neo (SM-R381), but it doesn't work with an older Gear 2 (SM-R380). Do you have any idea why? Probably it's related to a difference in API level supported by these two devices? Any pointers are appreciated. Googling didn't help so far.
The styles are completely ignored by SM-R380, while honored by SM-R381.
#media screen and (max-width: 320px) {
/*
.ui-header {
top: 0;
height: 46px;
padding: 0;
border: 0;
}
.ui-footer {
border: 0;
padding: 0;
position: fixed;
width: 100%;
bottom: 0;
left: 0;
}
.ui-header > button, .ui-footer > button {
height: 46px;
padding: 0;
line-height: 48px;
}
footer.ui-footer {
height: 46px;
}
*/
.icon-title {
max-width:250px;
}
.icon-title-menu {
max-width:200px;
}
. digit {
width: 23px;
height: 34px;
float: left;
margin-right: 1px;
margin-left: 1px;
background-size: 100%;
background-repeat: no-repeat;
}
.colon {
background-image: url(../img/14x51/colon.png);
width: 8px;
height: 40px;
}
.token {
margin-left:auto;
margin-right:auto;
margin-top:5%;
width:154px;
height:auto;
}
.time {
margin-left:auto;
margin-right:auto;
margin-top:5%;
width:170px;
height:auto;
}
.pb {
margin-left:auto;
margin-right:auto;
margin-top:27%;
width:64px;
height:64px;
background-size: 100%;"
background-repeat: no-repeat;
}
}
After going back and forth with this and not getting a solution to make #media working on Gear 2 (SM-R380), I found a way around:
Created two stylesheets- one for 320x320 screen, another for 360x480
Added the following code to index.html just before </head> tag:
<script type="text/javascript">
function setStyle(kb) {
var link = document.createElement( "link" );
link.href = kb?"./css/style.css":"./css/style320.css";
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen";
document.getElementsByTagName( "head" )[0].appendChild( link );
}
tizen.systeminfo.getPropertyValue("DISPLAY",
function (disp) {
if (disp.resolutionWidth <= 320)
setStyle(false);
else
setStyle(true);
},
function (err) {console.log("Can't read display props: " + err.message); setStyle(false);}
);
</script>
Now it seems to be working and appstore has finally accepted the application.

How to add a map as the background of jumbotron

EDIT: jsfiddle
I have a leaflet map which is created by the html:
<div id="map"></div>
And a jumbotron
<div class="jumbotron">
<h1>Example Unit</h1>
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
</div>
with the following style
.jumbotron {
color: white;
text-shadow: #444 0 1px 1px;
background:transparent;
background-size: 100%;
margin-bottom:0;
}
How do I make the map as the background of the jumbotron?
EDIT:
the css
#map { height: 180px; }
the js
var map = L.map('map').setView([38.578, -77.243], 13);
L.tileLayer('http://{s}.tiles.mapbox.com/v3/MapID/{z}/{x}/{y}.png', {
maxZoom: 18
}).addTo(map);
Now it got the solution: I set the height and marginBottom of the mapDiv with javascript and add position:relative;
JS
var map = L.map('map').setView([38.578, -77.243], 13);
L.tileLayer('http://{s}.tiles.mapbox.com/v3/mapid/{z}/{x}/{y}.png', {
maxZoom: 18
}).addTo(map);
var height=document.querySelector('.jumbotron').offsetHeight;
document.getElementById('map').style.height=height+"px";
document.getElementById('map').style.marginBottom="-"+height+"px";
CSS
html,body {
height:100%;
}
.jumbotron {
color: white;
text-shadow: #444 0 1px 1px;
background:transparent;
background-size: 100%;
margin-bottom:0;
overflow: hidden;
position: relative;
}
.navbar {margin-bottom:0; }
#map { height: 0px;
margin:-30px -30px -0px -30px;
z-index:0;
}
.jumbotron h1,.jumbotron p
{
z-index:100;
position:relative;
}

Mouse over text adds border to several images, but when mouse over images there should be no effect

I have some text on a page, when someone mouses over it, it will highlight (using outline) several selected images on the same page. I want this to be one way, so mousing over the text highlights the images, but I want mousing over the images to have no effect, right now it also highlights everything. Is this possible? Note: each image has an id and a class (jquery draggable) already attached to it.
HTML:
<div class="container">
<div class="containerLeft">alignments</div>
<div><img src="http://www.cool-smileys.com/images/out11.jpg" id="position7" class="ui-widget-content" /></div>
<div><img src="http://www.cool-smileys.com/images/out12.jpg" id="position8" class="ui-widget-content" /></div>
<div><img src="http://www.cool-smileys.com/images/out13.jpg" id="position9" class="ui-widget-content" /></div>
<div> <img src="http://www.cool-smileys.com/images/out14.jpg" id="position12" class="ui-widget-content" /> </div>
</div>
CSS:
/* Normal Styles */
.containerLeft {
color:#333;
width:100px;
}
.containerLeft:hover {
width:100px;
}
/* Hover Styles */
.container:hover .containerLeft {
background-color: none;
}
.container:hover #position12 {
outline:2px solid #CFF;
}
.container:hover #position7 {
outline:2px solid #CFF;
}
.container:hover #position8 {
outline:2px solid #CFF;
}
.container:hover #position9 {
outline:2px solid #CFF;
}
#position7{
position:absolute;
margin: 0;
padding: 0;
border:none;
left: 13em;
top:9em;
z-index:17;
}
#position8{
position:absolute;
margin: 0;
padding: 0;
border:none;
left: 4em;
top:15em;
z-index:2;
}
#position9{
position:absolute;
margin: 0;
padding: 0;
border:none;
left: 7em;
top:5em;
z-index:20;
}
#position12{
position:absolute;
margin: 0;
padding: 0;
border:none;
left: 24em;
top:10em;
z-index:-14;
}
Right now everything is in css, but maybe there is a javascript solution?
The jsfiddle: http://jsfiddle.net/tMzMN/8/
If you want to use JS/Jquery you could achieve what you want this way:
$(".containerLeft").hover(function() {
$(".ui-widget-content").addClass("hover_class");
}, function() {
$(".ui-widget-content").removeClass("hover_class")
});
Then just replace all 4 of your CSS selectors that look like this:
.container:hover #position9 {
outline:2px solid #CFF;
}
...
with this:
.hover_class {
outline:2px solid #CFF;
}
Here is a fiddle of it in action: http://jsfiddle.net/tMzMN/9/
Also, and don't quote me on this, using the Jquery method above will probably have a greater level of backwards compatibility with older browsers as opposed to any CSS tricks you find. I could be wrong and there may very well be something that plays nice with IE<9 but I'm not sure...

Move elements with CSS

How would YOU change the CSS to move this to another part of the page?
Here is the image I'm using: http://www.frysa.us/switch.gif
The function:
<script type="text/javascript" src="jquery.js" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready( function(){
$(".cb-enable").click(function(){
var parent = $(this).parents('.switch');
$('.cb-disable',parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox',parent).attr('checked', true);
});
$(".cb-disable").click(function(){
var parent = $(this).parents('.switch');
$('.cb-enable',parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox',parent).attr('checked', false);
});
});
The repeating nature of the .gif seems to mess up the positioning for me.
I'd like it to appear over to the right a little more
<style type="text/css">
* { margin: 0; padding: 0: }
body { font-family: Arial, Sans-serif; }
.cb-enable, .cb-disable, .cb-enable span, .cb-disable span { background: url
(switch.gif) repeat-x; display: block;float: left;}
.cb-enable span, .cb-disable span { line-height: 30px; display: block; background-
repeat: no-repeat; font-weight: bold; }
.cb-enable span { background-position: left -90px; padding: 0 10px; }
.cb-disable span { background-position: right -180px;padding: 0 10px; }
.cb-disable.selected { background-position: 0 -30px; }
.cb-disable.selected span { background-position: right -210px; color: #fff; }
.cb-enable.selected { background-position: 0 -60px; }
.cb-enable.selected span { background-position: left -150px; color: #fff; }
.switch label { cursor: pointer; }
</style>
If you just want to move it to the right by 120 pixels, give your element (right now it's the paragraph tag) an ID and do this:
#switchingButton{
margin-left: 120px;
}
You can use padding-left: 120px; as well if your design would require padding rather than margin.

Resources