Convert LESS to CSS and use it with Jekyll - css

In a previous post (How do I reset all css styles for a certain div? (Jekyll blog)) I did ask about a timeline that losses its style when I use it with my Jekyll site.
I did try to us an iframe but that is not a good solution for mobile.
My timeline is based on this project: https://github.com/ybogdanov/history-timeline. That timeline uses LESS to provide styles.
The problem is that Jekyll uses SASS instead of CSS.
This is my modified less style that works perfect with an iframe:
#content {
flex: 1;
overflow: scroll;
position: relative;
}
#ruler {
top: 0px;
height: 30px;
padding-top: 5px;
position: absolute;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
transition: top 0.1s linear;
}
#chart {
margin-top: 35px;
}
svg {
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 18px;
}
}
I used a LESS to CSS converter and I get this:
#content {
flex: 1;
overflow: scroll;
position: relative;
}
#ruler {
top: 0px;
height: 30px;
padding-top: 5px;
position: absolute;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
transition: top 0.1s linear;
}
#chart {
margin-top: 35px;
}
svg .axis path,
svg .axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
svg .axis text {
font-family: sans-serif;
font-size: 18px;
}
But some lines give me a warning about "unknown property" and the styles are missing when I insert the timeline using a div.
What can I do? I only wonder about having a readable text.
Timeline with iframe:
Timeline with div:

The original file only use LESS for some indentation and should work with Sass, just rename the file and put it in the _sass folder, so that Jekyll can build it.
mv styles.less timeline.scss && mv timeline.scss _sass
Create a css/main.scss file with:
---
---
#import "timeline";
In your layout or your include file, you should link to the the generated main.css file:
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">

Related

Background-color on checkbox doesn't set the color

I have an <input type="checkbox" />
I've managed to set things like the border color, but I seem not to be able to set the background-color. It just stays white.
Can anybody offer a solution, I've been looking on this site and others for an answer, but none that I've found work. This is an internal app that will be using the Edge Browser.
It might be overriden by your browser's default settings. Have you tried adding !important to the background-color option?
If that doesn't help, appearance: none; might help, but it removes completely default styles for your input, so you will have to style all the stuff like :checked mark etc.
E: If you just want to change the background color after checking the input, you can use accent-color (https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color)
i am not sure this will work or not but you can give a class name to input and try using :before and :after sudo selectors like
" .yourclassname:checked:after , .yourclassname:checked:before "
Just changing CSS won't work
Trying to set the background on input="checkbox" won't work when just given "background:some_color" because it has default values which will always override.
So we should use a label tag and a div tag to wrap the input tag, wherein input checkbox itself is hidden.
HTML
<label class="contain">
<input type="checkbox"/>
<div class="fake-input"/>
</label>
CSS
.contain *, .contain *::before, .contain *::after {
box-sizing: content-box !important;
}
.contain input {
position: absolute;
z-index: -1;
opacity: 0;
}
.contain {
display: table;
position: relative;
padding-left: 1.8rem;
cursor: pointer;
margin-bottom: .5rem;
}
.contain input[type="checkbox"] ~ .fake-input {
position: absolute;
top: 0;
left: 0;
height: 1.25rem;
width: 1.25rem;
background: rgba(0, 245, 248, 1);
transition: background 250ms;
border: 1px solid rgba(184, 194, 204, 1);
border-radius: 0.125rem;
}
.contain input[type="checkbox"] ~ .fake-input::after {
content: '';
position: absolute;
display: none;
left: .45rem;
top: .18rem;
width: .25rem;
height: .6rem;
border: solid rgba(255, 255, 255, 1);
border-width: 0 2px 2px 0;
transition: background 250ms;
transform: rotate(45deg);
}
.contain input:checked ~ .fake-input::after {
display: block;
}
.contain:hover input ~ .fake-input,
.contain input:focus ~ .fake-input {
background: rgb(10, 38, 43);
}
.contain input:focus ~ .fake-input {
box-shadow: 0 0 0 2px rgba(52,144,220,0.5);
}
.b-contain input:checked ~ .b-input {
background: rgba(0, 130, 243, 1);
border-color: rgba(0, 130, 243, 1);
}
If still are unsure about this, visit Bun.js. My answer is referred from there.

How does one create spacing between lines of CSS code in Visual Studio Code

I'm relatively new to VS Code and this site. The code below was done using scss. I cant figure out why vs code does this. Can anyone tell me which setting is controlling this behavior?
I would like to be able to add space between lines of code like I've seen others do in videos. for example
I see this.
.feature-box {
background-color: rgba($color-white, .8);
font-size: 1.5rem;
padding: 2.5rem;
text-align: center;
border-radius: 3px;
box-shadow: 0 1.5rem 4rem rgba($color-black, .15);
transition: transform .2s;
&__icon {
font-size: 6rem;
margin-bottom: .5rem;
display: inline-block;
background-image: linear-gradient( to right, $primary-color-light, $primary-color-dark);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
}
&:hover {
transform: translateY(-1.5rem) scale(1.02);
}
}
But would like to see this.
.feature-box {
background-color: rgba($color-white, .8);
font-size: 1.5rem;
padding: 2.5rem;
text-align: center;
border-radius: 3px;
box-shadow: 0 1.5rem 4rem rgba($color-black, .15);
transition: transform .2s;
&__icon {
font-size: 6rem;
margin-bottom: .5rem;
display: inline-block;
background-image: linear-gradient( to right, $primary-color-light, $primary-color-dark);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
}
&:hover {
transform: translateY(-1.5rem) scale(1.02);
}
}
Any help would greatly appreciated
thanks
Ok. So according to the documentation of the JS-CSS-HTML formatter
You need to access configuration of that plugin by pressing F1 then choosing Formatter config.
Next you need to customize the config file in the css section.
"css": {
"selectorSeparatorNewLine": true,
"newline_between_rules": true
}
I would also recommend not to use this plugin and use
Prettier which is still maintained in contrast to JS-CSS-HTML formatter which looks like it was abandoned 3 years ago

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>

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.

Input text tooltip doesn't show up

I'm going to add the tooltip for the input text in the page, this page has their own css!
my code is work on local machine but when i pasted code on that page it doesn't work, it seems there is a conflict on the page, but i've ran out of finding the issue.
the js is :
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<script>
// execute your scripts when the DOM is ready. this is a good habit
$(function() {
// select all desired input fields and attach tooltips to them
$("#myform :input").tooltip({
// place tooltip on the right edge
position: "center right",
// a little tweaking of the position
offset: [-2, 10],
// use the built-in fadeIn/fadeOut effect
effect: "fade",
});
});
</script>
the css is :
#myform {
}
.tooltip{
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
background-color: #fff;
border: 1px solid;
position: absolute;
border-color: #bbb #bbb #a8a8a8;
padding: 16px;
width: 255px;
line-height: 17px;
opacity: 0;
left: 16px;
top: 48px;
-webkit-transition: all 0.218s;
-moz-transition: all 0.218s;
-o-transition: all 0.218s;
transition: all 0.218s;
}
and the code is :
<form id="myform" action="#">
<!-- username -->
<label for="username">Username</label>
<input id="username" title="Must be at least 8 characters."/>
</form>
and below is the current input css of the page:
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
color: #000;
font-size: 1.4rem;
font-size: 14px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"] {
padding: 8px 10px 8px 46px;
width: 83%;
}
You can overwrite style by adding your own .tooltip style and overwriting each style using !important . do it for each style in .tooltip. hope this help. here is a simple JSFiddle example.
.tooltip{
background-color:red !important;
}

Resources