CSS white bite and oval form in spinner - css

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>

Related

How to make the padding in scrollbar? CSS

I've tried everything, searched the whole stack overflow and google.
Can someone help me to make this particular type of scrollbar?
When I use the border-right/top/bottom to make the spaces around it, it breaks the border-radius and gets ugly. As a reference, it's the same scrollbar used in Googledocs, a slim, rounded and doesn't touch the margins of the page: https://docs.new/
Here's the image: rounded, slim and not touching
So far I got:
::-webkit-scrollbar {
background: #262338;
width: 6px;
}
::-webkit-scrollbar-thumb {
padding: 0 4px;
background: #6E7191;
border-radius: 6px;
height: 48px;
}
::-webkit-scrollbar {
width: 10px;
height: 10px;
border-radius: 34px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 8px;
transition: all 0.4s;
-moz-transition: all 0.4s;
-webkit-transition: all 0.4s;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
border-radius: 16px;
}
This would get you the main design of the scrollbar you are looking. This is what I used on my website. Hope this is the design you want!
Scrollbar Padding
I think you'll have to use a container to accomplish the not touching part of your requirements.
Chrome vs Firefox
Be aware that the support to adjust the scrollbar is very limited in firefox compared to chrome browsers. The result of it will not show up in this snippet, nor on websites like jsfiddle. Rounded corners are impossible to achieve in firefox without using your own implementation or a third party library like thisone for example.
Example
body {
background-color: #14142B;
}
/* FIREFOX */
html {
scrollbar-width: thin;
scrollbar-color: #6E7191 #262338;
}
/* CHROME */
::-webkit-scrollbar {
width: 12px;
border-radius: 34px;
}
::-webkit-scrollbar-track {
background: #262338;
border-radius: 8px;
}
::-webkit-scrollbar-thumb {
background: #6E7191;
border-radius: 8px;
transition: all 0.4s;
-moz-transition: all 0.4s;
-webkit-transition: all 0.4s;
}
::-webkit-scrollbar-thumb:hover {
background: #7E81A1;
}
.container {
margin: 1.5rem .5rem;
overflow-y: scroll;
max-height: calc(100vh - 3rem);
}
.content {
height: 25rem;
}
hr {
border: 0;
border-top: 2px solid #201F36;
}
.filler {
height: 3rem;
}
<div class="container">
<div class="content">
<div class="filler"></div>
<hr>
<div class="filler"></div>
<hr>
<div class="filler"></div>
<hr>
<div class="filler"></div>
</div>
</div>

Why do I get two types of hover effects in my navbar?

Why do I get two types of animation effects when I hover over my navbar items? First it shows rectangular background then it becomes circular (which I want)
<div class="container">
<div class="items" id="item-1">Home </div>
.items {
padding-inline:20px ;
padding-block: 10px;
font-size: larger;
margin-inline: 35px;
}
a {
color: black;
text-decoration:none ;
}
#item-1:hover {
background-color: rgb(3, 151, 3);
color: white;
border-radius: 20px;
transition: 0.15s;
cursor:pointer ;
}
It's because #item-1 by default doesn't have border-radius, so when you hover it, it starts to apply border-radius and since you have set transition: 0.15s;, so this transition will apply to change all styles. to solve it you can set border-radius for #item-1 by default and with hover effect just changing it's background like this:
.items {
padding-inline: 20px;
padding-block: 10px;
font-size: larger;
margin-inline: 35px;
}
a {
color: black;
text-decoration: none;
}
#item-1 {
border-radius: 20px;
transition: 0.15s;
}
#item-1:hover {
background-color: rgb(3, 151, 3);
color: white;
cursor: pointer;
}
<div class="container">
<a href="https://www.google.com/">
<div class="items" id="item-1">Home </div>
</a>

Opacity on body not affecting background color on body

I am trying to set an opacity on the body. However, I have run into an issue.
When setting the opacity on the body, only its content will be affected. The background is not affected by the opacity.
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller then 1</p>
<button>Toggle opacity</button>
When doing the same on a div it works fine.
$("button").click(function() {
$("div").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
font-family: 'Arial';
margin: 0;
text-align: center;
}
div {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
opacity: 1;
}
div.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<p>The background gradient disapears when I set the opacity smaller than 1</p>
<button>Toggle opacity</button>
</div>
But I can't do this with a div. I have to set it on the body. How can I make the opacity affect the body's background?
P.S. Happy new year!
This is because the background of body is propagated to the html element (since this one doesn't have a background set) thus the html is also having the same background of the body. In your case, the opacity works fine with background also but you simply see the one of the html element.
Add a background to html to see the difference:
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
html {
background:red;
}
body {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller then 1</p>
<button>Toggle opacity</button>
Some usefull links to understand this behavior:
https://www.w3.org/TR/css-backgrounds-3/#special-backgrounds
https://css-tricks.com/just-one-of-those-weird-things-about-css-background-on-body/
https://stackoverflow.com/a/47998865/8620333
What's the meaning of "propagated to the viewport" in the CSS spec?
Use rgba() for your linear gradient colors. That way you can set the transparency of the colors. By default have the alpha transparency value set to 1 (a.k.a. 100% opacity = no transparency). Then change the value to something less than 1 so the background becomes semi-transparent.
Note: This solution will only affect the background and not child elements. Of which, may or may not be the intended result.
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
background: linear-gradient(to right, rgba(27, 188, 177, 1), rgba(55, 185, 233, 1));
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
background: linear-gradient(to right, rgba(27, 188, 177, 0.3), rgba(55, 185, 233, 0.3));
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller than 1</p>
<button>Toggle opacity</button>
As far as I know, the opacity property of the body does not exist. So you can obtain the desired effect with something like this:
https://codepen.io/calexandru/pen/YYQLmW
$( function () {
$("#target").on("click", function() {
$('body').addClass('opacity-container');
});
} );
.opacity-container::after {
/*CSS*/
content: "";
background: url(https://firebasestorage.googleapis.com/v0/b/betaproject-8a669.appspot.com/o/Quote-Generator%2F1.jpg?alt=media&token=4de18117-665f-4166-9111-4401af0cd555);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>Click the button for background with opacity</p>
<button id="target">Click me</button>

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

OS X Yosemite menu background blur in 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.

Resources