Possible to have a fully transparent inset box-shadow? - transparency

Is it possible to have the two divs with box-shadow overlap with fully transparent edges? In my example, I want to keep the faded, kind of rounded edge, but it's important that the underlying box is visible through the fade. But as you can see the faded edge is not entirely transparent so it will show a white border rather than let the blue color shine through..
Is it possible to make this work without resorting to png or similar?
Example
.bg {
background-image: -moz-linear-gradient(right top , rgba(255, 255, 255, 0) 0%, #FF0000 100%);
box-shadow: 0 0 90px 90px rgba(255, 255, 255, 0) inset;
-webkit-box-shadow: 0 0 90px 90px rgba(255, 255, 255, 0) inset;
-moz-box-shadow: 0 0 90px 90px rgba(255, 255, 255, 0) inset;
opacity: 0.7;
position: absolute;
}

I don't know whether this is possible with inset box-shadow; however you can make them overlap seamlessly with outset box-shadow for the overlapping element.
All you have to do is give the overlapping element a box-shadow color that is the same as its background-color.
I have edited your sample here: (I didn't copy all the vendor-specific prefixes, just used box-shadow).
http://jsbin.com/orajot/4/edit

Related

Nativescript 8 IOS shadow cornerRadius bug

Here is an example with test shadow (black) for element(white) with cornerRadius 17dpi
But the shadow takes on a radius that is larger than the element it belongs to and visually it looks like the shadow becomes cornerRadius 50% but should be 17 dpi.
Expected result: the cornerRadius on the shadow should match the cornerRadius on the element
This is reproduced in the case of applying a shadow through styles:
box-shadow: 0 20 0 #000;
To element with:
border-radius: 17;
package.json
"#nativescript/core": "8.3.6",
"#nativescript/ios": "8.2.3",
If you apply the shadow directly, it works as it should
const nsView = args.object;
const nsColorShadow = new Color('black');
const nsColorBg = new Color('white');
const iosView = nsView.ios;
iosView.layer.masksToBounds = false;
iosView.layer.shadowColor = nsColorShadow.ios.CGColor;
iosView.layer.shadowOpacity = 1;
iosView.layer.shadowRadius = 0;
iosView.layer.cornerRadius = 17;
iosView.layer.backgroundColor = nsColorBg.ios.CGColor;
iosView.layer.shadowOffset = CGSizeMake(0, 20);
I think that this is fix in core#8.4.2 https://github.com/NativeScript/NativeScript/pull/10142
iosView.layer.cornerRadius is in dp (device pixels), not dip (device independent pixels). When you're setting border-radius: 17; you're setting in dip. You could also set it as border-radius: 17px; to get the same result as you had on the manual setting of the view.
The reason you're seeing it stuck at 50% is because 50% is the max value for border-radius, and 17dip converted to dp will be larger than 50%, so it'll clip to 50%.

How can I implement a box shadow element in swift?

Please see the box attached. I want to implement that box in swift. How can I do it?
Here's the CSS:
background: #FFFFFF;
border: 1px solid #DAD9D9;
box-shadow: inset 2px 2px 0px rgba(0, 0, 0, 0.25);
border-radius: 30px 30px 0px 0px;
Here's what I tried:
self.answerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.0).cgColor
self.answerView.layer.shadowOpacity = 0.25
self.answerView.layer.cornerRadius = 30
self.answerView.layer.shadowOffset = CGSize(width: 2, height: 2);
self.answerView.layer.shadowRadius = 0
Try this:
self.answerView.borderStyle = .none
self.answerView.layer.cornerRadius = 10
self.answerView.layer.backgroundColor = UIColor.systemGray3.cgColor
self.answerView.backgroundColor = UIColor.systemBackground
self.answerView.layer.shadowColor = UIColor.systemGray3.cgColor
self.answerView.layer.shadowOpacity = 1
self.answerView.layer.shadowRadius = 0
self.answerView.layer.shadowOffset = CGSize(width: 0, height: 2.5);
self.answerView.layer.shadowRadius = 0
self.answerView.borderColor = UIColor.systemGray3
self.answerView.borderWidth = 2
If you only want to round the top corners, you should set the appropriate values to CALayer.maskedCorners.

Gradients give the wrong color on iOS mobile safari

I'm developing a mobile app with Cordova Phonegap that uses gradients that stack on top of eachother. On Android everything works as it is supposed to but on iOS the gradients shows up different. The edges are green whereas when I preview it in my browser it is blue as it's supposed to be. There's also this weird transition at the bottom of the page.
This is my css:
#gradient2Layer1 {
position: fixed;
height: 100px;
bottom: 0;
left: 0;
height: 20%;
width: 100%;
color = "blue";
background: -webkit-linear-gradient(270deg, rgba(15,431,28,0) 35%, #b3c6ff 50%,rgb(128,128,128) 100%);
z-index: 100; }
#gradient2Layer2 {
position: fixed;
height: 100px;
bottom: 0;
left: 0;
height: 20%;
width: 100%;
opacity: 0.5;
color = "blue";
background: -webkit-linear-gradient(270deg, rgba(15,431,28,0) 35%, blue 50%, blue 100%);
animation: fadeIn 5s infinite alternate;
z-index: 100; }
How can I fix this?
I really believe this is a typo and you wanted to use rgba(15,43,128,0) (which is the shade of blue you're looking for) instead of rgba(15,431,28,0), which is not even a valid RGB value (limited to 0..255).

Border-radius issue on iPad, iPad 2

Having border-radius issues on iPad(3.2), iPad 2 (4.3.2).
Here's the code:
.articles .post .left img{
width:100%;
border-radius: 0 0 100% 0;
-moz-border-radius: 0 0 100% 0;
-khtml-border-radius: 0 0 100% 0;
-webkit-transition: border-radius 1s;
transition-delay: 0.1s;
transition-duration: 0.5s;
transition-property: all;
transition-timing-function: ease;
}
And this is the result I'm getting:
Any ideas on how to get the desired result I'm after?
On iOS 4, use border-radius css on the container of img and set over-flow:hidden.
the container will 'cut' the img into rounded cornor.
its a tweak.
Try adding
-webkit-border-radius: 0 0 100% 0;
As Safari on IOS5 needs that to render border radius.

Corona sdk linear color ramp?

Ok, I have a very, very large background image, well not an image but a rectangle colored blue:
bg2 =display.newRect(0,0,20000,20000)
bg2.y=10000
bg2:setFillColor( 0 , 0, 225)
Is it possible to make the rectangle not just one solid color, but a linear color ramp from black to blue? In other words, the color fades from black to blue vertically. I don't want to use an image, because it would be way too large.
You're looking for a gradient fill color, such as this.
local black = {0, 0, 0}
local blue = {0, 0, 1}
local g = {type="gradient", color1=black, color2=blue}
bg2:setFillColor(g)

Resources