css code snippets

CSS CWS
/* Website Loading Screen */
.stop-scrolling { 
  height: 100%; 
  overflow: hidden; 
} 

#header {
  visibility: hidden;
}

.loadingscreen {
  position: absolute;
  background: #fff;
  opacity: 1;
  z-index: 2000;
  width: 100%;
}

.loadingscreen > .loading {
  background: #FFF;  
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;

}

.loading img {
  height: 200px;
  width: 200px;
}

.logo-pulse{
  animation-name: pulse;
  -webkit-animation-name: pulse;	

  animation-duration: 1.5s;	
  -webkit-animation-duration: 1.5s;

  animation-iteration-count: infinite;
  -webkit-animation-iteration-count: infinite;
}

// Enable Smooth Scrolling for anchor links
html {scroll-behavior: smooth;}

// Custom bullet points
ul[data-rte-list] li>*:first-child::before{content: "⟢"!important}

// Custom testimonial section
/* ---- GHOST PLUGINS - BOLDLY TESTIMONIAL SLIDER START ---- */
@boldly-ghost-card-background: #fff; // background color
@boldly-ghost-card-border-style: 1px solid #eee; // border radius
@boldly-ghost-card-border-radius: 10px; // border radius
@boldly-ghost-card-shadow-color: #fff; // subtle shadow color

@boldly-ghost-desc-font-size: 18px; // quote size
@boldly-ghost-desc-mobile-font-size: 1.2em; // mobile quote size
@boldly-ghost-desc-font-color: #000; // quote color

@boldly-ghost-title-font-size: 20px; // name title size
@boldly-ghost-title-mobile-font-size: 1.2em; // mobile name title size
@boldly-ghost-title-font-color: #000; // name title color

@boldly-ghost-position-size: 15px; // tag meta size
@boldly-ghost-position-mobile-font-size: 1em; // mobile tag meta size
@boldly-ghost-position-color: #666; // tag meta color

@boldly-ghost-arrow-size: 2em; // arrow button size
@boldly-ghost-arrow-bg-color: #000; // arrow background
@boldly-ghost-arrow-color: #fff; // arrow icon color

@boldly-ghost-quote-symbol-size: 30px; // quote icon size
@boldly-ghost-quote-symbol-color: #000; // quote icon color

@boldly-ghost-bullet-size: 12px; // bullet slider icon size
@boldly-ghost-bullet-color: #000; // bullet slider icon color

/* ----- DON'T EDIT BELOW THIS LINE - SUPPORT NOT PROVIDED IF EDITING BELOW THIS LINE ----- */
body{.boldly-plugin{.image-slide{border: @boldly-ghost-card-border-style !important; background: @boldly-ghost-card-background;border-radius: @boldly-ghost-card-border-radius;&:after{background-color: @boldly-ghost-card-background;border-radius: @boldly-ghost-card-border-radius;}&:before{box-shadow: 0px 1px 5px 5px @boldly-ghost-card-shadow-color;border-radius: @boldly-ghost-card-border-radius;}}h3{font-size: @boldly-ghost-title-font-size;color: @boldly-ghost-title-font-color !important;@media only screen and (max-width: 640px){font-size: @boldly-ghost-title-mobile-font-size;}}p{font-size: @boldly-ghost-desc-font-size;color: @boldly-ghost-desc-font-color;a{color: @boldly-ghost-desc-font-color;}}svg{width: @boldly-ghost-quote-symbol-size;height: @boldly-ghost-quote-symbol-size;stroke: @boldly-ghost-quote-symbol-color;path{fill: @boldly-ghost-quote-symbol-color;}}.desc-wrapper{p{@media only screen and (max-width: 640px){font-size: @boldly-ghost-desc-mobile-font-size;}}}.author-info{p{line-height: 1.2;font-size: @boldly-ghost-position-size;color: @boldly-ghost-position-color;@media only screen and (max-width: 640px){font-size: @boldly-ghost-position-mobile-font-size;}}.author-position p, p a{color: @boldly-ghost-position-color;}}}.boldly-pagination.swiper-pagination{.swiper-pagination-bullet{width: @boldly-ghost-bullet-size;height: @boldly-ghost-bullet-size;margin: @boldly-ghost-bullet-size/2;background-color: @boldly-ghost-bullet-color;}}.boldly-control-wrapper{height: @boldly-ghost-arrow-size;.boldly-control{.swiper-button-next, .swiper-button-prev{color: @boldly-ghost-arrow-color;left: -@boldly-ghost-arrow-size/2;background-color: @boldly-ghost-arrow-bg-color;&:after{font-size: @boldly-ghost-arrow-size;}}.swiper-button-next{right: -@boldly-ghost-arrow-size/2;}}}
  /* ---- GHOST PLUGINS - BOLDLY TESTIMONIAL SLIDER END ---- */


  // Add solid black line around picture on ABOUT page (Meet Mary Lou Hoover)
  #block-fb64aa8e33ec53d1f8ac{
    border: 2px solid black;
  }

  /******* MOBILE ONLY Code *******/
  @media only screen and (max-width: 640px) {
    // Center the headings
    #block-650a19492b582ebec7dfdcd7 h3
    {
      text-align: center;
    }

    // Change H1 size
    h1 {
      font-size: 2.5rem
    } 

    // Add padding to ABOUT page with the white background behind text
    .fe-block-65370874633f041db8a2d0e3{
      padding: 17px 17px 17px 17px !important;
      // Center text on ABOUT page
      p{
        text-align: center;
      }
    }

    // Center text and buttons om mobile
    [data-section-id="65186fca6ce6416583d3f009"], [data-section-id="650a1949e95695d995395cdc"], [data-section-id="65383a8fb4d3ab00c6b2a5c9"]{
      h1, h2, h3, p{
        text-align: center !important;
      }
      .sqs-block-button-container--left{
        justify-content: center !important;
      }
    }

    // Portfolio page fonts on mobile
    .portfolio-hover[data-variant-hover-cover] .portfolio-hover-item-title{
      font-size: 38px !important;
    }
  }
  
/**
 * Background Image For Mobile Menu
 * From Will-Myers.com
**/
.header-menu-bg {
  --opacity: 0.75;
  --blur: 5px;

  &:after {
    background-image: url(https://static1.squarespace.com/static/6442d193d9f352786c7e8651/t/654433505e58705c235caf2a/1698968401549/natural-light-on-workspace.jpg);

    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-size: cover;
    background-position: 50% 50%;
   // filter: blur(var(--blur, 5px));
    transform: scale(1);
    opacity: var(--opacity, 1);
    transition: transform 0.8s ease;
  }
  .header--menu-open &:before{
    transform: scale(1.1);
  }
}
  /******* TABLET ONLY Code ********/
  @media only screen and (min-width: 767px) and (max-width:950px) {
    // Center text and buttons om tablet
    [data-section-id="650a1949e95695d995395cdc"], [data-section-id="65186fca6ce6416583d3f009"]{
      h1, h2, h3, p{
        text-align: center !important;
      }
      .sqs-block-button-container--left{
        justify-content: center !important;
      }
    }

    .fe-block-65370874633f041db8a2d0e3{
      padding: 17px 17px 17px 17px !important;
    }
  }

  /* DESKTOP ONLY Code
  @media only screen and (min-width: 951px) {code goes here}
  */


  /******* FOOTER Code *******/
  // Remove underlines on footer text links
  Footer p a {
    text-decoration: none !important;
  }

  // Remove the automatic hyphens on headings and paragraphs
  h1, h2, h3, h4, p {
    hyphens: none;
  }
}

// Change lightbox background color
html .c-lightbox[data-type=inline]:not([data-group]) .c-lightbox__overlay {
  background: #FAF7F9;
}

/* Portfolio titles below image on mobile */
@media screen and (max-width:767px) {
  div#gridThumbs {
    grid-template-columns: repeat(1,1fr);
  }

  a.grid-item {
    height: unset !important;
    padding-bottom: 0 !important;
  }

  .portfolio-text {
    position: relative !important;
    opacity: 1 !important;
    padding-top: 15px !important;
  }
}

.process-number{
  width: 100px;
  height: 100px;
  background-color: #45554d;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  border-radius: 100%;
  font-size: 36px;
}
text styling distorted
*{
    margin:0;
    padding:0;
    background:#000;

 }

 body{
    display:flex;
    justify-content:center;
    align-items: center;
    min-height: 100vh;
    background: #000;
    
   
 }
 h2{
    position:relative;
    margin:0;
   font-size: 4em;
    font-weight: 900;
    color:white;
    z-index:1;
    overflow:hidden
 }

 h2:before{
    content:'';
    position:absolute;
    left:0;
    width:120%;
    height:100%;
    background:linear-gradient(90deg, transparent 0%, #000 5%,#000 100%);
    animation:animate 5.5s linear forwards;
    animation-delay: 2.5s;
 }

 h2 span{
    color: #ff022c;
 }
 @keyframes animate{
0%{
    left:110%
}
100%{
    left:-20%
}
 }


 video{
    position: absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    object-fit: cover;
    z-index:2;
    pointer-events: none;
    mix-blend-mode: screen;
 }
css custom properties
:root{

    /* css custom properties */
   --bg-wild-blue-yonder:hsla(216,33%,68%,1);
   --bg-carolina-blue:hsla(199,89%,49%,1);
   --bg-prussian-blue:hsla(216,33%,20%,1);
   --bg-oxford-blue:hsla(222,44%,13%,1);
   --bg-oxford-blue-2:hsla(222,47%,11%,1);

   --text-white:hsla(0,0%,100%,1);
   --text-wild-blue-yonder:hsla(216,33%,68%,1);
   --text-alice-blue:hsla(216,100%,95%,1);
   --text-columbia-blue:hsla(199,69%,84%,1);
   --text-carolina-blue:hsla(199,89%,49%,1);
   --text-shadow-blue:hsla(217,24%,59%,1);
   --text-slate-gray:hsla(217,17%,48%,1);

   --gradient-1:linear-gradient(90deg,#0ea5ea,#0bd1d1 51%);
   --gradient-1:linear-gradient(90deg,#0ea5ea,#0bd1d1 51%,#0ea5ea);
   --gradient-1:linear-gradient(0deg,#000d1a,tranparent);
}
css grids
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <main>
<div class="div1">div1</div>
<div class="div2">div2</div>
<div class="div3">div3</div>
<div class="div4">div4</div>
<div class="div5">div5</div>
<div class="div6">div6</div>
</main>
</body>
</html>

main{
width:90%;
margin:50px auto;
border: 1px solid black;
color: white;
display: grid;
/* ie 2 rows with 100 px and 150 px height */
/* grid-template-rows: 150px 150px; */
grid-template-rows: repeat(3,150px);

/* ie 3 columns with 150 px width and 3*2 is 6 */
/* 1 fr is the unit that can be used which automatically adjusts the width  */

/* grid-template-columns: 1fr 1fr 1fr; */
/* grid-template-columns:repeat(3,1fr); */

/* sets the column width to the length of the longest word */
/* grid-template-columns: min-content repeat(3,1fr); */

/* grid-template-columns: max-content repeat(3,1fr); */
/* occupies the entire width which is as long as the text */


/* grid-template-columns:minmax(150px,450px) repeat(3,1fr); */
/* it will set minimum width of 150px no matter what device it is. while max is what is shown on website */



/* @@extremely important */
grid-template-columns: repeat(auto-fit,minmax(400px, 600px));
row-gap: 20px;
column-gap: 20px;
/* gap: 20px; */
grid-auto-rows: 150px;
/* align-items: center; */
/* justify-items: center; */


}


.div1{
    background-color: red;
    border: 1px solid black;
}
.div2{
    background-color: rgb(59, 216, 221);
    border: 1px solid black;
    /* grid-column: 1/-1; */
}
.div3{
    background-color: rgb(102, 0, 255);
    border: 1px solid black;
}
.div4{
    background-color: rgb(255, 230, 0);
    border: 1px solid black;
}
.div5{
    background-color: rgb(255, 0, 183);
    border: 1px solid black;
    /* grid-row-start:1; */
    /* grid-column-start: 2; */
    /* grid-column-end: 4; */


    
    /* grid-row:1/2; */
    /* grid-column:2/4; */
}
.div6{
    background-color: rgb(30, 255, 0);
    border: 1px solid black;
}
Center container and its child container
.parent{
    display:grid;
}
Create a Login modal popup using HTML and CSS
/* Check the article on website */
variables
:root {

    /**
     * colors
     */
  
    --spanish-gray: hsl(0, 0%, 60%);
    --sonic-silver: hsl(0, 0%, 47%);
    --eerie-black: hsl(0, 0%, 13%);
    --salmon-pink: hsl(353, 100%, 78%);
    --sandy-brown: hsl(29, 90%, 65%);
    --bittersweet: hsl(0, 100%, 70%);
    --ocean-green: hsl(152, 51%, 52%);
    --davys-gray: hsl(0, 0%, 33%);
    --cultured: hsl(0, 0%, 93%);
    --white: hsl(0, 100%, 100%);
    --onyx: hsl(0, 0%, 27%);
  
    /**
     * typography
     */
  
    --fs-1: 1.563rem;
    --fs-2: 1.375rem;
    --fs-3: 1.25rem;
    --fs-4: 1.125rem;
    --fs-5: 1rem;
    --fs-6: 0.938rem;
    --fs-7: 0.875rem;
    --fs-8: 0.813rem;
    --fs-9: 0.75rem;
    --fs-10: 0.688rem;
    --fs-11: 0.625rem;
  
    --weight-300: 300;
    --weight-400: 400;
    --weight-500: 500;
    --weight-600: 600;
    --weight-700: 700;
  
    /**
     * border-radius
     */
  
    --border-radius-md: 10px;
    --border-radius-sm: 5px;
  
    /**
     * transition 
     */
  
    --transition-timing: 0.2s ease;
  
}
Change color of <hr> element using CSS
hr {
    height: 2px;
    background-color: #ff0000;
    border: none;
}
Apply :hover on element:after and element:before using CSS
.box {
    position: relative;
}

.box:hover:before {
    content: "Before content";
}

.box:hover:after {
    content: "After content";
}
SHOW/HIDE a div when checkbox is checked using CSS only
.div_box {
    border: 1px solid #aaa;
    padding: 10px;
    display: none;
}

.checkbox:checked + .div_box {
    display: block;
}
10 methods to vertically center a text using CSS
/* Using flex */
.ele {
    display: flex;
    align-items: center;
    height: 200px;
    background: #DDDDDD;
}
Remove underline from link using CSS
.link {
    text-decoration: none;
}
CSS Input Placeholder Customization
/* SUPPORTS - chrome, firefox, opera, safari */
::placeholder {
  color: blue;
  opacity: 1;
}

/* SUPPORTS - internet explorer 10+ */
:-ms-input-placeholder { 
  color: blue;
}

/* SUPPORTS - microsoft edge */
::-ms-input-placeholder { 
  color: blue;
}

/* FOR SPECIFIC INPUT HAVING CLASS - control  */
input.control::placeholder {
    color: blue;
    opacity: 1;
}
Remove (WebKit) Chrome browser autofill background color CSS
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active  {
    /* -webkit-box-shadow: 0 0 0 40px white inset !important; */
    -webkit-box-shadow: 0 0 0 0 rgba(white,0.0) inset !important;

}
input:-webkit-autofill {
    -webkit-text-fill-color: yellow;
}
test.test
padding:10px;
Create a simple Vertical menu using CSS Example 1
.v_menu {
    border: 1px solid #ddd;
    width: 250px;
    margin: 0;
    padding: 5px;
    border-radius: 10px;
}
.v_menu li {
    display: block;
}
.v_menu li a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    border-radius: 10px;
    color: #000;
    font-size: 15px;
}
.v_menu li a.active {
    background: #000;
    color: #fff;
}
sample css code
.sample{
    display: inline-block;
    background-color: red;
}
sample css
.sample{
    display: inline-block;
    background-color: red;
}
Add border radius to element CSS
/*add radius all sides*/
.element {
    border-radius: 10px;
}
/* 
add radius specific sides 
order - top-left top-right bottom-right bottom-left
*/
.element {
    border-radius: 20px 10px 30px 20px;
}
Add image to background using CSS
/* using background proprty */
body {
    background: url('https://placeimg.com/640/480/arch'); /*this will add image to background */
}

/* using background */
body {
    background-image: url('https://placeimg.com/640/480/arch'); /*this will add image to background */
}
Change Last element style using CSS
ul li:last-child {
    background: #ff0000;
    border: 1px solid #ff0000;
}
Change font color CSS
.element {
    color: #ff0000;
}
Customize placeholder color in CSS
/* SUPPORTS - chrome, firefox, opera, safari */
::placeholder {
  color: blue;
  opacity: 1;
}

/* SUPPORTS - internet explorer 10+ */
:-ms-input-placeholder { 
  color: blue;
}

/* SUPPORTS - microsoft edge */
::-ms-input-placeholder { 
  color: blue;
}

/* FOR SPECIFIC INPUT HAVING CLASS - control  */
input.control::placeholder {
    color: blue;
    opacity: 1;
}
Capitalize, Uppercase, Lowercase, text-transform in CSS
/* TO CAPITALIZE A SENTENCE */
.capitalize {
    text-transform: capitalize;
}

/* TO UPPERCASE A SENTENCE */
.uppercase {
    text-transform: uppercase;
}

/* TO LOWERCASE A SENTENCE */
.lowercase {
    text-transform: lowercase;
}
Word spacing CSS
.paragraph {
    word-spacing: 10px;
}
qwe
asdf
Remove chrome browser autofill background color CSS
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active  {
    -webkit-box-shadow: 0 0 0 40px white inset !important;
}
flex direction in CSS
.flex_element {
    display: flex;
    flex-direction: row;
}

.flex_element {
    display: flex;
    flex-direction: row-reverse;
}

.flex_element {
    display: flex;
    flex-direction: column;
}

.flex_element {
    display: flex;
    flex-direction: column-reverse;
}

.flex_element {
    display: flex;
    flex-direction: initial;
}
Create skew background using CSS
.skew_container  {
   max-width: 500px;
   margin: 50px auto;
   overflow: hidden;
   padding-bottom: 4%;
}

.skew_container .skew_bg {
   height: 260px;
   background: #115edb;
   text-align: center;
   padding-top: 130px;
   margin-top: -9%;
   transform: skew(0deg, 10deg); /*THIS WILL DO THE MAGIC*/
}

.skew_container .skew_bg .content {
   color: #fff;
   font-size: 30px;
   transform: skew(0deg, -10deg); /* MAKE CONTENT HORIZENTAL */
}
Left side box shadow only in CSS
.element {
    -webkit-box-shadow: -5px 0 5px -5px #333;
    -moz-box-shadow: -5px 0 5px -5px #333;
    box-shadow: -5px 0 5px -5px #333;
}

/* FOR INSET CASE */
.elemnt_inset_left_shaow {
    -webkit-box-shadow: 7px 0 4px -4px #333 inset;
    -moz-box-shadow: 7px 0 4px -4px #333 inset;
    box-shadow: 7px 0 4px -4px #333 inset;
}
CSS3 Animations
.container {
  animation-name: popin;
  animation-duration: 5s;
  animation-timing-function: linear;
  animation-delay: 2s;
  animation-iteration-count: infinite;
  animation-direction: reverse;
}

/*THE ABOVE CODE IN SHORT FORMAT CAN BE WRITTEN IN SINGLE LINE*/
.container {
    animation: popin 5s linear 2s infinite reverse;
}

/* TO GENERATE ANIMATION WE USE KEYFRAMES */
@keyframes popin {
    from {
        transform: scale(0.8);
    }
    to {
        transform: scale(1.0);
    }
}
Rounded button
.rounded_button {
   padding: 1.2rem 2.5rem;
   font-size: 1rem;
   background: #207ef9;
   color: #fff;
   border-radius: 40px;
   border: 0;
   letter-spacing: 1px;
   cursor: pointer;
   outline: 0;
}

.rounded_button:hover {
   opacity: .9;
}
Text ellipsis for multi lines in CSS
.multi_line_ellipsis {
    display: -webkit-box;
    max-height: 3rem;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-line-clamp: 2;
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1.6rem;
}
Bottom box shadow only to element in CSS
.bottom-box-shadow {
    -webkit-box-shadow: 0 8px 6px -6px rgba(0,0,0,0.7);
       -moz-box-shadow: 0 8px 6px -6px rgba(0,0,0,0.7);
            box-shadow: 0 8px 6px -6px rgba(0,0,0,0.7);
}
Create rounded shape style button using CSS
.rounded_button {
   padding: 1.2rem 2.5rem;
   font-size: 1rem;
   background: #207ef9;
   color: #fff;
   border-radius: 40px;
   border: 0;
   letter-spacing: 1px;
   cursor: pointer;
   outline: 0;
}

.rounded_button:hover {
   opacity: .9;
}