OS X Yosemite menu background blur in CSS - css

I'm looking for a way to get the blurry background effect of OS X 10.10 working in css. Blurring with filter:blur or an SVG Gaussian filter will also blur the border, so this will not work.
Here is an example of the effect:

this is CSS imitating OSX Yosemite
Stylesheet
body {
background-image: url('your image');
background-size: cover;
font-size: 14px;
}
.block {
color: #000;
border: 1px solid rgba(0,0,0,0.1);
border-radius: 6px;
overflow: hidden;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
background: inherit;
position: relative;
}
.block:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: inherit;
-webkit-filter: blur(10px) saturate(2);
}
.title {
font-size: 1.4em;
font-weight: 300;
color: #222;
padding: 8px;
background: rgba(235,235,235,0.85);
border-bottom: 1px solid rgba(0,0,0,0.1);
text-align: center;
}
.content {
padding: 8px;
background: rgba(255,255,255,0.66);
}
and your html like following
<div class="block">
<div class="title">Hello World</div>
<div class="content">This is your main content!</div>
</div>
Example

You can use Css3 and JS, as explained in this article. Below you can find a snippet of Css code, for the full working example, please refer to the original post and fiddle below:
/* TRANSFORMATIONS */
.glass.down {
/* Fallback for browsers that don't support 3D Transforms */
transform: translateY(100%) translateY(-7rem);
transform: translateY(100%) translateY(-7rem) translateZ(0);
}
.glass.down::before {
transform: translateY(-100%) translateY(7rem);
transform: translateY(-100%) translateY(7rem) translateZ(0);
}
.glass.up, .glass.up::before {
transform: translateY(0);
transform: translateY(0) translateZ(0);
}
See this demo:
http://jsfiddle.net/cQQ9u/

You can achieve this effect with webkit's backdrop-filter css property
https://webkit.org/demos/backdrop-filter/

These are just workarounds... it works only with image background and it won't with text (for example if we want to create modals windows).... you can combine css and js to get some similar effect but for now we can't get the right behavior with pure CSS.
This is my idea and hope some CSS guru can contradict me but I think this is a CSS3 technology limit..... maybe in future we'll can do it.

Related

CSS white bite and oval form in spinner

I'm playing making my own UI library, I'm working on an Input component who is able to add components (like an icon or spinner) to the sides and I have this strange spinner bug. There are two problems that are explained in the code.
If I uncheck & check the width attr from dev tools, the "white bite" fixes.
PD: The example is written in a react project because I want to add behaviour later, but now it's just a simple css problem.
EDIT: This is the image of the oval when you remove the "dummy-wrapper" div.
.container {
display: flex;
border: 1px solid rgba(34, 36, 38, 0.15);
border-radius: 10px;
border-color: teal;
padding: 0.4em 0.5em;
background: white;
justify-content: center;
align-items: center;
width: 50%;
}
input {
width: 100%;
border: none;
background: inherit;
color: inherit;
outline: 0;
padding: 0em 0.4em;
font-size: 14px;
font-family: Poppins;
color: black;
/* TODO: make themeable */
font-weight: 400;
letter-spacing: 0.14px;
}
.spinner {
width: 15px;
height: 15px;
border-radius: 50%;
border: 0.2rem solid rgba(151, 159, 208, 0.3);
border-top-color: inherit;
animation: 1s spin infinite linear;
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="container">
<label>X</label>
<input
placeholder="this is a placeholder......"
value="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s"
/>
<!--{/* Problem 1: Without the dummy-wrapper the circle becomes an oval. */}
{/* Problem 2: The circle has a small white bite. */}-->
<div class="dummy-wrapper">
<div class="spinner" />
</div>
</div>
Try using a fixed px border width, I guess it might be the border width 0.2rem => 3.1875px chrome view resolution problem.
border: 3px solid rgba(151, 159, 208, 0.3);
I don't see any problem there ... ?
.spinner {
--spinSz : 32px; /* spinner size */
box-sizing : border-box;
display : inline-block;
flex-shrink : 0;
width : var(--spinSz);
height : var(--spinSz);
border-radius : 50%;
border : calc(var(--spinSz)/10) solid #1a31c54d;
border-top-color: #830b2f;
animation : 1s spin infinite linear;
}
#keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
<b class="spinner"></b>

Changing Only Background Opacity Using "Opacity", not "RGBA"

I have two boxes that when you hover over, the background opacity should change, but the foreground text opacity should not change. I know the solution to this is on hover, set the rgba to the background color and add the opacity. Example:
#join:hover {
rgba(0, 102, 255, .4)
}
However, the thing is that in jquery the background of each of the boxes change when clicked on, so using a solid and specific color is not an option. I'd like to use just opacity: .4 so that the opacity is the same regardless of the background color of each box.
When I use opacity on hover, the opacity of the text in each box changes as well. To get around this, I tried using z-index/position: relative and setting the text (#join-text, #learn-text) to a higher z-index and the background (#join, #learn) to a lesser z-index. This did not render the correct results.
I also tried using pseudo class ::before like #join:hover::before but that also did not render the correct results, the position:absolute changed the position of the buttons.
Is there any way to change the opacity on hover ONLY for the background, using the opacity: .4 property? Any input would be greatly appreciated.
Find code here: https://jsfiddle.net/Lsqjwu15/1/
You can use CSS3 :before selector
#join:before {
background: #0066ff;
}
#learn:before {
background: #ffb31a;
}
.rectangle:before {
content: "";
width: inherit;
height: inherit;
position: absolute;
}
.rectangle:hover:before {
opacity: .4;
}
JSFiddle
You could make a workaround with pseudo elements (changed the "join" box):
.rectangle {
position:relative;
height: 200px;
width: 80px;
border: 1px solid transparent;
}
#join:before {
content:"";
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
background: #0066ff;
}
#learn {
background: #ffb31a;
}
#join:hover:before,
#learn:hover {
opacity: .4;
}
.vertical {
text-align: center;
color: #000000;
font-size: 30px;
font-weight: bold;
white-space: nowrap;
transform: rotate(-90deg);
}
#join-text {
margin-top: 110px;
}
#learn-text {
margin-top: 125px;
}
<div class="rectangle" id="join">
<div class="vertical" id="join-text">
Join Here
</div>
</div>
<div class="rectangle" id="learn">
<div class="vertical" id="learn-text">
Learn More
</div>
</div>
Could you make the text "rgba(0,0,0,1) !important" to override the background opacity? would that still fade with the background?
However, the thing is that in jquery the background of each of the boxes change when clicked on, so using a solid and specific color is not an option.
You haven't specified HOW the background colors are changed or what they are initially but using RGBA Colors throughout seems simple enough. JQ is perfectly capable of handing RGBA.
.rectangle {
height: 200px;
width: 80px;
border: 1px solid transparent;
}
#join {
background: rgba(0, 102, 255, 1)
}
#learn {
background: rgba(255, 179, 26, 1)
}
#join:hover {
background: rgba(0, 102, 255, .4)
}
#learn:hover {
background: rgba(255, 179, 26, .4)
}
.vertical {
text-align: center;
color: #000000;
font-size: 30px;
font-weight: bold;
white-space: nowrap;
transform: rotate(-90deg);
}
#join-text {
margin-top: 110px;
}
#learn-text {
margin-top: 125px;
}
<div class="rectangle" id="join">
<div class="vertical" id="join-text">
Join Here
</div>
</div>
<div class="rectangle" id="learn">
<div class="vertical" id="learn-text">
Learn More
</div>
</div>
If there is something else you haven't told us then if you want a solution to your code, you're going to have to reproduce the exact issue including the JS/JQ

Tooltip CSS ONLY: focus and hover prevents access to following button

http://codepen.io/anon/pen/wBaGgW
I currently have what a list of items and then a button next to them on the right:
The tooltip must appear on focus and the tooltip must appear on hover - this works but the problem is that when an item is focused (after clicking on it) - the following item cannot be accessed via mouse (because preceeding is item focused!):
The tooltip must disappear when the mouse over the tooltip itself, but the focus is forcing it stay.
The test-case is here: http://codepen.io/anon/pen/wBaGgW
can anyone offer a solution that does not have any javascript? Also, the html markup cannot be changed too much. Minimal changes to HTML are OK. Just trying to prevent too much as I'll most likely need to compensate other parts of the application to fit the html changes.
Here shows the tooltip:
button:hover>.tooltip,
button:focus>.tooltip,
button:active>.tooltip {
visibility: visible;
opacity: 1;
}
I can hide the tooltip doing the following:
button:focus>.tooltip:hover {
visibility: hidden;
opacity: 0;
}
But that causes a crazy flickering effect as the mouse moves within the area in which the tooltip would appear.
Keep in mind the restrictions:
No JavaScript
Compatibility with IE8+ (please note, the tooltip css is coming from our global module, and I dont have direct access to change it, I am working on a separate module that I can of course override because my css loads after the global css does)
Tooltip must appear below (unfortunately)
With those restrictions, I don't know of any way to resolve your issue perfectly.
As a workaround, you can change the tooltip to be a sibling of the button, instead of a child and use the CSS adjacent sibling selector. This makes it so that when a user clicks the tooltip, it loses focus from the button and the tooltip is hidden. This will require you to fix the position of the tooltip a little (I used margin-top as a quick fix).
Code
button:hover + .tooltip,
button:focus + .tooltip,
button:active + .tooltip {
visibility: visible;
opacity: 1;
margin-top:20px;
}
<ul>
<li><span>Lorem Ipsum Dlar Set</span>
<button>X
</button>
<span class="tooltip">Hello ToolTip
</span>
</li>
...
</ul>
Live example: http://codepen.io/anon/pen/azONYP
Based my answer on this: Answer
html
<button tooltip="Tooltip text">Test</buttoN>
css
[tooltip]:before {
position : absolute;
content : attr(tooltip);
pacity : 0;
}
[tooltip]:hover:before {
opacity : 1;
margin-top:10px;
}
Here is the Fiddle
Update
Fiddle now with focus.
Added pointer event: none;
IE8 YEP YEP
No Javascript YEP
Must be below YEP
when mouse leave the tooltip, it's needs to be removed completely? (like removing the ":focus")...beacuse if it's allow for the tooltip to be visible again after mouse leave so you can use:
button:focus>.tooltip:hover
{
background: none;
border: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
text-indent: -9999px;
}
codepen: http://codepen.io/anon/pen/OPVNaW
Use <a> instead of buttons and style them as buttons.
/* `border-box`... ALL THE THINGS! */
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 64px auto;
text-align: center;
font-size: 100%;
max-width: 640px;
width: 94%;
}
a:hover {
text-decoration: none;
}
header,
.demo,
.demo p {
margin: 4em 0;
text-align: center;
}
/**
* Tooltip Styles
*/
/* Add this attribute to the element that needs a tooltip */
[data-tooltip] {
position: relative;
z-index: 2;
cursor: pointer;
}
/* Hide the tooltip content by default */
[data-tooltip]:before,
[data-tooltip]:after {
visibility: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
pointer-events: none;
}
/* Position tooltip above the element */
[data-tooltip]:before {
position: absolute;
top: 150%;
left: 50%;
margin-top: 5px;
margin-left: -80px;
padding: 7px;
width: 160px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background-color: #000;
background-color: hsla(0, 0%, 20%, 0.9);
color: #fff;
content: attr(data-tooltip);
text-align: center;
font-size: 14px;
line-height: 1.2;
}
/* Triangle hack to make tooltip look like a speech bubble */
[data-tooltip]:after {
position: absolute;
top: 150%;
left: 50%;
margin-left: -5px;
width: 0;
border-bottom: 5px solid #000;
border-bottom: 5px solid hsla(0, 0%, 20%, 0.9);
border-right: 5px solid transparent;
border-left: 5px solid transparent;
content: " ";
font-size: 0;
line-height: 0;
}
/* Show tooltip content on hover */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
visibility: visible;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
/* Show tooltip content on focus */
[data-tooltip]:focus:before,
[data-tooltip]:focus:after {
visibility: visible;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<h1>CSS Simple Tooltip</h1>
<div class="demo">
<p>I’m a button with a tooltip</p>
</div>
Try refactoring your CSS to something like this:
button:hover>.tooltip,
button:active>.tooltip {
visibility: visible;
opacity: 1;
}
button:focus>.tooltip {
visibility: visible;
opacity: 1;
outline: none;
}

CSS3 - Transparent text through `div`?

I was looking for this.
But when I tried it, it won't work.
The text is transparent, but not through the div, which is the big idea.
Fiddle
.title1_background {
background-color: rgba(255, 255, 255, 0.8);
height: 20%;
width: 100%;
position: fixed;
bottom: 8%;
margin: 0;
left: 0;
text-align: center;
}
.title1_background h1 {
font-size: 400%;
display: block;
-webkit-text-fill-color: transparent;
}
The better way is to use two images.
The background image and the image with hollow text above it.
You can achieve the same using -webkit-text-fill-color: transparent; but this would only work with browsers supporting -webkit.
see this link it works fine in chrome since it supports -webkit but won't work in firefox.
See the browsers and their versions that support -webkit
We should always prefer to design and develop that supports cross browser compatibility.
Try This link
<div id="outer">
<div id="wrapper">
<div id="inner">TEXT</div>
</div>
CSS
#outer {
width:300px;
height:300px;
background-image: url(http://www.placekitten.com/300/300);
overflow:auto;
}
#wrapper {
background: #fff;
margin: 100px 0;
opacity:0.6;
}
#inner {
font: bold 60px Arial;
text-align:center;
margin:20px;
background-color: #fff;
background-image: url(http://www.placekitten.com/300/300);
background-position: 280px 201px;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#outer:hover{
border:solid 2px #4072B4;
}

CSS3 - making parallelogram pieces for vertical nav bar

I'm just been learning some HTML5/CSS3/JS and part of jQuery recently so still a noob to it for the most part but trying to make a navigation bar that's a bunch of parallelogram blocks stacked vertically, so far just messing around this is what I have for each block but this makes them rectanges and I was looking to push the top of each box over to create a parallelogram look:
.nav {
background-color: blue;
border: 1px solid black;
border-radius: 3px;
margin: 2px;
text-align: center;
font-family: Verdana;
font-weight: bold;
font-size: 1em;
color: yellow;
padding: 15px;
cursor: pointer;
}
I saw something about using 'transform: skew(xdeg)' but it didn't seem to affect anything, maybe I wasn't implementing it correctly?
Have you tried:
.nav {
/*all your properties */
transform: skew(30deg);
-o-transform: skew(30deg); /* Opera */
-ms-transform: skew(30deg); /* IE 9 */
-webkit-transform: skew(30deg); /* Safari and Chrome */
}

Resources