Is it possible to make a css3 counter increment itself without displaying the number?
I use steps and when a step is done I want to display another thing in the ::before content (like a font-awesome icon). It works but if I don't write content: counter(step); then the number is not incremented and all my steps after have a wrong number.
I tried a few things but I'm out of idea here. Do you know how to increment correctly the counter without displaying the number itself?`
li {
list-style-type: none;
color: $gray-dark;
font-size: 12px;
width: 33.33%;
float: left;
position: relative;
line-height: 1;
&:after {
content: '';
width: 100%;
height: 2px;
background: $gray-darker;
position: absolute;
left: -50%;
top: 12px;
z-index: 99; /*put it behind the numbers*/
}
&:before {
#include border-radius(15px);
content: counter(step);
counter-increment: step;
width: 28px;
height: 28px;
line-height: 20px;
display: block;
font-size: 12px;
color: $white;
font-weight: bold;
background: $gray-dark;
margin: 0 auto 5px auto;
position: relative;
z-index: 100 !important;
padding-top: 3px;
border:1px solid $gray-darker;
}
&:first-child:after {
// connector not needed before the first step
content: none;
}
&.question {
&:before {
content: '?';
background: $blue-lighter;
}
}
/**
* Specific classes for <li> element.
*/
&.active {
color: $gray-darker;
&:before {
background-color: $orange;
}
}
&.success {
#extend .fa;
color: $gray-darker;
&:before {
background-color: $green-check;// I can't set a content: '\f00c' to get a fa icon.
}
}
}
You can try content: counter(step, none);. Live demo here.
Related
I am working on a new font icon library, and trying to get a desired result that looks like below using only CSS. I can get the single color backgrounds working with css without any issues, but trying to find the best way to do the angled second background layer in a way that will keep ratio based on the font-size used.
Here is my current wip css.
.aw-#{$app_name}:before {
content: $app_code;
}
.aw-#{$app_name}-app:before {
content: $app_code;
position: relative;
border-top-left-radius: 1.25rem;
border-top-right-radius: 1.25rem;
border-bottom-right-radius: 1.25rem;
position: relative;
}
.bg-app-black {
position: relative !important;
}
.bg-app-black:before {
position: absolute;
content: "";
display:block;
width: 5rem;
height: 5rem;
border-radius: 1.25rem;
background-color: #222;
display:inline-block;
background: -0.1rem -0.1rem 0 1.5rem #000;
transform: rotate(-20deg);
}
Here is the html:
<div class="bg-app-black"><i class="aw-actions-app bg-development-app"></i></div>
Here is the results I am getting, and it doesn't scale as the font size changes.
To do it, you need to know that em unit is equal to the computed value of the font-size property of the element on which it is used. And, by default, descendants inherit font-size.
b {
position: relative;
display:inline-block;
font-size: 3rem;
}
b:before {
content: 'N';
position: relative; z-index:1;
display: inline-flex;
font-size: .8em;
width: 1.25em;
height: 1.25em;
border-radius: .3125em .3125em .3125em 0;
margin: .33em 0 0 .33em;
color: #fff;
background: #db2828;
justify-content: center;
align-items: center;
}
b:after {
content: "";
position: absolute;
bottom: 0;
right: 0;
width: 1em;
height: 1em;
border-radius: .25em;
background: #222;
transform: rotateZ(-20deg);
transform-origin: 0 100%;
}
<b></b>
<b style="font-size:5em"></b>
<b style="font-size:24px"></b>
I have a content management system supplying one of our applications with HTML.
I have been asked to change all "ul"s to use a <mat-icon>check_circle_outline</mat-icon> instead of the default "."
The problem is; I can't modify the content so I have to do it through css.
is there a way to add the icon to the css directly instead of using <mat-icon>check_circle_outline</mat-icon> ?
For example, with font-awesome you could do something like
.list-style-checked {
margin-left: 2.5em;
padding: 0;
li {
position: relative;
span {
font-family: "Font Awesome 5 Free";
position: absolute;
left: -2em;
text-align: center;
width: 2em;
line-height: inherit;
&:before {
content: "\f14a";
}
}
}
}
is there a similar way to do it with angular material?
Turns out it's not that different:
.list-style-checked {
#include bodyLight;
color: black;
margin-left: 36px;
margin-bottom: 0;
padding: 0;
list-style: none;
p {
margin-bottom: 0;
}
li {
position: relative;
text-align: left;
span {
font-family: 'Material Icons';
font-size: 24px;
position: absolute;
width: 24px;
height: 24px;
left: -30px;
text-align: center;
line-height: inherit;
&:before {
display: block;
margin-top: -4px;
content: 'check_circle_outline';
}
}
}
}
&.list-style-strikethrough p {
text-decoration: line-through;
}
I'm writing a document in Typora and I need a paragraph break whitch is a line with text in the middle. The whole document should be exportable to pdf.
result
I currently tried this, but it doesn't work when exporting to pdf:
h3 {
color: #015573;
text-align: center;
font-size: 0.8em;
position: relative;
margin:0;
text-transform: uppercase;
}
h3 span {
background-color: white;
padding: 0 0.3em;
}
h3:before{
content:"";
display: block;
position: absolute;
z-index:-1;
top: 50%;
width: 100%;
border-bottom: 2px solid #015573;
}
Try using below code. It's working fine. You can export to pdf with no problems. I did not use the background-color: white; property because the background color is white by default of any exported pdf. BTW, if you are using a dark theme for Typora, you can specify that property. It won't affect the exported style in the pdf file.
h3 {
color: #015573;
text-align: center;
font-size: 0.8em;
text-transform: uppercase;
overflow: hidden;
}
h3:before,
h3:after {
content: "";
display: inline-block;
height: 2px;
position: relative;
vertical-align: middle;
width: 50%;
background-color: #015573;
}
h3:before {
right: 0.5em;
margin-left: -50%;
}
h3:after {
left: 0.5em;
margin-right: -50%;
}
<h3>Heading</h3>
This is how exported pdf looks like:
.fancy {
line-height: 0.5;
text-align: center;
}
.fancy span {
display: inline-block;
position: relative;
}
.fancy span:before {
right: 100%;
margin-right: 15px;
}
.fancy span:before,
.fancy span:after {
content: "";
position: absolute;
height: 5px;
border-bottom: 1px solid black;
top: 0;
width: 600px;
}
.fancy span:after {
left: 100%;
margin-left: 15px;
}
<p class="fancy"><span>A fancy subtitle</span></p>
I'm requesting your help with a .css hr class
I'm trying to figure out how to make a double border like this:
Here's what i did:
hr.style15 {
border-top: 4px double black;
}
hr.style15:after {
content: 'SHIPPING INFO';
display: inline-block;
position: relative;
top: -15px;
left: 40px;
padding: 0 10px;
background: #f0f0f0;
color: #8c8b8b;
font-size: 18px;
}
My questions are:
1) How do I get rid of the inline-block below the 2 lines? I've tried by deleting the inline-block sentence but it doesn't work.
2) Can I add font-family and font size to this?
3) Is it possible to increase the space between the 2 lines without increasing the width?
Basically I believe I'd do it differently. Using both :after and :before for the lines will help you drastically on putting a text on top of it.
So I prepared this CodePen for you. Basically what I did was using an :after and a :before (as I told you before) for the border-lines and after that I added a span with a background-color (in this case white) on top of the border-lines (look at the z-index).
.container {
width: 800px;
position: relative;
}
.double-bar {
&:after {
content: "";
border-bottom: 1px solid black;
width: 100%;
position: absolute;
top: 9px;
left: 0;
z-index: 1;
}
&:before {
content: "";
border-bottom: 1px solid black;
width: 100%;
position: absolute;
top: 13px;
left: 0;
z-index: 1;
}
span {
z-index: 2;
position: relative;
background-color: white;
left: 40px;
padding: 0 7.5px;
text-transform: uppercase;
font-weight: 600;
font-size: 20px;
}
}
You can see a demo of this.
I hope this helps!
Please have a check with this:-
HTML
<h1 class="title"><span>Shipping info</span></h1>
CSS
h1.title {
margin-top: 0;
position: relative;
}
h1.title:before {
content: "";
display: block;
border-top: solid 1px black;
width: 100%;
height: 2px;
position: absolute;
top: 50%;
z-index: 1;
border-bottom: 1px solid #000;
}
h1.title span {
background: #fff;
padding: 0 20px;
position: relative;
z-index: 5;
margin-left: 50px;
}
I've been struggling with getting my hamburger menu to slowly open. It took me a long time to even create it. :) Can anyone tell me if this CSS code allows for having it gradually open?
http://codepen.io/kiddigit/pen/EKRgQz
#media only screen and (max-width: 700px) {
body {
background-color: #white;
}
img {max-width: 100%; padding-bottom: 10px;
}
h1 {
font-size: 30px;
}
.wrapper {
border: 0px;
padding: 1px;
background-color: white;
}
.content {
background-color: white;
border: none;
margin-left: 100px;
margin-right: 100px;
}
.menu-btn div{
float: left;
padding-right: 0px;
margin-top: 0em;
line-height: 1.2;
font-size: 18px;
font-weight: 200;
vertical-align: middle;
z-index: 99;
}
.menu-btn span {
display: block;
width: 25px;
height: 4px;
margin-bottom: 5px;
background: rgb(0,0,0);
z-index: 99;
}
.menu-btn span:last-of-type {
margin-bottom: 0;
}
.responsive-menu{
display: none;
overflow: hidden;
}
.responsive-menu ul {
width: 80px;
float: left;
margin-right: 0;
margin: 0;
}
.main-nav {
border: none;
}
a {
font-size: 10px;
color: white;
}
.responsive-menu li {
padding-left: 5px;
font-size: 10px;
line-height: 25px;
list-style-type: none;
background-color: black;
}
.expand {
display: block !important;
}
$( '.menu-btn' ).click(function(){
$('.responsive-menu').slideToggle('slow');
});
UPD: Smooth appearing of element when it changes display from none to block can't be achieved with CSS. JQuery has some functions for that, toggle() and slideToggle(). slideToggle looks better for dropdown as it changes height of element from 0 to its natural height. In brackets you can add animation speed, slow is equal to 600 milliseconds, time in milliseconds also can be used: $('.responsive-menu').slideToggle(500)