I am trying to build Screen like below but in the result parent view opacity inherit inside child view too.is anyone knows how to resolve this issue
below are the what am i trying to create and the result what i get.
what i want:
result what i get:
Code
<View style={styles.container} >
<Image
source={{
uri: 'http://i.imgur.com/sIaHZ9i.png',
}}
style={styles.image} >
</Image>
<View style={styles.subcontainer} >
<View style={styles.locationview}>
<View
style={styles.lastcircle}>
<View
style={styles.last} /></View>
<Entypo
name="location-pin"
style={styles.icon}
size={35}
/>
</View>
<View style={styles.contentContainer} >
<Text style={styles.title}>DELIVERING TO</Text>
<Text style={styles.text}>Locating...</Text>
</View>
</View>
</View>
CSS
subcontainer:{
flex:1,
backgroundColor:'rgba(255, 255, 255,0.8)',
alignItems:'center',
justifyContent:'center'
},
locationview:{
height:130,
width:130,
borderColor:'#CAD5E2',
borderWidth:1,
borderRadius:70,
marginBottom:20,
},
If you post to and join the Geographic Information Systems Stack Exchange they might have some helpful tips in CSS and supply more people understanding your map related problem https://gis.stackexchange.com/
Here are a few other resources that might help:
https://gis.stackexchange.com/questions/106811/make-leaflet-map-background-transparent
change opacity of image.map area
https://www.sitepoint.com/community/t/change-opacity-of-an-area-of-an-image/274316
Check out Codepen.io too which had a solution by Paul O'Brien on spot opacity in CSS , but StackOverflow won't allow me to link it here.
This is not my code, This is the code from Paul O Brien on Codepen
CSS :
.hole {
position: relative;
display: inline-table;
margin:10px;
}
.hole img {
opacity: 0.5;
}
.hole:after{
content: "";
position: absolute;
z-index: 2;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background: url(https://picsum.photos/300/300) no-repeat 0 0;
border-radius: 50%;
}
.hole2 img,.hole3 img{
filter: blur(2px);
}
.hole3:after{
width:100px;
height:100px;
margin:auto;
background-size:300px 300px;
background-position:50% 50%;
}
.hole4:after{
transition:all 2s ease;
margin:0;
background-position:0% 0%;
}
.hole4:hover:after{
background-position:100% 100%;
margin:calc(100% - 100px) 0 0 calc(100% - 100px);
}
.hole5:after{
transition:all 1s ease;
height:0;
width:0;
}
.hole5:hover:after{
width:150px;
height:150px;
}
<div class="hole hole1">
<img src="https://picsum.photos/300/300" width="300" height="300" alt="Sea View">
</div>
<div class="hole hole2">
<img src="https://picsum.photos/300/300" width="300" height="300" alt="Sea View">
</div>
<div class="hole hole3">
<img src="https://picsum.photos/300/300" width="300" height="300" alt="Sea View">
</div>
<div class="hole hole3 hole4">
<img src="https://picsum.photos/300/300" width="300" height="300" alt="Sea View">
</div>
<div class="hole hole3 hole5">
<img src="https://picsum.photos/300/300" width="300" height="300" alt="Sea View">
</div>
<p>(Hover the last 2 images)</p>
Related
I've a <div> wrapped within <a>. a:active has css to transform the element but I don't want that behaviour (transform) to be there while I focus on bx--overflow-menu child. I am using NextJS with styled-jsx and SaSS. Below is my code :
<a class="singleTile" data-cta-type="unimplemented" href="test">
<div class="bx--row">
<div class="bx--overflow-menu" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Menu" tabindex="0">
<svg focusable="false" aria-label="open and close list of options" role="img" class="bx--overflow-menu__icon">
<circle cx="8" cy="3" r="1"></circle>
<circle cx="8" cy="8" r="1"></circle>
<circle cx="8" cy="13" r="1"></circle>
<title>open and close list of options</title>
</svg>
</div>
<div class="bx--col">
<p class="name-212">cougar</p>
<p class="name-213">Version:<span class="" style="display: inline;">test.1</span></p>
</div>
</div>
</a>
The styles:
<style>
.singleTile {
flex: none;
width: 100%;
border: 1px solid #e0e0e0;
display: block;
padding: 1rem;
transition: all 150ms cubic-bezier(0.2, 0, 0.38, 0.9);
background-color: #ffffff;
}
a.singleTile:hover {
border-color: red;
}
a.singleTile:active {
transform: scale(.994);
}
.bx--overflow-menu{
top: 0;
right: .25rem;
position: absolute;
}
</style>
I have some idea that it can't be done with CSS only and I am also not allowed to use jQuery.
Any other suggestions will be helpful.
There are no parent selectors in css right now. It could be possible to implement this on next css4.
.singleTile:has(> bx--overflow-menu:active) { /* styles to apply to the singleTile tag */ }
I have a requirement to display 2 circles with different widths and heights but circles should start from same origin ( same center ), it means even though I change the sizes of both the circles they should look same with different sizes.
I have seen some bunch of examples over internet,problem with them is when I change the width and heights center point of both the circles are not the same anymore.
Also when I do hover they have to increase the size with smooth transition.
I am guessing that I need two circles to draw something like this, if we can draw with using only one circle please let me know.
Outer circle details:
inner circle
width: 97.33px;
height: 97.33px;
color: #DEBF43;
opacity: 74%;
shadow: #D7E0F1, 100%;
blur: 30px;
x - 0px //no idea but is mentioned in requirement
y 10px //no idea but is mentioned in requirement
outer circle details:
width: 79.49
height: 79.49
shadow: #000000,15%;
blur: 6px;
opacity: 100%;
X - 0px //no idea but is mentioned in requirement
y - 1px //no idea but is mentioned in requirement
Thanks,
Rohan
I would use a SVG with circles. It is quite easy and well readable.
Get two circles aligned with different radius and manipulate them via Javascript. Just overwrite the r-property.
Here a quick example with Vue:
new Vue({
el: '#app',
data: {
r1: 120,
r2: 90,
}
});
/* circles */
.circle--1 {
fill: yellow;
}
.circle--2 {
fill: orange;
}
.transparent {
opacity: 0.4;
}
/* demo stuff */
.container {
display: flex;
flex-flow: row wrap;
justify-content: center;
align-content: flex-start;
background: #ccc;
height: 100vh;
}
.svg, aside {
background-color: #fff;
box-shadow: 0 0 4rem #00000033;
margin: 1rem;
}
aside {
width: 300px;
height: 300px;
display: flex;
flex-flow: column;
justify-content: space-evenly;
align-items: center;
}
label {
display: block;
font-weight: 700;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<main id="app" class="container">
<!-- svg with two circles -->
<svg class="svg" width="300" height="300">
<circle class="circle circle--1" cx="50%" cy="50%" r="120" stroke="black" stroke-width="2"/>
<circle class="circle circle--2" cx="50%" cy="50%" r="90"/>
</svg>
<!-- demo svg with editable radii -->
<svg class="svg" width="300" height="300">
<circle id="circle-1" class="circle circle--1 transparent" cx="50%" cy="50%" :r="r1" stroke="black" stroke-width="2"/>
<circle id="circle-2" class="circle circle--2 transparent" cx="50%" cy="50%" :r="r2"/>
</svg>
<!-- demo controls -->
<aside>
<section>
<label for="radius1">Radius 1 ({{r1}}px)</label>
<input type="range" id="radius1" min="0" max="140" v-model="r1">
</section>
<section>
<label for="radius2">Radius 2 ({{r2}}px)</label>
<input type="range" id="radius2" min="0" max="140" v-model="r2">
</section>
</aside>
</main>
Here is a simple idea where you can rely on multiple background. The trick is to make the gradient to cover only the content box and control the space using padding:
.box {
width:100px;
height:100px;
border-radius:50%;
border:5px solid;
padding:20px;
background:
linear-gradient(orange,orange) content-box,
yellow;
}
<div class="box">
</div>
Or like this with a radial-gradient
.box {
width:100px;
height:100px;
border-radius:50%;
border:5px solid;
padding:20px;
background:
radial-gradient(farthest-side,orange 60%,yellow 61%);
}
<div class="box">
</div>
I know there are many css filters out there especially for webkit, but I can't find a solution for colorize a white (#FFFFFF) image. I've tried some combination of the filters, but none of them make my image colorized. I can only change the image in the range of grayscale, or sepia.
So my question is:
Is there any way to change my totally white png to (for example) red using css only?
Like shown on this image:
This can be done with css masking, though unfortunately browser support is really bad (I believe webkit only).
http://jsfiddle.net/uw1mu81k/1/
-webkit-mask-box-image: url(http://yourimagehere);
Because your image is all white, it is a perfect candidate for masking. The way the mask works is that wherever the image is white, the original element is shown as normal, where black (or transparent) the original element is not shown. Anything in the middle has some level of transparency.
EDIT:
You can also get this to work in FireFox with slight help from svg.
http://jsfiddle.net/uw1mu81k/4/
div {
width: 50px;
height: 50px;
mask: url(#mymask);
-webkit-mask-box-image: url(http://www.clker.com/cliparts/F/5/I/M/f/U/running-icon-white-on-transparent-background-md.png);
}
<div style="background-color: red;"></div>
<div style="background-color: blue;"></div>
<div style="background-color: green;"></div>
<div style="background-color: orange;"></div>
<div style="background-color: purple;"></div>
<svg height="0" width="0">
<mask id="mymask">
<image id="img" xlink:href="http://www.clker.com/cliparts/F/5/I/M/f/U/running-icon-white-on-transparent-background-md.png" x="0" y="0" height="50px" width="50px" />
</mask>
</svg>
I recently have the same question and I think this approach is worth sharing for future readers.
Try this
filter: brightness(50%) sepia(100) saturate(100) hue-rotate(25deg);
Brightness will darken the image, sepia will make it a bit yellowish, saturate to increase the color, and lastly hue-rotate to change the color.
It's not cross browser friendly though:
It's not supported on IE
On chrome, hue-rotate(25deg) will make any image red, but you need
negative value in firefox e.g. hue-rotate(-25deg) to make it red. You can use this to target mozilla browsers:
https://css-tricks.com/snippets/css/css-hacks-targeting-firefox/
Here are some useful tips and tools that I've used when I work with images/icons using css:
If you have the svg version of the image, you can convert them to
font icons using this tool https://icomoon.io/ . To change color you just need color:#f00; just like font colors.
If you need to achieve this effect for hover state, Use red image with filter: brightness(0) invert(); on NON-hover state, and filter: brightness(1); on hover state. Hovever this will still won't work on IE
Use sprite sheet. You can create yourself using image editing tool or use sprite sheet generators available online. Then, you can use SpriteCow to get the css for every sub-image of your spritesheet.
This can be done with a CSS filter that references an SVG Filter. Here is the SVG filter (the "1 1 1" in the first line of values converts the blue and green channels to red.)
<svg width="800px" height="600px">
<filter id="redden" color-interpolation-filters="sRGB">
<feColorMatrix type="matrix" values="1 1 1 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0"/>
</filter>
<image filter="url(#redden)" width="190" height="400"
preserveAspectRatio="xMinYMin slice"
xlink:href="http://i.stack.imgur.com/e6MUC.jpg"/>
</svg>
i tried to color my white cloud picture following #zekkai's answer, and then i wrote a filter generator.
var slider_huerotate = document.getElementById("slider_huerotate");
var slider_brightness = document.getElementById("slider_brightness");
var slider_saturate = document.getElementById("slider_saturate");
var slider_sepia = document.getElementById("slider_sepia");
var output = document.getElementById("demo");
var cloud = document.getElementById('cloud');
let [brightness, sepia, saturate, huerotate] = ["100", "80", "100", "360"];
var filtercolor = `brightness\(${brightness}%\) sepia\(${sepia}\) saturate\(${saturate}\) hue-rotate\(${huerotate}deg\)`
// Display the default slider value
output.innerHTML = filtercolor;
// Update the current slider value (each time you drag the slider handle)
slider_huerotate.oninput = function() {
huerotate = this.value;
var filtercolor = `brightness\(${brightness}%\) sepia\(${sepia}\) saturate\(${saturate}\) hue-rotate\(${huerotate}deg\)`
cloud.style.filter = filtercolor;
output.innerHTML = filtercolor;
}
slider_brightness.oninput = function() {
brightness = this.value;
var filtercolor = `brightness\(${brightness}%\) sepia\(${sepia}\) saturate\(${saturate}\) hue-rotate\(${huerotate}deg\)`
cloud.style.filter = filtercolor;
output.innerHTML = filtercolor;
}
slider_sepia.oninput = function() {
sepia = this.value;
var filtercolor = `brightness\(${brightness}%\) sepia\(${sepia}\) saturate\(${saturate}\) hue-rotate\(${huerotate}deg\)`
cloud.style.filter = filtercolor;
output.innerHTML = filtercolor;
}
slider_saturate.oninput = function() {
saturate = this.value;
var filtercolor = `brightness\(${brightness}%\) sepia\(${sepia}\) saturate\(${saturate}\) hue-rotate\(${huerotate}deg\)`
cloud.style.filter = filtercolor;
output.innerHTML = filtercolor;
}
.slider {
-webkit-appearance: none;
width: 350px;
height: 15px;
border-radius: 5px;
background: #d3d3d3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
img {
width: 300px;
z-index: 100;
filter: brightness(100%) sepia(80) saturate(100) hue-rotate(360deg);
padding: 70px 25px 50px 25px;
}
.wrapper {
width: 600px;
height: 500px;
padding: 50px;
font-size: small;
}
.slidecontainer_vertical {
margin-top: 50px;
transform: translate(0, 300px) rotate(270deg);
-moz-transform: rotate(270deg);
}
.left {
width: 50px;
height: 300px;
float: left;
}
.cloud {
width: 100%;
}
.middle {
width: 350px;
height: 300px;
float: left;
margin: 0 auto;
}
.right {
width: 50px;
height: 300px;
float: left;
}
#demo {
width: 100%;
text-align: center;
padding-bottom: 20px;
font-family: 'Handlee', cursive;
}
<head>
<link href="https://fonts.googleapis.com/css?family=Handlee" rel="stylesheet">
</head>
<div class="wrapper">
<div class="left">
<div class="slidecontainer_vertical">
<input type="range" min="0" max="360" value="360" class="slider" id="slider_huerotate">
</div>
</div>
<div class="middle">
<div class="slidecontainer">
<input type="range" min="0" max="100" value="100" class="slider" id="slider_brightness">
</div>
<div id="cloud">
<img src="https://docs.google.com/drawings/d/e/2PACX-1vQ36u4x5L_01bszwckr2tAGS560HJtQz4qblj0jnvFUPSgyM9DAh7z_L3mmDdF6XRgu8FkTjqJKSNBQ/pub?w=416&h=288">
</div>
<div id="demo"></div>
<div class="slidecontainer">
<input type="range" min="0" max="100" value="80" class="slider" id="slider_sepia">
</div>
</div>
<div class="right">
<div class="slidecontainer_vertical">
<input type="range" min="0" max="100" value="100" class="slider" id="slider_saturate">
</div>
</div>
</div>
I'm trying to figure out a way to center vertically my SVG Tag.
Basically, here is a simplified SVG code i'm trying to center :
<svg height="272" style="background-color:transparent;margin-left: auto; margin-right: auto;" width="130" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g style="font-size: 0.7em;" transform="scale(1 1) rotate(0) translate(0 270)">
<g id="1" style="font-size: 0.7em;">
<image height="32" width="32" x="49" xlink:href="../../images/JOB.GIF" y="-270"/>
</g>
</g>
</svg>
I have no trouble putting it in the middle (horizontally speaking) of the page, however i'd like it to be vertically centered as well.
I can add wrappers, but i'd like to know a generic way of doing this, not depending on the SVG size nor the window size.
I have tried multiple ways, but nothing worked.
Thanks,
I updated this answer as current browser have a lot better solution for that.
How wise man said, first year you learn html and css, for another few years you learn advanced javascript and after five years you finally learn how to vertically center div.
to vertically/horizontally align anything in css you can use two main ways:
Absolute
<div class="outside">
<div class="inside">Whatever</div>
</div>
and css:
.outside{
position:relative;
}
.inside{
position:absolute;
top:50%;
bottom:50%;
transform:translate(-50%, -50%);
}
the only issue with that is that element doesn't generate the height.
Flexbox
Flexbox has now pretty good support so why not to use it. https://caniuse.com/#feat=flexbox
Using flexbox your item doesn't need to be absolute so it will generate the height. code:
<div class="outside">
<div>Whatever</div>
</div>
and css:
.outside{
display: flex;
align-items: center;
justify-content: center;
}
Old answer:
you have height and width so u can use margin : auto auto;
or put it in div with
position:absolute ;
left:50% ;
margin-left: -(half of width of image)px;
top:50% ;
margin-top: -(half of height of image)px;
the second one will be better if u will be doing some stuff with it (javascript animation or something)
I didn't check it but maybe u can use second option for svg (without outer div) too
It's Simple!
HTML:
<div class="a">
<div class="b">
<div class="c">
<!-- Your SVG Here -->
</div>
</div>
</div>
CSS:
<style>
.a {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.b {
display: table-cell;
vertical-align: middle;
}
.c {
margin-left: auto;
margin-right: auto;
height: /* Your size in px, else it will expand to your screen size!*/
width: /* Your size in px, else it will expand to your screen size!*/
}
</style>
If you provide your svg element with a viewBox attribute and set it's width & height attributes to 100% then all should be well (in most browsers..)
$(document).ready(function(){
$(".panel-left").resizable({handleSelector: ".splitter",containment: "parent"});
});
#ctr
{
position: absolute;
border: 1px solid #131313;
top: 5%;
left: 5%;
bottom: 5%;
right: 5%;
display: flex;
flex-direction: row;
}
#ctr svg
{
height: 100%;
width: 100%;
}
.panel-left
{
flex: 0 0 auto;
padding: 10px;
width: 50px;
min-height: 50px;
min-width: 50px;
max-width: 80%;
max-height: 100%;
white-space: nowrap;
background: #131313;
color: white;
}
.splitter
{
flex: 0 0 auto;
width: 18px;
}
.panel-right
{
flex: 1 1 auto;
padding: 10px;
min-width: 20px;
background: #eee;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div style="visibility:hidden; position:absolute; width:0">
<svg>
<g id="my-funky-svg-defs">
<defs>
<radialGradient id="gradient" cx="25%" cy="25%" r="100%" fx="40%" fy="40%">
<stop offset= "0%" stop-color="hsla(313, 80%, 80%, 1)"/>
<stop offset= "40%" stop-color="hsla(313, 100%, 65%, 1)"/>
<stop offset="110%" stop-color="hsla(313, 100%, 50%, 0.7)"/>
</radialGradient>
</defs>
<title>smarteee</title>
<circle class="face" cx="200" cy="200" r="195" fill="url(#gradient)" />
<ellipse class="eye eye-left" cx="140" cy="150" rx="10" ry="40" fill="#131313"/>
<ellipse class="eye eye-right" cx="260" cy="150" rx="10" ry="40" fill="#131313"/>
<path class="smile" d="M120,280 Q200,330 280,280" stroke-width="10" stroke="#131313" fill="none" stroke-linecap="round"/>
</g>
</svg>
</div>
<div id=ctr>
<div class="panel-left">
<svg viewBox="0 0 400 400"><use xlink:href="#my-funky-svg-defs"></use></svg>
</div>
<div class="splitter">
</div>
<div class="panel-right">
<svg viewBox="0 0 400 400"><use xlink:href="#my-funky-svg-defs"></use></svg>
</div>
</div>
&here's a corresponding jsfiddle to play with
NB: there is also the preserveAspectRatio attribute that works in conjunction with the viewBox settings. eg: preserveAspectRatio="xMidYMid meet"
You could try using flexbox.
Simple HTML:
<div class="outside">
<svg />
</div>
CSS:
.outside {
display: flex;
align-items: center; /* vertical alignment */
justify-content: center; /* horizontal alignment */
}
HTML with your sample:
<div class="outside">
<svg height="272" style="background-color:transparent;margin-left: auto; margin-right: auto;" width="130" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g style="font-size: 0.7em;" transform="scale(1 1) rotate(0) translate(0 270)">
<g id="1" style="font-size: 0.7em;">
<image height="32" width="32" x="49" xlink:href="../../images/JOB.GIF" y="-270"/>
</g>
</g>
</svg>
</div>
Flexbox browser support: caniuse flexbox
Learn about Flexbox: CSS Tricks Guide to Flexbox
Learn by playing: Flexbox Froggy
I've finally used some JS code to do so.
I was using the solution from here : Best way to center a <div> on a page vertically and horizontally?
Which is :
div {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
But the problem is that if the SVG is bigger than the window size, it gets cropped.
Here is the JS code i've used in onLoad :
var heightDiff = window.innerHeight - svg.height.baseVal.value;
var widthDiff = window.innerWidth - svg.width.baseVal.value;
if (heightDiff > 0)
svg.style.marginTop = svg.style.marginBottom = heightDiff / 2;
if (widthDiff > 0)
svg.style.marginLeft = svg.style.marginRight = widthDiff / 2;
We have this htmls in our page:
<div id="img"></div>
<div id="mouse_target">
<img style="-moz-user-select: none; border: medium none; width: 27px; height: 35px;" usemap="#imgmap1" src="http://i.stack.imgur.com/S9eo1.png">
<map name="imgmap1"><area href="javascript:void(0)" style="cursor: pointer;" title="" shape="poly" coords="11,25,22,11,11,1,1,11,11,25,11,33"></map>
</div>
And the css:
#img,#mouse_target{
width:27px;
height:35px;
position:absolute;
left:40px;
top:100px;
}
#img{
background:url("http://i.stack.imgur.com/S9eo1.png") no-repeat;
-moz-transform:rotate(45deg);
}
#mouse_target{
opacity:0.01;
}
#mouse_target map{
-moz-transform:rotate(45deg);
}
#mouse_target map area{
-moz-transform:rotate(45deg);
}
JsFiddle
Now,we have two problems:
implement the rotate across browser
Since the -moz-transform does not work on ie.
make the div#mouse_target or div#mouse_target map or
div#mouse_target map area rotate with the div#img.
Is this possible?