Masks not working in Gecko - firefox

I am trying to mask an element that has some images inside of it, using only css.
i have done this and it works fine in webkit using -webkit-mask-box-image and its doing just what i want, but im having trouble using other browsers.
gecko is supposed to work using mask, and that tag does show up in firebug, but it doesnt actually use the mask.. i've also tried converting the png im using to base64 data uri, but to no avail.
example: http://jsfiddle.net/nNLta/
does anyone know the correct way for doing this?
HTML
<div id='wrap'>
<div class='masked flashing-anim'>
<div class='the-mask' >
<ul>
<li class='blink_1'></li>
<li class='blink_2'></li>
</ul>
</div>
</div>
<div class='the-outline'>
<img src='img/real-stuff.png' height=500 />
</div>
</div>
CSS
#wrap {
position: relative;
}
.the-outline, the-mask {
position: absolute;
top: 0;
}
.the-mask {
height: 500px;
width: 360px;
-webkit-mask-box-image: url(../img/the-mask.png);
-moz-mask-box-image: url(../img/the-mask.png);
-o-mask-box-image: url(../img/the-mask.png);
mask-box-image: url(../img/the-mask.png);
mask: url(data:lotsofchars);
}
example: http://jsfiddle.net/nNLta/

Part 1
mask is not the same as mask-box-image unfortunately. If you read the (rather sparse) docs you will see it is applicable to SVG only. More on this later.
Currently Gecko doesn't support 'mask-box-image' - if you search the MDN you'll see it applies to -webkit- only.
Additionally I don't think this is actually spec. Webkit has had this capability/concept for ages (in various forms like -webkit-box-reflect) and I think that it's just a hangover from those days. I'm not sure whether this will even be adopted by all browser vendors (although I hope, and it makes sense that, it will).
Part 2
To use the svg dependant mask: css property you need to create an SVG element and reference that. Here is a guide. I've not used this technique before so I'm afraid that's all the detail I'm going to go into right now.
An alternate option
If you don't need a clever repeating/growing mask why not create a large png and overlay the text/image you wish to hide. I'm not sure I understand what you are ultimately trying to do but this seems pretty simple to me. The obvious issue is when you need the stuff behind the mask to be selectable/interactable (err..interactive that is...); for instance when you wish to apply masking to text or links. A way around this is to use pointer-events:none which is supported in Gecko and Webkit (but nothing else...). Here's more from the MDN
Sorry I don't have better news - if none of the above is helpful please feel free to leave a comment with your specific requirement and we'll see if we can't work around the browser limitations.
Hope this is helpful!

Related

Make entire div clickable

I am trying to get the whole div clickable and this works but only with a straight link to another site. Is there a way to make it work with this text in it also:
<div class='reddit' title='Share Us On Reddit' onclick="window.open('http://www.reddit.com/submit?url=httpsFwww.example.com&title=XXX is Cape Breton's Homepage. Start Your Web Search With Beautiful Cape Breton Island')">
Thanks
From CSS Tricks
This probably isn't a thing you need to rely on JavaScript for
anymore. Since HTML5, this is perfectly valid:
<a href="http://example.com">
<div>
anything
</div>
</a>
And remember you can make links display: block; so sometimes you
don't even need the div.
<div style="cursor:pointer" onclick="document.location='evenidontknow-page.html'">
<h2>Full Div Clickable</h2>
</div
The above code helped me very well, and this will not require any extra code.
Using a tag may solve the problem but we need to add extra code to it.
please check this link for more info w3schools
Bootstrap has a feature called "Stretched Link". From the documentation:
Make any HTML element or Bootstrap component clickable by “stretching” a nested link via CSS.
You can read more by visiting the following link:
https://getbootstrap.com/docs/4.4/utilities/stretched-link/

What can go wrong when creating a jQuery plugin that responds to proportional media queries?

The assumption behind this question is that the designer is using proportional queries in a Responsive Web Design and going from 1-column on a smartphone to 2 and 3-column on the displays where they will comfortably fit.
A content widget jQuery plugin (like a Recent Updates widget) should change it's character in the different layouts. In 1-column layout it might need to be 4 small text links and in 2 or 3-column layouts it can include thumbnails and extra text.
For reference, here's the code as the end-user of the content widget would see it.
HTML:
<section id="sidebar">
<section id="latestupdates"></section>
</section>
JS:
(function($){
$(function(){
$("#latestupdates").widgetco_latestupdates();
});
})(jQuery);
I think the best way to hook into the designers layout changes is this. Ask for the breakpoints as parameters for widgetco_latestupdates during initialization and use the resize events to toggle css classes.
Is this even the right method? What are the pitfalls with doing this?
UPDATE:
Since asking, I have found enquire.js which will handle running the queries. That still leaves the question of this being the right method.
If you are careful with the classes you assign to the content, you can likely control everythinhg with standard CSS.
For example, say your desktop output was something like
<article>
<h1> Update heading </h1>
<img src="..">
<p class="intro"> Intro text ... </p>
<p class="full-text"> Full text here </p>
read more
</article>
Then in your CSS you manage what content to show on which devices with
#media screen and (max-width: 480px){
/* for smartphones */
article img, p.intro{
display:none;
}
}
#media screen and (min-width: 481px) and (max-width: 800px){
/* for tablets */
p.full-text{
display:none;
}
}
I think if you can use CSS to manage the different layouts it will be more flexible and easier to update going forward.
Good luck!
EDIT
If you are thinking about ajax to add / remove content based on the visitor's viewport, here are two interesting links:
http://filamentgroup.com/lab/ajax_includes_modular_content/
Project on Github

Twitter Bootstrap: Image positioning

I am customizing my website using Twitter Bootstrap. I am trying to insert an image positioned as the top layer, is located slightly "outside of the container", and can responsively resize while staying proportionate / in relation to the other elements. I would like to use position: relative, but the image seems forced into a box within the container. When I use position: absolute, the image displays correctly at first on my web browser, but it does not behave as intended when the screen is resized.
Can anyone help me figure out a good solution to this issue?
HTML: I do not have the image contained within it's own , but is still located within the overall . Here's the code:
<img src="images/hero-babee.png" alt="Babee blowing bubbles." id="babee-bubbles">
CSS: Here's my custom css.
img#babee-bubbles {
z-index: 100;
position: relative;
top: 51%;
left: 7.5%;
}
I'd appreciate any help finding a solution and/or help with my code / syntax. Thanks in advance.
To design responsive website using bootstrap you can use bootstrap layout.
Fluid layout has class "row-fluid" and you can specify width in using class as span.
this structure will be responsive. to test it just resize your browser window.
<div class="row-fluid">
<div class="span2">
<img>....</img>
......
</div>
<div class="span2">
</div>
......
</div>
Bootstrap devide screen size in 12 part. we can use that part by giving
class="span*"
* is no of part.

Css Form don't fit the page

In all my pages my content fit to the body:
But where i have forms they go over the footer and body don't resize:
Where is the problem?
Your form probably contains a lot of floated elements, so you might want add this to your <form> CSS:
form {
...
overflow: hidden;
}
I have experienced something similar this week.
Try using
<div style="clear:both"/>
to encapsulate your content within your page.
<div id="mainDiv">
content
<div style="clear:both"/>
</div>
the issue is clearly with floated elements in the form. You can fix it using the micro clearfix by Nicolas Gallagher, currently the "best practice" for the issue
http://nicolasgallagher.com/micro-clearfix-hack/
Don't use overflow: hidden; as it might give you trouble if you want any element to overflow the form. (eg. select).
Also, tables are not a good idea for the layout, and empty divs to clear are not necessary.

What is the best way to clear floated elements in CSS?

What is currently considered the best way to clear CSS floated elements that will:
Keep the HTML markup as semantic and free of unnecessary elements as possible, and
Be a cross-browser, cross-platform solution that works reliably for the majority of browsers?
This isn't a graphic design question. It's a CSS one, so belongs on StackOverflow.
That said, the answer for keeping the HTML clean is simply to give the parent an overflow. So if your markup is:
<div class="wrapper">
<div style="float: left;"></div>
<div style="float: left;"></div>
</div>
you can give wrapper an overflow:
.wrapper {overflow: auto}
And now .wrapper will contain both the floats.
That's usually all that is needed.
Sometimes, in older IEs, the container also needs a width.
You can make this more complicated, but a simple way is to add a class to your CSS called .clearfix with this attribute:
.clearfix {clear: both;}
Then just insert a tag underneath what you want to clear.
Google clearfix for more modern ways to define the tag.
The best method I've seen for this is using :before & :after pseudo elements for modern browsers and zoom: 1 for older versions of IE.
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
/* For IE 6/7 (trigger hasLayout) */
.cf {
zoom:1;
}
More info here:
http://nicolasgallagher.com/micro-clearfix-hack/
a little tricky, but it's work for modern browser :)
.wrapper::after {
content:"";
clear:both;
}

Resources